Class: Datashake::ReviewIndex::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/datashake-ruby-sdk/review_index/v1.rb,
lib/datashake-ruby-sdk/review_index/v1/error.rb,
lib/datashake-ruby-sdk/review_index/v1/reviews.rb,
lib/datashake-ruby-sdk/review_index/v1/profiles.rb,
lib/datashake-ruby-sdk/review_index/v1/response.rb,
lib/datashake-ruby-sdk/review_index/v1/base_endpoint.rb,
lib/datashake-ruby-sdk/review_index/v1/update_status.rb,
lib/datashake-ruby-sdk/review_index/v1/status_response.rb

Defined Under Namespace

Classes: BaseEndpoint, Error, Profiles, Response, Reviews, StatusResponse, UpdateStatus

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ V1

Returns a new instance of V1.



14
15
16
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 14

def initialize(client)
  @client = client
end

Instance Method Details

#connectionObject



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

def connection
  client.connection
end

#fetch(method:, path:, params: {}, body: {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 34

def fetch(method:, path:, params: {}, body: {})
  response = connection.public_send(method, path) do |request|
    request.params = params
    request.params[:api_key] = client.token
    request.body = body.to_json
  end

  body = response.body
  body["http_status"] = response.status

  return body if body["success"] || success_status?(response.status)

  raise Datashake::ReviewIndex::V1::Error.new(
    body["message"],
    body["http_status"]
  )
end

#profilesObject



18
19
20
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 18

def profiles
  @profiles ||= Profiles.new(self)
end

#reviewsObject



22
23
24
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 22

def reviews
  @reviews ||= Reviews.new(self)
end

#success_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 52

def success_status?(status)
  [200, 201].include?(status)
end

#update_statusObject



26
27
28
# File 'lib/datashake-ruby-sdk/review_index/v1.rb', line 26

def update_status
  @update_status ||= UpdateStatus.new(self)
end