Class: Custplace::Reviews
- Defined in:
- lib/custplace/answers.rb,
lib/custplace/reviews.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#find(review_id) ⇒ Custplace::Entities::Store
Retrieves the details of an existing review.
-
#list(params: {}) ⇒ Array<Custplace::Entities::Store>
Get the list of all reviews.
- #reply(review_id, message) ⇒ Object
Methods inherited from Base
#default_headers, #get, #initialize, #post
Constructor Details
This class inherits a constructor from Custplace::Base
Instance Method Details
#find(review_id) ⇒ Custplace::Entities::Store
Retrieves the details of an existing review.
34 35 36 37 |
# File 'lib/custplace/reviews.rb', line 34 def find(review_id) response = get("/messages/#{review_id}") Custplace::Entities::Review.new(response["data"]) end |
#list(params: {}) ⇒ Array<Custplace::Entities::Store>
Get the list of all reviews
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/custplace/reviews.rb', line 11 def list(params: {}) page = 1 reviews = [] response = get("/messages", params: params.merge(page: page, per_page: 100 )) data = response["data"] reviews = reviews.concat(data.map { |review| Custplace::Entities::Review.new(review) }) pagination = response["links"] while pagination["next"] page += 1 response = get("/messages", params: params.merge(page: page)) data = response["data"] reviews = reviews.concat(data.map { |review| Custplace::Entities::Review.new(review) }) pagination = response["links"] end reviews end |