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