Module: BeyondApi::ProductAvailability

Included in:
Products
Defined in:
lib/beyond_api/resources/products/availability.rb

Instance Method Summary collapse

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 }'

Examples:

@availability = session.products.adjust_stock_level("685f483e-cdda-40af-8091-d5bc31249409", -1)

Parameters:

  • product_id (String)

    the product UUID

  • relative_amount (Integer)

    the relative amount

Returns:

  • (OpenStruct)

Scopes:

  • prda:u



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>'

Examples:

@availability = session.products.availability("fb22d408-00dc-47e3-ae58-e35769bdb428")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • (OpenStruct)

Scopes:

  • prda:r



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>'

Examples:

session.products.disable_purchasability("6b30255e-650f-475c-b345-e7247f957689")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • true

Scopes:

  • prda:u



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>'

Examples:

session.products.disable_stock_management("e966cb17-4047-4b82-ade4-33e7f0978c89")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • true

Scopes:

  • prda:u



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>'

Examples:

session.products.enable_purchasability("17e3a92b-6f3b-4415-bd8f-c9c8921a5a73")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • true

Scopes:

  • prda:u



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 }'

Examples:

body = {
  "initial_available_stock" => 100,
  "stock_threshold" => 2
}
@availability = session.products.enable_stock_management("101fa968-9bb8-4dbe-b166-3add1fc1b35e", body)

Parameters:

  • product_id (String)

    the product UUID

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • prda:u



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 }'

Examples:

session.products.update_reserve_stock("f74b5f57-43cc-4176-97aa-c6eb9fdeb37c", 5)

Parameters:

  • product_id (String)

    the product UUID

  • stock_threshold (Integer)

    the stock threshold

Returns:

  • (OpenStruct)

Scopes:

  • prda:u



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