Module: BeyondApi::VariationAvailability
- Included in:
- Variations
- Defined in:
- lib/beyond_api/resources/variations/availability.rb
Instance Method Summary collapse
-
#adjust_stock_level(product_id, variation_id, relative_amount) ⇒ OpenStruct
A
POST
request is used to adjust the available stock of a variation. -
#availability(product_id, variation_id) ⇒ OpenStruct
A
GET
request is used to retrieve the availability of a variation. -
#disable_purchasability(product_id, variation_id) ⇒ Object
A
POST
request is used to disable purchasability for a variation. -
#enable_purchasability(product_id, variation_id) ⇒ OpenStruct
A
POST
request is used to enable purchasability for a variation.
Instance Method Details
#adjust_stock_level(product_id, variation_id, relative_amount) ⇒ OpenStruct
A POST
request is used to adjust the available stock of a variation.
$ curl 'https://api-shop.beyondshop.cloud/api/products/9171c3ed-0b53-43ef-8fed-c081f55560f4/variations/a6d8275f-66cd-4cd7-8623-2d005f1ab7fc/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 }'
27 28 29 30 31 32 33 34 35 |
# File 'lib/beyond_api/resources/variations/availability.rb', line 27 def adjust_stock_level(product_id, variation_id, relative_amount) path = "/products/#{product_id}/variations/#{variation_id}/availability/adjust-available-stock" response, status = BeyondApi::Request.post(@session, path, relative_amount: relative_amount) handle_response(response, status) end |
#availability(product_id, variation_id) ⇒ OpenStruct
A GET
request is used to retrieve the availability of a variation.
$ curl 'https://api-shop.beyondshop.cloud/api/products/7fdc9424-1ddd-4fba-a59d-3d5de08d89d1/variations/13b28149-975a-4f47-ad54-bdc4ca4a07ec/availability' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
55 56 57 58 59 60 61 62 |
# File 'lib/beyond_api/resources/variations/availability.rb', line 55 def availability(product_id, variation_id) path = "/products/#{product_id}/variations/#{variation_id}/availability" response, status = BeyondApi::Request.get(@session, path) handle_response(response, status) end |
#disable_purchasability(product_id, variation_id) ⇒ Object
A POST
request is used to disable purchasability for a variation.
$ curl 'https://api-shop.beyondshop.cloud/api/products/f3b9d880-b73e-45a4-b04c-e03acae4fcdd/variations/40337e9c-a187-4bb6-9a0d-c8d66386cb8d/availability/disable-purchasability' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
108 109 110 111 112 113 114 115 |
# File 'lib/beyond_api/resources/variations/availability.rb', line 108 def disable_purchasability(product_id, variation_id) path = "/products/#{product_id}/variations/#{variation_id}/availability/disable-purchasability" response, status = BeyondApi::Request.post(@session, path) handle_response(response, status) end |
#enable_purchasability(product_id, variation_id) ⇒ OpenStruct
A POST
request is used to enable purchasability for a variation.
$ curl 'https://api-shop.beyondshop.cloud/api/products/131400c9-54f1-4510-a0c4-2c7e34c57336/variations/cec06f66-5a80-4638-a74c-c916e1173c21/availability/enable-purchasability' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
82 83 84 85 86 87 88 89 |
# File 'lib/beyond_api/resources/variations/availability.rb', line 82 def enable_purchasability(product_id, variation_id) path = "/products/#{product_id}/variations/#{variation_id}/availability/enable-purchasability" response, status = BeyondApi::Request.post(@session, path) handle_response(response, status) end |