Class: BeyondApi::WebhookSubscriptions
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/webhook_subscriptions.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#activate(webhook_subscription_id) ⇒ Object
A
POST
request is used to activate a webhook subscription. -
#all(params = {}) ⇒ OpenStruct
A
GET
request is used to list all of the webhook subscriptions in a paged way. -
#create(body) ⇒ OpenStruct
A
POST
request is used to create a webhook subscription. -
#deactivate(webhook_subscription_id) ⇒ Object
A
POST
request is used to deactivate a webhook subscription. -
#delete(webhook_subscription_id) ⇒ Object
A
DELETE
request is used to delete a webhook subscription. -
#find(webhook_subscription_id) ⇒ OpenStruct
A
GET
request is used to retrieve the details of a webook subscription. -
#update(webhook_subscription_id, body) ⇒ OpenStruct
A
PUT
request is used to update a subscription.
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(webhook_subscription_id) ⇒ Object
A POST
request is used to activate a webhook subscription.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions/268a8629-55cd-4890-9013-936b9b5ea14c/activate' -i -X POST \
-H 'Authorization: Bearer <Access token>'
24 25 26 27 28 29 30 31 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 24 def activate(webhook_subscription_id) path = "/webhook-subscriptions/#{webhook_subscription_id}/activate" response, status = BeyondApi::Request.post(@session, path) handle_response(response, status, respond_with_true: true) end |
#all(params = {}) ⇒ OpenStruct
A GET
request is used to list all of the webhook subscriptions in a paged way.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions' -i -X GET \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
49 50 51 52 53 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 49 def all(params = {}) path = "/webhook-subscriptions" handle_all_request(path, :webhook_subscriptions, params) end |
#create(body) ⇒ OpenStruct
A POST
request is used to create a webhook subscription.
The scopes needed for the operation depend on the event types you register for. e.g. Order events require the scope orde:r
.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"callbackUri":"http://example.com/test",
"eventTypes": ["order.created", "product.created"]
}'
81 82 83 84 85 86 87 88 89 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 81 def create(body) path = "/webhook-subscriptions" response, status = BeyondApi::Request.post(@session, path, body) handle_response(response, status) end |
#deactivate(webhook_subscription_id) ⇒ Object
A POST
request is used to deactivate a webhook subscription.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions/a597cea4-b688-4164-8c56-b6568ea4d5aa/deactivate' -i -X POST \
-H 'Authorization: Bearer <Access token>'
104 105 106 107 108 109 110 111 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 104 def deactivate(webhook_subscription_id) path = "/webhook-subscriptions/#{webhook_subscription_id}/deactivate" response, status = BeyondApi::Request.post(@session, path) handle_response(response, status, respond_with_true: true) end |
#delete(webhook_subscription_id) ⇒ Object
A DELETE
request is used to delete a webhook subscription.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions/c6076a5a-a8ad-443f-b20b-8a1b268b069e' -i -X DELETE \
-H 'Authorization: Bearer <Access token>'
126 127 128 129 130 131 132 133 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 126 def delete(webhook_subscription_id) path = "/webhook-subscriptions/#{webhook_subscription_id}" response, status = BeyondApi::Request.delete(@session, path) handle_response(response, status, respond_with_true: true) end |
#find(webhook_subscription_id) ⇒ OpenStruct
A GET
request is used to retrieve the details of a webook subscription.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions/3d44ec71-768c-4927-9069-a96a5153e87c' -i -X GET \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
149 150 151 152 153 154 155 156 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 149 def find(webhook_subscription_id) path = "/webhook-subscriptions/#{webhook_subscription_id}" response, status = BeyondApi::Request.get(@session, path) handle_response(response, status) end |
#update(webhook_subscription_id, body) ⇒ OpenStruct
A PUT
request is used to update a subscription.
The scopes needed for the operation depend on the event types you register for. e.g. Order events require the scope orde:r
.
$ curl 'https://api-shop.beyondshop.cloud/api/webhook-subscriptions/6f3bc033-c2d1-4f44-80e3-1b668f6bd699' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"callbackUri":"http://example.com/test/updated",
"eventTypes": ["product.updated"]
}'
187 188 189 190 191 192 193 194 195 |
# File 'lib/beyond_api/resources/webhook_subscriptions.rb', line 187 def update(webhook_subscription_id, body) path = "/webhook-subscriptions/#{webhook_subscription_id}" response, status = BeyondApi::Request.put(@session, path, body) handle_response(response, status) end |