Class: BeyondApi::PaymentMethods
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/payment_methods.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#activate(payment_method_id) ⇒ Object
A
POST
request is used to activate a payment method. -
#all(params = {}) ⇒ OpenStruct
A
GET
request is used to list all payment methods in a paged way. -
#deactivate(payment_method_id) ⇒ Object
A
POST
request is used to deactivate a payment method. -
#find(payment_method_id) ⇒ OpenStruct
A
GET
request is used to retrieve the details of a payment method. -
#sort(payment_method_ids) ⇒ OpenStruct
A
PUT
request is used to sort payment methods. -
#update(payment_method_id, body) ⇒ OpenStruct
A
PUT
request is used to update a payment method.
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
#activate(payment_method_id) ⇒ Object
A POST
request is used to activate a payment method.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods/da313b73-ea6b-49c7-8a3d-d707934098b8/activate' -i -X POST \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
25 26 27 28 29 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 25 def activate(payment_method_id) response, status = BeyondApi::Request.post(@session, "/payment-methods/#{payment_method_id}/activate") handle_response(response, status, respond_with_true: true) end |
#all(params = {}) ⇒ OpenStruct
A GET
request is used to list all payment methods in a paged way.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods' -i -X GET \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
50 51 52 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 50 def all(params = {}) handle_all_request("/payment-methods", :payment_methods, params) end |
#deactivate(payment_method_id) ⇒ Object
A POST
request is used to deactivate a payment method.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods/157f930f-328a-4d7a-974d-66bc3b4dd28e/deactivate' -i -X POST \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
70 71 72 73 74 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 70 def deactivate(payment_method_id) response, status = BeyondApi::Request.post(@session, "/payment-methods/#{payment_method_id}/deactivate") handle_response(response, status, respond_with_true: true) end |
#find(payment_method_id) ⇒ OpenStruct
A GET
request is used to retrieve the details of a payment method.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods/7d964402-8f67-48f3-af86-6c35abe4fa08' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
93 94 95 96 97 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 93 def find(payment_method_id) response, status = BeyondApi::Request.get(@session, "/payment-methods/#{payment_method_id}") handle_response(response, status) end |
#sort(payment_method_ids) ⇒ OpenStruct
A PUT
request is used to sort payment methods.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods' -i -X PUT \
-H 'Content-Type: text/uri-list' \
-H 'Authorization: Bearer <Access token>' \
-d 'https://api-shop.beyondshop.cloud/api/payment-methods/dd59a52b-0661-49f9-82c3-e063ff80328f
https://api-shop.beyondshop.cloud/api/payment-methods/66b22fb2-2184-4ea1-9143-44ae1d230d49
https://api-shop.beyondshop.cloud/api/payment-methods/a9462eae-ed72-4e29-b853-f04537c8ab11
https://api-shop.beyondshop.cloud/api/payment-methods/84172da4-5baa-4a99-b779-33d673bed6d1'
126 127 128 129 130 131 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 126 def sort(payment_method_ids) body = payment_method_ids.map { |id| "#{@session.api_url}/payment-methods/#{id}" } response, status = BeyondApi::Request.put(@session, "/payment-methods", body) handle_response(response, status, respond_with_true: true) end |
#update(payment_method_id, body) ⇒ OpenStruct
A PUT
request is used to update a payment method.
$ curl 'https://api-shop.beyondshop.cloud/api/payment-methods/dc00a5af-d21e-49f0-99f2-ef67ca6fa782' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"name" : "Another name",
"description" : "Pay by ACME.",
"taxClass" : "REGULAR",
"discountOrFee" : {
"type" : "ABSOLUTE",
"absoluteValue" : {
"taxModel" : "GROSS",
"currency" : "EUR",
"amount" : 2.0
}
},
"serviceableCountries" : [ "DE" ],
"minimumOrderValue" : {
"currency" : "EUR",
"amount" : 10.0
}
}'
188 189 190 191 192 |
# File 'lib/beyond_api/resources/payment_methods.rb', line 188 def update(payment_method_id, body) response, status = BeyondApi::Request.put(@session, "/payment-methods/#{payment_method_id}", body) handle_response(response, status) end |