Class: DiffbotSimple::V2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/diffbot_simple/v2/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(token: nil, bulk_api: nil, api_client: nil, crawlbot_api: nil) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


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

#analyzeObject



23
24
25
# File 'lib/diffbot_simple/v2/client.rb', line 23

def analyze
	Analyze.new api_client: api_client, token: token
end

#articleObject



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

#imageObject



20
21
22
# File 'lib/diffbot_simple/v2/client.rb', line 20

def image
	Image.new api_client: api_client, token: token
end

#productObject



17
18
19
# File 'lib/diffbot_simple/v2/client.rb', line 17

def product
	Product.new api_client: api_client, token: token
end