Class: NeomodeClient::Api
- Inherits:
-
Object
- Object
- NeomodeClient::Api
- Includes:
- NeomodeClient
- Defined in:
- lib/neomode_client/api.rb
Instance Method Summary collapse
- #fetch_categories(args = {}) ⇒ Object
- #fetch_orders(seller_code:, query:) ⇒ Object
- #fetch_product_by_id(product_id) ⇒ Object
- #fetch_products(args = {}) ⇒ Object
- #fetch_stock_quantities(args = {}) ⇒ Object
-
#initialize(args) ⇒ Api
constructor
A new instance of Api.
- #mark_order_as_paid(args = {}) ⇒ Object
- #send_order(order) ⇒ Object
- #send_products(body) ⇒ Object
- #update_invoice(order_id:, invoice:) ⇒ Object
- #update_order_status(order_id:, status:) ⇒ Object
- #update_price(body) ⇒ Object
- #update_quantity(body) ⇒ Object
- #update_tracking(order_id:, tracking:) ⇒ Object
Methods included from NeomodeClient
Constructor Details
#initialize(args) ⇒ Api
Returns a new instance of Api.
5 6 7 8 |
# File 'lib/neomode_client/api.rb', line 5 def initialize(args) @token = args[:token] @is_production = args[:is_production] end |
Instance Method Details
#fetch_categories(args = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/neomode_client/api.rb', line 58 def fetch_categories(args = {}) response = connection.get("/management/catalog/categories", args) handler.new(response).parse! end |
#fetch_orders(seller_code:, query:) ⇒ Object
28 29 30 31 32 |
# File 'lib/neomode_client/api.rb', line 28 def fetch_orders(seller_code:, query:) response = connection.get("/management/commerce/sellers/#{seller_code}/orders", query) handler.new(response).parse! end |
#fetch_product_by_id(product_id) ⇒ Object
70 71 72 73 74 |
# File 'lib/neomode_client/api.rb', line 70 def fetch_product_by_id(product_id) response = connection.get("/management/catalog/products/#{product_id}") handler.new(response).parse! end |
#fetch_products(args = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/neomode_client/api.rb', line 64 def fetch_products(args = {}) response = connection.get("/management/catalog/products", args) handler.new(response).parse! end |
#fetch_stock_quantities(args = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/neomode_client/api.rb', line 52 def fetch_stock_quantities(args = {}) response = connection.get("/management/catalog/stocks", args) handler.new(response).parse! end |
#mark_order_as_paid(args = {}) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/neomode_client/api.rb', line 82 def mark_order_as_paid(args = {}) response = Faraday .new(url: "https://#{is_production ? "" : "hlog-"}lori.neomode.com.br", headers: headers) .post("/orderupdatequeue?#{args.to_query}") handler.new(response).parse! end |
#send_order(order) ⇒ Object
76 77 78 79 80 |
# File 'lib/neomode_client/api.rb', line 76 def send_order(order) response = connection.post("/management/commerce/orders", order.to_json) handler.new(response).parse! end |
#send_products(body) ⇒ Object
10 11 12 13 14 |
# File 'lib/neomode_client/api.rb', line 10 def send_products(body) response = connection.put("/management/catalog/products", body.to_json) handler.new(response).parse! end |
#update_invoice(order_id:, invoice:) ⇒ Object
40 41 42 43 44 |
# File 'lib/neomode_client/api.rb', line 40 def update_invoice(order_id:, invoice:) response = connection.put("/management/commerce/orders/#{order_id}/invoicedetails", {invoice: invoice}.to_json) handler.new(response).parse! end |
#update_order_status(order_id:, status:) ⇒ Object
34 35 36 37 38 |
# File 'lib/neomode_client/api.rb', line 34 def update_order_status(order_id:, status:) response = connection.put("/management/commerce/orders/#{order_id}/status/#{status}") handler.new(response).parse! end |
#update_price(body) ⇒ Object
22 23 24 25 26 |
# File 'lib/neomode_client/api.rb', line 22 def update_price(body) response = connection.put("/management/catalog/prices", body.to_json) handler.new(response).parse! end |
#update_quantity(body) ⇒ Object
16 17 18 19 20 |
# File 'lib/neomode_client/api.rb', line 16 def update_quantity(body) response = connection.put("/management/catalog/stocks", body.to_json) handler.new(response).parse! end |
#update_tracking(order_id:, tracking:) ⇒ Object
46 47 48 49 50 |
# File 'lib/neomode_client/api.rb', line 46 def update_tracking(order_id:, tracking:) response = connection.put("/management/commerce/orders/#{order_id}/trackingdetails", tracking.to_json) handler.new(response).parse! end |