Class: DiffbotSimple::V2::Client
- Inherits:
-
Object
- Object
- DiffbotSimple::V2::Client
- Defined in:
- lib/diffbot_simple/v2/client.rb
Instance Method Summary collapse
- #analyze ⇒ Object
- #article ⇒ Object
- #bulk(name: nil) ⇒ Object
- #crawl(name: nil) ⇒ Object
- #custom(name: nil) ⇒ Object
- #image ⇒ Object
-
#initialize(token: nil, bulk_api: nil, api_client: nil, crawlbot_api: nil) ⇒ Client
constructor
A new instance of Client.
- #product ⇒ Object
Constructor Details
#initialize(token: nil, bulk_api: nil, api_client: nil, crawlbot_api: nil) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 |
# File 'lib/diffbot_simple/v2/client.rb', line 4 def initialize token: nil, bulk_api: nil, api_client: nil, crawlbot_api: nil raise ArgumentError.new("Must supply developer token") if token.to_s.empty? @token = token @api_client = api_client ||= ApiClient.new @bulk_api = bulk_api ||= BulkApi.new(api_client: api_client, token: token) @crawlbot_api = crawlbot_api ||= CrawlbotApi.new(api_client: api_client, token: token) end |
Instance Method Details
#analyze ⇒ Object
23 24 25 |
# File 'lib/diffbot_simple/v2/client.rb', line 23 def analyze Analyze.new api_client: api_client, token: token end |
#article ⇒ Object
11 12 13 |
# File 'lib/diffbot_simple/v2/client.rb', line 11 def article Article.new api_client: api_client, token: token end |
#bulk(name: nil) ⇒ Object
26 27 28 29 |
# File 'lib/diffbot_simple/v2/client.rb', line 26 def bulk name: nil return bulk_api.all.map { |e| Bulk.new name: e.delete(:name), init: e, bulk_api: bulk_api } unless name return Bulk.new name: name, bulk_api: bulk_api end |
#crawl(name: nil) ⇒ Object
30 31 32 33 |
# File 'lib/diffbot_simple/v2/client.rb', line 30 def crawl name: nil return crawlbot_api.all.map { |e| Crawl.new name: e.delete(:name), init: e, crawlbot_api: crawlbot_api } unless name return Crawl.new name: name, crawlbot_api: crawlbot_api end |
#custom(name: nil) ⇒ Object
14 15 16 |
# File 'lib/diffbot_simple/v2/client.rb', line 14 def custom name: nil Custom.new api_client: api_client, token: token, name: name end |
#image ⇒ Object
20 21 22 |
# File 'lib/diffbot_simple/v2/client.rb', line 20 def image Image.new api_client: api_client, token: token end |
#product ⇒ Object
17 18 19 |
# File 'lib/diffbot_simple/v2/client.rb', line 17 def product Product.new api_client: api_client, token: token end |