Skip to content

Commit 6156677

Browse files
author
Scott Martin
committed
Make the API parameter optional, because it causes Diffbot to waste time on large jobs, and prevent sending the same request twice when getting details.
1 parent 4aecef6 commit 6156677

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/diffbot/api_client/bot.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class Bot
99
# @param options [Hash]
1010
def initialize client, options = {}
1111
@api = options.delete(:api)
12-
raise ArgumentError.new("client should be an instance of Diffbot::APIClient::GenericAPI") unless @api.is_a?(Diffbot::APIClient::GenericAPI)
12+
raise ArgumentError.new("client should be an instance of Diffbot::APIClient::GenericAPI") unless @api.nil? || @api.is_a?(Diffbot::APIClient::GenericAPI)
1313

14-
options[:apiUrl] = @api.full_url
14+
options[:apiUrl] = @api.full_url if @api
1515

1616
raise ArgumentError.new("client should be an instance of Diffbot::APIClient") unless client.is_a?(Diffbot::APIClient)
1717
@client = client
@@ -33,6 +33,7 @@ def url
3333
#
3434
# @return [Hash]
3535
def details
36+
return @details if @details
3637
post
3738
end
3839

lib/diffbot/api_client/bulk.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Bulk < Bot
1111
def initialize client, options = {}
1212
super(client, options)
1313

14-
post(parse_params(options))
14+
@details = post(parse_params(options))
1515
end
1616

1717
# Return request path

0 commit comments

Comments
 (0)