Class: Crema::Client
Instance Method Summary collapse
- #fetch_product(product_id, brand_id: nil) ⇒ Object
- #fetch_products(brand_id: nil, page: 1, limit: 30, status: 'selling') ⇒ Object
Methods inherited from Base
Instance Method Details
#fetch_product(product_id, brand_id: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/crema/client.rb', line 16 def fetch_product(product_id, brand_id: nil) response = connection.get( "/v1/products/#{product_id}", brand_id: brand_id, access_token: Crema.config.access_token ) return nil unless response.success? Product.new(JSON.parse(response.body)) end |
#fetch_products(brand_id: nil, page: 1, limit: 30, status: 'selling') ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/crema/client.rb', line 3 def fetch_products(brand_id: nil, page: 1, limit: 30, status: 'selling') response = connection.get( '/v1/products', brand_id: brand_id, page: page, limit: limit, status: status, access_token: Crema.config.access_token ) return nil unless response.success? JSON.parse(response.body).map { |i| Product.new(i) } end |