Class: Datashake::ReviewScraper::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/datashake-ruby-sdk/review_scraper/client.rb

Constant Summary collapse

BASE_URL =
"https://app.datashake.com"

Instance Method Summary collapse

Constructor Details

#initialize(token:, adapter: Faraday.default_adapter, endpoint: nil, timeout: 30, open_timeout: 30) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 10

def initialize(token:, adapter: Faraday.default_adapter, endpoint: nil, timeout: 30, open_timeout: 30)
  @token = token
  @base_url = endpoint || BASE_URL
  @adapter = adapter
  @timeout = timeout
  @open_timeout = open_timeout
end

Instance Method Details

#add_profileObject



38
39
40
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 38

def add_profile
  v2.profiles.add
end

#add_profilesObject



42
43
44
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 42

def add_profiles
  v2.profiles.add_bulk
end

#connectionObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 18

def connection
  @connection ||= Faraday.new do |conn|
    conn.headers = {"spiderman-token" => token}
    conn.url_prefix = base_url
    conn.request(:json)
    conn.response(:json, content_type: "application/json")
    conn.options.timeout = timeout
    conn.options.open_timeout = open_timeout
    conn.adapter(adapter)
  end
end

#info(job_id) ⇒ Object



54
55
56
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 54

def info(job_id)
  v2.profiles.info.job_id(job_id)
end

#job(job_id) ⇒ Object



50
51
52
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 50

def job(job_id)
  v2.profiles.job.job_id(job_id)
end

#jobsObject



46
47
48
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 46

def jobs
  v2.profiles.jobs
end

#profilesObject



34
35
36
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 34

def profiles
  v2.profiles
end

#reviews(job_id) ⇒ Object



58
59
60
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 58

def reviews(job_id)
  v2.profiles.reviews.job_id(job_id)
end

#v2Object



30
31
32
# File 'lib/datashake-ruby-sdk/review_scraper/client.rb', line 30

def v2
  @v2 ||= V2.new(self)
end