Class: Ecommerce::Resources::AdjustmentOrder
- Defined in:
- lib/ecommerce/resources/adjustment_order.rb
Overview
A wrapper to Ecommerce adjusments orders API
- API
-
Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/index.html
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#valid_from ⇒ Object
readonly
Returns the value of attribute valid_from.
-
#valid_until ⇒ Object
readonly
Returns the value of attribute valid_until.
Class Method Summary collapse
- .build(response) ⇒ Object
-
.create(slug, order_id, params) ⇒ Object
Creates an Adjustment order.
-
.destroy(order_id, slug, id) ⇒ Object
Destroys an Adjustment order.
-
.find(slug, order_id, id) ⇒ Object
Finds an Adjustment order.
-
.find_all(slug, order_id, page = 1, limit = 20) ⇒ Object
Lists all Adjustments orders of an order and return a collection and pagination information (represented by Ecommerce::Resources::AdjustmentOrderCollection).
Instance Method Summary collapse
-
#id ⇒ Object
Adjustment order API does not return the ID field.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Ecommerce::Resources::Base
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
10 11 12 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 10 def amount @amount end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 10 def description @description end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 10 def url @url end |
#valid_from ⇒ Object (readonly)
Returns the value of attribute valid_from.
10 11 12 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 10 def valid_from @valid_from end |
#valid_until ⇒ Object (readonly)
Returns the value of attribute valid_until.
10 11 12 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 10 def valid_until @valid_until end |
Class Method Details
.build(response) ⇒ Object
77 78 79 80 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 77 def self.build(response) attributes = parsed_body(response) attributes.empty? ? {} : new(attributes) end |
.create(slug, order_id, params) ⇒ Object
Creates an Adjustment order
- API
-
Method:
POST /api/orders/:slug/:id/adjustments/
Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#criacao-de-alteracao-de-valor-para-uma-ordem-de-compra
27 28 29 30 31 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 27 def self.create(slug, order_id, params) client.post("/api/orders/#{slug}/#{order_id}/adjustments/", body: params) do |response| build(response) end end |
.destroy(order_id, slug, id) ⇒ Object
Destroys an Adjustment order
- API
-
Method:
DELETE /api/orders/:slug/:order_id/adjustments/:id/
Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#remocao-de-uma-alteracao-de-valor
71 72 73 74 75 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 71 def self.destroy(order_id, slug, id) client.delete("/api/orders/#{slug}/#{order_id}/adjustments/#{id}/") do |response| build(response) end end |
.find(slug, order_id, id) ⇒ Object
Finds an Adjustment order
- API
-
Method:
GET /api/orders/:slug/:order_id/adjustments/:id/
Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#obtencao-dos-dados-de-uma-alteracao-de-valor
57 58 59 60 61 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 57 def self.find(slug, order_id, id) client.get("/api/orders/#{slug}/#{order_id}/adjustments/#{id}/") do |response| build(response) end end |
.find_all(slug, order_id, page = 1, limit = 20) ⇒ Object
Lists all Adjustments orders of an order and return a collection and pagination information (represented by Ecommerce::Resources::AdjustmentOrderCollection)
- API
-
Method:
GET /api/orders/:slug/adjustments/
Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#listagem-das-alteracoes-de-valor-associadas-a-uma-ordem-de-compra
42 43 44 45 46 47 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 42 def self.find_all(slug, order_id, page = 1, limit = 20) body = { page: page, limit: limit } client.get("/api/orders/#{slug}/#{order_id}/adjustments/", body: body) do |response| Ecommerce::Resources::AdjustmentOrderCollection.build(response) end end |
Instance Method Details
#id ⇒ Object
Adjustment order API does not return the ID field
15 16 17 |
# File 'lib/ecommerce/resources/adjustment_order.rb', line 15 def id url.split('/')[8].to_i end |