Module: BeyondApi::ProductAvailability
- Included in:
- Products
- Defined in:
- lib/beyond_api/resources/products/availability.rb
Instance Method Summary collapse
-
#adjust_stock_level(product_id, relative_amount) ⇒ OpenStruct
A
POST
request is used to adjust the available stock of a product. -
#availability(product_id) ⇒ OpenStruct
A
GET
request is used to retrieve the availability of a product. -
#disable_purchasability(product_id) ⇒ Object
A
POST
request is used to disable purchasability for a product. -
#disable_stock_management(product_id) ⇒ Object
A
POST
request is used to disable stock management for a product or variation product. -
#enable_purchasability(product_id) ⇒ Object
A
POST
request is used to enable purchasability for a product. -
#enable_stock_management(product_id, body) ⇒ OpenStruct
A
POST
request is used to enable stock management for a product or variation product. -
#update_reserve_stock(product_id, stock_threshold) ⇒ OpenStruct
A
PUT
request is used to update the reserve stock by changing thestockThreshold
value of a product or variation product (incl. all of its variations).
Instance Method Details
#adjust_stock_level(product_id, relative_amount) ⇒ OpenStruct
A POST
request is used to adjust the available stock of a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/685f483e-cdda-40af-8091-d5bc31249409/availability/adjust-available-stock' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{ "relativeAmount" : -1 }'
26 27 28 29 30 31 32 |
# File 'lib/beyond_api/resources/products/availability.rb', line 26 def adjust_stock_level(product_id, relative_amount) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/adjust-available-stock", { relative_amount: relative_amount }) handle_response(response, status) end |
#availability(product_id) ⇒ OpenStruct
A GET
request is used to retrieve the availability of a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/fb22d408-00dc-47e3-ae58-e35769bdb428/availability' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
51 52 53 54 55 56 |
# File 'lib/beyond_api/resources/products/availability.rb', line 51 def availability(product_id) response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/availability") handle_response(response, status) end |
#disable_purchasability(product_id) ⇒ Object
A POST
request is used to disable purchasability for a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/6b30255e-650f-475c-b345-e7247f957689/availability/disable-purchasability' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
75 76 77 78 79 80 |
# File 'lib/beyond_api/resources/products/availability.rb', line 75 def disable_purchasability(product_id) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-purchasability") handle_response(response, status, respond_with_true: true) end |
#disable_stock_management(product_id) ⇒ Object
A POST
request is used to disable stock management for a product or variation product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/e966cb17-4047-4b82-ade4-33e7f0978c89/availability/disable-stock-management' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
99 100 101 102 103 104 |
# File 'lib/beyond_api/resources/products/availability.rb', line 99 def disable_stock_management(product_id) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-stock-management") handle_response(response, status, respond_with_true: true) end |
#enable_purchasability(product_id) ⇒ Object
A POST
request is used to enable purchasability for a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/17e3a92b-6f3b-4415-bd8f-c9c8921a5a73/availability/enable-purchasability' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
123 124 125 126 127 128 |
# File 'lib/beyond_api/resources/products/availability.rb', line 123 def enable_purchasability(product_id) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/enable-purchasability") handle_response(response, status, respond_with_true: true) end |
#enable_stock_management(product_id, body) ⇒ OpenStruct
A POST
request is used to enable stock management for a product or variation product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/101fa968-9bb8-4dbe-b166-3add1fc1b35e/availability/enable-stock-management' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{ "initialAvailableStock" : 100, "stockThreshold" : 2 }'
153 154 155 156 157 158 159 |
# File 'lib/beyond_api/resources/products/availability.rb', line 153 def enable_stock_management(product_id, body) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/enable-stock-management", body) handle_response(response, status) end |
#update_reserve_stock(product_id, stock_threshold) ⇒ OpenStruct
A PUT
request is used to update the reserve stock by changing the stockThreshold
value of a product or variation product (incl. all of its variations). Reserve stock refers to an inventory level that indicates that a product needs to be reordered.
$ curl 'https://api-shop.beyondshop.cloud/api/products/f74b5f57-43cc-4176-97aa-c6eb9fdeb37c/availability/update-stock-threshold' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{ "stockThreshold" : 5 }'
180 181 182 183 184 185 186 |
# File 'lib/beyond_api/resources/products/availability.rb', line 180 def update_reserve_stock(product_id, stock_threshold) response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/availability/update-stock-threshold", { stock_threshold: stock_threshold }) handle_response(response, status) end |