Class: BeyondApi::PickupOptions
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/pickup_options.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(params = {}) ⇒ OpenStruct
A
GET
request is used to list all pickup options of the shop in a paged way. -
#create(body) ⇒ OpenStruct
A
POST
request is used to create a pickup option. -
#delete(pickup_option_id) ⇒ Object
A
DELETE
request is used to delete a pickup option. -
#find(pickup_option_id) ⇒ OpenStruct
A
GET
request is used to retrieve the details of a pickup option. -
#sort(pickup_option_ids) ⇒ OpenStruct
A
PUT
request is used to sort the pickup options. -
#update(pickup_option_id, body) ⇒ OpenStruct
A
PUT
request is used to update a pickup option.
Methods included from Utils
#file_content_type, #handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct
Methods inherited from Base
Constructor Details
This class inherits a constructor from BeyondApi::Base
Instance Method Details
#all(params = {}) ⇒ OpenStruct
A GET
request is used to list all pickup options of the shop in a paged way.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X GET \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
25 26 27 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 25 def all(params = {}) handle_all_request("/pickup-options", :pickup_options, params) end |
#create(body) ⇒ OpenStruct
A POST
request is used to create a pickup option.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"name" : "My little Cornershop - St.Ives",
"description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
"taxClass" : "REGULAR",
"freePickupValue" : {
"currency" : "EUR",
"amount" : 50
},
"fixedPrice" : {
"taxModel" : "GROSS",
"currency" : "EUR",
"amount" : 1
},
"phoneNumberRequired" : true,
"locationId" : "cb554eb6-2768-4491-afd2-6bcd0aec0937"
}'
78 79 80 81 82 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 78 def create(body) response, status = BeyondApi::Request.post(@session, "/pickup-options", body) handle_response(response, status) end |
#delete(pickup_option_id) ⇒ Object
A DELETE
request is used to delete a pickup option.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/d253a31b-3892-4196-ae16-c5d8d6b05791' -i -X DELETE
98 99 100 101 102 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 98 def delete(pickup_option_id) response, status = BeyondApi::Request.delete(@session, "/pickup-options/#{pickup_option_id}") handle_response(response, status, respond_with_true: true) end |
#find(pickup_option_id) ⇒ OpenStruct
A GET
request is used to retrieve the details of a pickup option.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/76302c10-761f-43c1-9d18-52ad16bd52e8' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
121 122 123 124 125 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 121 def find(pickup_option_id) response, status = BeyondApi::Request.get(@session, "/pickup-options/#{pickup_option_id}") handle_response(response, status) end |
#sort(pickup_option_ids) ⇒ OpenStruct
A PUT
request is used to sort the pickup options. This is done by passing the self-links of the pickup options in the desired order. The request must contain URIs for all pickup options of the given page.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X PUT \
-H 'Content-Type: text/uri-list' \
-H 'Authorization: Bearer <Access token>' \
-d 'https://api-shop.beyondshop.cloud/api/pickup-options/bff3673f-91c1-4e09-a8ab-562a3a553fac
https://api-shop.beyondshop.cloud/api/pickup-options/7b4d36fc-ac0f-44a3-8655-f2bd05c2a42d
https://api-shop.beyondshop.cloud/api/pickup-options/630b63ee-c7d8-4953-9b7c-c874fd795154'
152 153 154 155 156 157 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 152 def sort(pickup_option_ids) body = pickup_option_ids.map { |id| "#{@session.api_url}/pickup-options/#{id}" } response, status = BeyondApi::Request.put(@session, "/pickup-options", body) handle_response(response, status, respond_with_true: true) end |
#update(pickup_option_id, body) ⇒ OpenStruct
A PUT
request is used to update a pickup option.
$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/5765b837-db5b-49a9-a659-68d00376e42a' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"name" : "New name",
"description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
"taxClass" : "REGULAR",
"freePickupValue" : {
"currency" : "EUR",
"amount" : 50
},
"fixedPrice" : {
"taxModel" : "GROSS",
"currency" : "EUR",
"amount" : 1
},
"phoneNumberRequired" : true,
"locationId" : "c9179393-abcc-450a-8cf4-875b39647ab6"
}'
210 211 212 213 214 |
# File 'lib/beyond_api/resources/pickup_options.rb', line 210 def update(pickup_option_id, body) response, status = BeyondApi::Request.put(@session, "/pickup-options/#{pickup_option_id}", body) handle_response(response, status) end |