Module: BeyondApi::VariationAvailability

Included in:
Variations
Defined in:
lib/beyond_api/resources/variations/availability.rb

Instance Method Summary collapse

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

Examples:

@availability = session.variations.adjust_stock_level(product_id, variation_id, { relativeAmount => -1 })

Parameters:

  • product_id (String)

    the product UUID

  • variation_id (String)

    the product variation UUID

  • relative_amount (Integer)

    the relative amount

Returns:

  • (OpenStruct)

Scopes:

  • prda:u


28
29
30
31
32
# File 'lib/beyond_api/resources/variations/availability.rb', line 28

def adjust_stock_level(product_id, variation_id, relative_amount)
  response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variations/#{variation_id}/availability/adjust-available-stock", 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>'

Examples:

@availability = session.variations.availability("fb22d408-00dc-47e3-ae58-e35769bdb428", "13b28149-975a-4f47-ad54-bdc4ca4a07ec")

Parameters:

  • product_id (String)

    the product UUID

  • variation_id (String)

    the product variation UUID

Returns:

  • (OpenStruct)

Scopes:

  • prda:r


52
53
54
55
56
# File 'lib/beyond_api/resources/variations/availability.rb', line 52

def availability(product_id, variation_id)
  response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variations/#{variation_id}/availability")

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

Examples:

@availability = session.variations.disable_purchasability("17e3a92b-6f3b-4415-bd8f-c9c8921a5a73", "13b28149-975a-4f47-ad54-bdc4ca4a07ec")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • true

Scopes:

  • prda:u


99
100
101
102
103
# File 'lib/beyond_api/resources/variations/availability.rb', line 99

def disable_purchasability(product_id, variation_id)
  response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variations/#{variation_id}/availability/disable-purchasability")

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

Examples:

@availability = session.variations.enable_purchaability("1e3a92b-6f3b-4415-bd8f-c9c8921a5a73", "13b28149-975a-4f47-ad54-bdc4ca4a07ec")

Parameters:

  • product_id (String)

    the product UUID

  • variation_id (String)

    the product variation UUID

Returns:

  • (OpenStruct)

Scopes:

  • prda:u


76
77
78
79
80
# File 'lib/beyond_api/resources/variations/availability.rb', line 76

def enable_purchasability(product_id, variation_id)
  response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variations/#{variation_id}/availability/enable-purchasability")

  handle_response(response, status)
end