Module: BeyondApi::ProductAttachments
- Included in:
- Products
- Defined in:
- lib/beyond_api/resources/products/attachments.rb
Instance Method Summary collapse
-
#add_attachment(product_id, body) ⇒ OpenStruct
A
POST
request is used to create an attachment and add it to a product. -
#attachment(product_id, attachment_id) ⇒ OpenStruct
A
GET
request is used to retrieve a single attachment of a product. -
#attachments(product_id, params = {}) ⇒ OpenStruct
A
GET
request is used to list all the attachments of a product. -
#delete_attachment(product_id, attachment_id) ⇒ true
A
DELETE
request is used to delete a product attachment.
Instance Method Details
#add_attachment(product_id, body) ⇒ OpenStruct
A POST
request is used to create an attachment and add it to a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/ecb997ce-79c3-4367-9373-058089a313e3/attachments' -i -X POST \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"mimeType" : "application/pdf",
"length" : 1,
"label" : "Handbuch",
"dataUri" : "my_document_1.pdf?hash=8a627f655c68f56dfbbf217ab7d5563281225666"
}'
37 38 39 40 41 |
# File 'lib/beyond_api/resources/products/attachments.rb', line 37 def (product_id, body) response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/attachments", body) handle_response(response, status) end |
#attachment(product_id, attachment_id) ⇒ OpenStruct
A GET
request is used to retrieve a single attachment of a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/eb11b53a-5017-4ae7-9ba1-c02c12c80b61/attachments/36933722-f13f-4ee2-858c-0835ae0a884e' -i -X GET \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
61 62 63 64 65 |
# File 'lib/beyond_api/resources/products/attachments.rb', line 61 def (product_id, ) response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attachments/#{}") handle_response(response, status) end |
#attachments(product_id, params = {}) ⇒ OpenStruct
A GET
request is used to list all the attachments of a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/fd60a63e-c4c0-496d-af49-c4ed224cca2a/attachments' -i -X GET \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
86 87 88 89 90 |
# File 'lib/beyond_api/resources/products/attachments.rb', line 86 def (product_id, params = {}) response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attachments", params) handle_response(response, status) end |
#delete_attachment(product_id, attachment_id) ⇒ true
A DELETE
request is used to delete a product attachment
$ curl 'https://api-shop.beyondshop.cloud/api/products/00add006-beaa-46fe-bb73-f8ebae15082d/attachments/9a44e585-571a-4253-9248-54a4c418c7e2' -i -X DELETE \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
110 111 112 113 114 |
# File 'lib/beyond_api/resources/products/attachments.rb', line 110 def (product_id, ) response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/attachments/#{}") handle_response(response, status, respond_with_true: true) end |