Class: Datashake::ReviewScraper::V2
- Inherits:
-
Object
- Object
- Datashake::ReviewScraper::V2
- Defined in:
- lib/datashake-ruby-sdk/review_scraper/v2.rb,
lib/datashake-ruby-sdk/review_scraper/v2/error.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles.rb,
lib/datashake-ruby-sdk/review_scraper/v2/response.rb,
lib/datashake-ruby-sdk/review_scraper/v2/job_instance.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/add.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/job.rb,
lib/datashake-ruby-sdk/review_scraper/v2/bulk_response.rb,
lib/datashake-ruby-sdk/review_scraper/v2/jobs_instance.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/info.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/jobs.rb,
lib/datashake-ruby-sdk/review_scraper/v2/review_instance.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profile_instance.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/reviews.rb,
lib/datashake-ruby-sdk/review_scraper/v2/profiles/add_bulk.rb,
lib/datashake-ruby-sdk/review_scraper/v2/review_response_instance.rb
Defined Under Namespace
Classes: BulkResponse, Error, JobInstance, JobsInstance, ProfileInstance, Profiles, Response, ReviewInstance, ReviewResponseInstance
Instance Method Summary collapse
- #connection ⇒ Object
- #fetch(method:, path:, params: {}, body: {}) ⇒ Object
-
#initialize(client) ⇒ V2
constructor
A new instance of V2.
- #profiles ⇒ Object
Constructor Details
#initialize(client) ⇒ V2
Returns a new instance of V2.
16 17 18 |
# File 'lib/datashake-ruby-sdk/review_scraper/v2.rb', line 16 def initialize(client) @client = client end |
Instance Method Details
#connection ⇒ Object
24 25 26 |
# File 'lib/datashake-ruby-sdk/review_scraper/v2.rb', line 24 def connection client.connection end |
#fetch(method:, path:, params: {}, body: {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/datashake-ruby-sdk/review_scraper/v2.rb', line 28 def fetch(method:, path:, params: {}, body: {}) response = connection.public_send(method, path) do |request| request.params = params request.body = body.to_json end body = response.body raise Datashake::ReviewScraper::V2::Error.new("Server error", 500) if response.status >= 500 return body if body.is_a?(Array) return body if body["status"].is_a?(String) return body if body["jobs"] return body if body["status"] == 200 raise Datashake::ReviewScraper::V2::Error.new( body["message"], body.fetch("status", response.status) ) end |