Module: BeyondApi::ShopAttributes
- Included in:
- Shop
- Defined in:
- lib/beyond_api/resources/shops/attributes.rb
Instance Method Summary collapse
-
#attribute(attribute_name) ⇒ OpenStruct
A
GET
request is used to retrieve a particular shop attribute by its name. -
#attributes(params = {}) ⇒ OpenStruct
A
GET
request is used to retrieve a list of all shop attributes. -
#create_attribute(body) ⇒ OpenStruct
A
POST
request is used to create a shop attribute. -
#delete_attribute(attribute_name) ⇒ Object
A
DELETE
request is used to delete an shop attribute. -
#update_attribute(attribute_name, body) ⇒ OpenStruct
A
PUT
request is used to update a shop attribute.
Instance Method Details
#attribute(attribute_name) ⇒ OpenStruct
A GET
request is used to retrieve a particular shop attribute by its name.
$ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X GET \
-H 'Authorization: Bearer <Access token>'
22 23 24 25 26 |
# File 'lib/beyond_api/resources/shops/attributes.rb', line 22 def attribute(attribute_name) response, status = BeyondApi::Request.get(@session, "/shop/attributes/#{attribute_name}") handle_response(response, status) end |
#attributes(params = {}) ⇒ OpenStruct
A GET
request is used to retrieve a list of all shop attributes.
$ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X GET \
-H 'Authorization: Bearer <Access token>'
44 45 46 47 48 |
# File 'lib/beyond_api/resources/shops/attributes.rb', line 44 def attributes(params = {}) response, status = BeyondApi::Request.get(@session, "/shop/attributes", params) handle_response(response, status) end |
#create_attribute(body) ⇒ OpenStruct
A POST
request is used to create a shop attribute.
$ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"name" : "second-unknown-attribute-name",
"value" : "correct-value",
"public" : false
}'
77 78 79 80 81 |
# File 'lib/beyond_api/resources/shops/attributes.rb', line 77 def create_attribute(body) response, status = BeyondApi::Request.post(@session, "/shop/attributes", body) handle_response(response, status) end |
#delete_attribute(attribute_name) ⇒ Object
A DELETE
request is used to delete an shop attribute.
$ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X DELETE \
-H 'Authorization: Bearer <Access token>'
98 99 100 101 102 |
# File 'lib/beyond_api/resources/shops/attributes.rb', line 98 def delete_attribute(attribute_name) response, status = BeyondApi::Request.delete(@session, "/shop/attributes/#{attribute_name}") handle_response(response, status, respond_with_true: true) end |
#update_attribute(attribute_name, body) ⇒ OpenStruct
A PUT
request is used to update a shop attribute. This operation is idempotent and will create a new shop attribute if required.
$ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"value" : "new-value",
"public" : false
}'
130 131 132 133 134 |
# File 'lib/beyond_api/resources/shops/attributes.rb', line 130 def update_attribute(attribute_name, body) response, status = BeyondApi::Request.put(@session, "/shop/attributes/#{attribute_name}", body) handle_response(response, status) end |