From 130f0ad58df383cd260cfa76281cf40e7b5143c2 Mon Sep 17 00:00:00 2001 From: k4th Date: Fri, 4 Oct 2024 07:24:31 +0200 Subject: [PATCH] Add webhooks endpoints --- .../services/webhook/subscription.rb | 79 +++++- .../services/webhook/subscription_spec.rb | 40 +++ .../activates_a_webhook_subscription.yml | 254 +++++++++++++++++ .../deactivates_a_webhook_subscription.yml | 254 +++++++++++++++++ .../deletes_a_webhook_failure.yml | 250 +++++++++++++++++ ...d_deliveries_of_a_webhook_subscription.yml | 256 ++++++++++++++++++ .../retries_a_failed_webhook_delivery.yml | 238 ++++++++++++++++ 7 files changed, 1370 insertions(+), 1 deletion(-) create mode 100644 spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_activate/activates_a_webhook_subscription.yml create mode 100644 spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_deactivate/deactivates_a_webhook_subscription.yml create mode 100644 spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_delete_failure/deletes_a_webhook_failure.yml create mode 100644 spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_failures/lists_all_failed_deliveries_of_a_webhook_subscription.yml create mode 100644 spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_retry/retries_a_failed_webhook_delivery.yml diff --git a/lib/beyond_api/services/webhook/subscription.rb b/lib/beyond_api/services/webhook/subscription.rb index 794584b..1b8016d 100644 --- a/lib/beyond_api/services/webhook/subscription.rb +++ b/lib/beyond_api/services/webhook/subscription.rb @@ -63,7 +63,7 @@ def delete_all # @example # @client.delete('84ce4b3a-9a10-46d0-afcd-a71bcd0c0e9a') def delete(id) - super("webhook-subscriptions/#{id}") # Concerns::Connection delete method + super("webhook-subscriptions/#{id}") end # Retrieve the details of a webhook subscription. @@ -79,6 +79,83 @@ def delete(id) def find(id) get("webhook-subscriptions/#{id}") end + + # Activate a webhook subscription. You might want to use this request for a deactivated webhook. + # + # @see https://developer.epages.com/beyond-docs/#activate_webhook_subscription + # + # @param id [String] the webhook subscription UUID + # + # @return [Hash] + # + # @example + # @client.activate('1d61c1b4-49aa-4827-bd04-b1c4374f3499') + def activate(id) + post("webhook-subscriptions/#{id}/activate") + end + + # Deactivate a webhook subscription. You might want to use this request for a currently active webhook. + # + # @see https://developer.epages.com/beyond-docs/#deactivate_webhook_subscription + # + # @param id [String] the webhook subscription UUID + # + # @return [Hash] + # + # @example + # @client.deactivate('8517ab39-db0e-417a-87ed-f96e437c03e4') + def deactivate(id) + post("webhook-subscriptions/#{id}/deactivate") + end + + # List all failed deliveries of a webhook subscription in a paged way. + # + # @see https://developer.epages.com/beyond-docs/#list_failed_webhook_deliveries + # + # @param id [String] the webhook subscription UUID + # @option params [Boolean] :paginated + # @option params [Integer] :size the page size + # @option params [Integer] :page the page number + # + # @return [Hash] + # + # @example + # @client.failures('a3dd55a4-dbc3-4f20-8a5e-d0fe4ba59afd', { size: 100, page: 0 }) + def failures(id, params = {}) + fetch_all_pages("webhook-subscriptions/#{id}/failures", params) + end + + # Retry a failed webhook delivery. + # + # @see https://developer.epages.com/beyond-docs/#retry_failed_webhook_delivery + # + # @param webhook_id [String] the webhook subscription UUID + # @param failure_id [String] the failure UUID + # + # @return [Hash] + # + # @example + # @client.retry('d9828fba-3922-4750-a70c-174daeeb37e4', + # 'b21146e0-16b9-468f-806b-a23c8e04a7fc') + def retry(webhook_id, failure_id) + post("webhook-subscriptions/#{webhook_id}/failures/#{failure_id}/retry") + end + + # Delete a webhook failure. + # + # @see https://developer.epages.com/beyond-docs/#delete_webhook_delivery_failure + # + # @param webhook_id [String] the webhook subscription UUID + # @param failure_id [String] the failure UUID + # + # @return [Hash] an empty hash + # + # @example + # @client.delete_failure('cbcebfc4-9dee-4344-83b2-8c25b2287a60', + # 'f090610b-19da-4e40-a986-3c9562fefeab') + def delete_failure(webhook_id, failure_id) + delete("webhook-subscriptions/#{webhook_id}/failures/#{failure_id}") + end end end end diff --git a/spec/beyond_api/services/webhook/subscription_spec.rb b/spec/beyond_api/services/webhook/subscription_spec.rb index 3a045e3..91dcab8 100644 --- a/spec/beyond_api/services/webhook/subscription_spec.rb +++ b/spec/beyond_api/services/webhook/subscription_spec.rb @@ -40,6 +40,46 @@ end end + describe '.deactivate' do + it 'deactivates a webhook subscription' do + response = client.deactivate(@webhook_subscription[:id]) + expect(response).not_to be nil + expect(response[:active]).to eq(false) + end + end + + describe '.activate' do + it 'activates a webhook subscription' do + response = client.activate(@webhook_subscription[:id]) + expect(response).not_to be nil + expect(response[:active]).to eq(true) + end + end + + describe '.failures' do + it 'lists all failed deliveries of a webhook subscription' do + response = client.failures(@webhook_subscription[:id], { size: 100, page: 0 }) + expect(response).not_to be nil + expect(response.dig(:embedded, :failures)).to be_kind_of(Array) + end + end + + describe '.retry' do + it 'retries a failed webhook delivery' do + failure_id = '987e6543-e21b-45d3-b123-654321098765' + # Non existing failure ID will raise an error + expect { client.retry(@webhook_subscription[:id], failure_id) }.to raise_error(BeyondApi::Error) + end + end + + describe '.delete_failure' do + it 'deletes a webhook failure' do + failure_id = '123e4567-e89b-12d3-a456-426614174000' + # Non existing failure ID will raise an error + expect { client.delete_failure(@webhook_subscription[:id], failure_id) }.to raise_error(BeyondApi::Error) + end + end + after(:each) do client.delete(@webhook_subscription[:id]) rescue BeyondApi::Error # rubocop:disable Lint/SuppressedException diff --git a/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_activate/activates_a_webhook_subscription.yml b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_activate/activates_a_webhook_subscription.yml new file mode 100644 index 0000000..93a6346 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_activate/activates_a_webhook_subscription.yml @@ -0,0 +1,254 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.111' + X-B3-Traceid: + - e3d66d2aa31912e7b0b504fcb4cf21c1 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1727938728, + "jti" : "vitZ488XJwzufv9LHJgiyHRiAzM=" + } + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions + body: + encoding: UTF-8 + string: '{"callbackUri":"http://example.com/test","eventTypes":["order.created","product.created"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.069' + X-B3-Traceid: + - 2d1a762ad3d611a96e94a2123847b6f8 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "735d9365-7795-496e-bfb7-7156433dd525", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525/activate + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.027' + X-B3-Traceid: + - 904d76b8aba432e0ff0c17a0624fbcf5 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "735d9365-7795-496e-bfb7-7156433dd525", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/735d9365-7795-496e-bfb7-7156433dd525 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.043' + X-B3-Traceid: + - 21e2dda7d41c1dd2bd6f82cc7279cfe9 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_deactivate/deactivates_a_webhook_subscription.yml b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_deactivate/deactivates_a_webhook_subscription.yml new file mode 100644 index 0000000..4c5a8c4 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_deactivate/deactivates_a_webhook_subscription.yml @@ -0,0 +1,254 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.107' + X-B3-Traceid: + - 93421d636b7e092cc7a76bedb577e104 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1727938728, + "jti" : "GRGUemmcTlUrNdm6vnUA2fS2B3E=" + } + recorded_at: Thu, 03 Oct 2024 06:58:47 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions + body: + encoding: UTF-8 + string: '{"callbackUri":"http://example.com/test","eventTypes":["order.created","product.created"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.055' + X-B3-Traceid: + - aa578b3abd60b6584917ef2ba3132052 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "5a8bba3b-5e7c-4f02-8876-d777af2d9659", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659/deactivate + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.044' + X-B3-Traceid: + - 376b1c8a5c9d1069eaca08a061003094 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : false, + "_id" : "5a8bba3b-5e7c-4f02-8876-d777af2d9659", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659" + }, + "activate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659/activate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/5a8bba3b-5e7c-4f02-8876-d777af2d9659 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 03 Oct 2024 06:58:48 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.039' + X-B3-Traceid: + - f1d312c7dae8eb40f6420031c734634e + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:48 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_delete_failure/deletes_a_webhook_failure.yml b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_delete_failure/deletes_a_webhook_failure.yml new file mode 100644 index 0000000..84fa6e4 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_delete_failure/deletes_a_webhook_failure.yml @@ -0,0 +1,250 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:50 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.075' + X-B3-Traceid: + - 326eaf6eb08d2a384ab8f6f8401d9f0d + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1727938730, + "jti" : "hd/XTyQyv33SG4JeSrywaAmJico=" + } + recorded_at: Thu, 03 Oct 2024 06:58:50 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions + body: + encoding: UTF-8 + string: '{"callbackUri":"http://example.com/test","eventTypes":["order.created","product.created"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 03 Oct 2024 06:58:50 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.052' + X-B3-Traceid: + - e063e94d034a0a2135b479c9f036c291 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "38d82a29-4ad6-49fa-83cd-70350517a472", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:50 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472/failures/123e4567-e89b-12d3-a456-426614174000 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 500 + message: Server Error + headers: + Date: + - Thu, 03 Oct 2024 06:58:50 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Vary: + - Access-Control-Request-Headers + - Access-Control-Request-Method + - Origin + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.018' + X-B3-Traceid: + - 259b55a05b6bfd44abd906464d51489a + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "errorId" : "internal-error", + "details" : { }, + "message" : "No static resource webhook-subscriptions/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472/failures/123e4567-e89b-12d3-a456-426614174000.", + "traceId" : "259b55a05b6bfd44abd906464d51489a" + } + recorded_at: Thu, 03 Oct 2024 06:58:50 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/38d82a29-4ad6-49fa-83cd-70350517a472 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 03 Oct 2024 06:58:50 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.036' + X-B3-Traceid: + - 70c15805665504105f8478af5129ccf6 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:50 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_failures/lists_all_failed_deliveries_of_a_webhook_subscription.yml b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_failures/lists_all_failed_deliveries_of_a_webhook_subscription.yml new file mode 100644 index 0000000..116dda6 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_failures/lists_all_failed_deliveries_of_a_webhook_subscription.yml @@ -0,0 +1,256 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.089' + X-B3-Traceid: + - 3dda588eafcbb357100ef4ef04af1bf8 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1727938729, + "jti" : "T/v4oieL2/5IZv6TqGvqp7aiXSM=" + } + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions + body: + encoding: UTF-8 + string: '{"callbackUri":"http://example.com/test","eventTypes":["order.created","product.created"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.034' + X-B3-Traceid: + - edff24a91abd9b6bb9d5de0f6e610385 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "57c659f9-3706-439f-8388-3b6fbb026c9b", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: get + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b/failures?page=0&size=100 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.022' + X-B3-Traceid: + - 8495ad4960eb203745452af09a0a4335 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_embedded" : { + "failures" : [ ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b/failures?page=0&size=100&sort=createdAt,desc" + } + }, + "page" : { + "size" : 100, + "totalElements" : 0, + "totalPages" : 0, + "number" : 0 + } + } + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/57c659f9-3706-439f-8388-3b6fbb026c9b + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.028' + X-B3-Traceid: + - 7cbaa1ac44a6dc8120b1c5f6bfc0ce13 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_retry/retries_a_failed_webhook_delivery.yml b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_retry/retries_a_failed_webhook_delivery.yml new file mode 100644 index 0000000..2a8eea1 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Webhook_Subscription/with_webhook_subscription/_retry/retries_a_failed_webhook_delivery.yml @@ -0,0 +1,238 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.081' + X-B3-Traceid: + - 2c6d053ea44a5654591358694fc35f81 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1727938729, + "jti" : "IsJ4kGGsEUTDD7kri+ON7+SLEe8=" + } + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions + body: + encoding: UTF-8 + string: '{"callbackUri":"http://example.com/test","eventTypes":["order.created","product.created"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/6ea2623c-4ef2-40fb-8f05-9683ba8d5e71 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.043' + X-B3-Traceid: + - 4a6df15f0cc1641ee0dea4b4e52419f8 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "callbackUri" : "http://example.com/test", + "eventTypes" : [ "product.created", "order.created" ], + "active" : true, + "_id" : "6ea2623c-4ef2-40fb-8f05-9683ba8d5e71", + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/6ea2623c-4ef2-40fb-8f05-9683ba8d5e71" + }, + "deactivate" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/6ea2623c-4ef2-40fb-8f05-9683ba8d5e71/deactivate" + } + } + } + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/6ea2623c-4ef2-40fb-8f05-9683ba8d5e71/failures/987e6543-e21b-45d3-b123-654321098765/retry + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Thu, 03 Oct 2024 06:58:49 GMT + Content-Length: + - '0' + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.019' + X-B3-Traceid: + - fe923707345224b9199ee1185b7ff8a4 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:49 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/webhook-subscriptions/6ea2623c-4ef2-40fb-8f05-9683ba8d5e71 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 03 Oct 2024 06:58:50 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - '0' + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.031' + X-B3-Traceid: + - 31be1c834ab966a4aa654059e5441133 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 03 Oct 2024 06:58:50 GMT +recorded_with: VCR 6.2.0