Module: BeyondApi::ProductCustomAttributes
- Included in:
- Products
- Defined in:
- lib/beyond_api/resources/products/custom_attributes.rb
Instance Method Summary collapse
-
#create_custom_attribute(product_id, body) ⇒ OpenStruct
A
POST
request is used to create a product attribute, which defines the value of a certain product attribute definition for a specific product. -
#custom_attribute(product_id, attribute_name) ⇒ OpenStruct
A
GET
request is used to retrieve detailed information about a specific product attribute. -
#custom_attributes(product_id) ⇒ OpenStruct
A
GET
request is used to retrieve all product attributes for a product. -
#delete_custom_attribute(product_id, attribute_name) ⇒ OpenStruct
A
DELETE
request is used to delete a product attribute. -
#update_custom_attribute(product_id, attribute_name, body) ⇒ OpenStruct
A
PUT
request is used to update the value of a product attribute.
Instance Method Details
#create_custom_attribute(product_id, body) ⇒ OpenStruct
A POST
request is used to create a product attribute, which defines the value of a certain product attribute definition for a specific product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/0c0e1699-d2a4-44d0-bed9-64b2fa1a7713/attributes' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"key" : "colour",
"value" : "Yellow"
}'
33 34 35 36 37 |
# File 'lib/beyond_api/resources/products/custom_attributes.rb', line 33 def create_custom_attribute(product_id, body) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/attributes", body) handle_response(response, status) end |
#custom_attribute(product_id, attribute_name) ⇒ OpenStruct
A GET
request is used to retrieve detailed information about a specific product attribute.
$ curl 'https://api-shop.beyondshop.cloud/api/products/d389347c-568e-4785-8216-91e4f8850c66/attributes/key' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>'
57 58 59 60 61 |
# File 'lib/beyond_api/resources/products/custom_attributes.rb', line 57 def custom_attribute(product_id, attribute_name) response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attributes/#{attribute_name}") handle_response(response, status) end |
#custom_attributes(product_id) ⇒ OpenStruct
A GET
request is used to retrieve all product attributes for a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/57f0ef04-9dac-462f-9dd4-606f7551cc7b/attributes' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>'
80 81 82 83 84 |
# File 'lib/beyond_api/resources/products/custom_attributes.rb', line 80 def custom_attributes(product_id) response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attributes") handle_response(response, status) end |
#delete_custom_attribute(product_id, attribute_name) ⇒ OpenStruct
A DELETE
request is used to delete a product attribute.
$ curl 'https://api-shop.beyondshop.cloud/api/products/fec3b6f3-83d0-467a-abc5-d51019e57b51/attributes/farbe' -i -X DELETE \
-H 'Authorization: Bearer <Access token>'
103 104 105 106 107 |
# File 'lib/beyond_api/resources/products/custom_attributes.rb', line 103 def delete_custom_attribute(product_id, attribute_name) response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/attributes/#{attribute_name}") handle_response(response, status, respond_with_true: true) end |
#update_custom_attribute(product_id, attribute_name, body) ⇒ OpenStruct
A PUT
request is used to update the value of a product attribute. If the specified product attribute doesn’t exist, it will be created with the response as described in Create product attribute.
$ curl 'https://api-shop.beyondshop.cloud/api/products/82ed44e9-664d-47c0-8b07-09adecfdbf20/attributes/key' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"value" : "green"
}'
134 135 136 137 138 |
# File 'lib/beyond_api/resources/products/custom_attributes.rb', line 134 def update_custom_attribute(product_id, attribute_name, body) response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/attributes/#{attribute_name}", body) handle_response(response, status) end |