Skip to content

Commit 1299956

Browse files
committed
test: custom_headers webhooks
1 parent d04163a commit 1299956

7 files changed

Lines changed: 57 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Next Release (minor)
44

55
- Adds Ruby 3.4 support
6-
- Fixes the update webhook function to wrap parameters in the request correctly
76
- Corrects the HTTP verb for updating a brand from `GET` to `PATCH`
87
- Removes the deprecated `create_list` tracker endpoint function as it is no longer available via API
98

examples

Submodule examples updated 170 files

lib/easypost/services/webhook.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def all(params = {})
2727

2828
# Update a Webhook.
2929
def update(id, params = {})
30-
wrapped_params = { webhook: params }
31-
response = @client.make_request(:patch, "webhooks/#{id}", wrapped_params)
30+
response = @client.make_request(:patch, "webhooks/#{id}", params)
3231

3332
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
3433
end

spec/cassettes/webhook/EasyPost_Services_Webhook_create_creates_a_webhook.yml

Lines changed: 16 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/cassettes/webhook/EasyPost_Services_Webhook_update_updates_a_webhook.yml

Lines changed: 23 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/support/fixture.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,19 @@ def self.event_bytes
129129
end
130130

131131
def self.webhook_hmac_signature
132-
read_fixture_data['webhook_hmac_signature']
132+
read_fixture_data['webhooks']['hmac_signature']
133133
end
134134

135135
def self.webhook_secret
136-
read_fixture_data['webhook_secret']
136+
read_fixture_data['webhooks']['secret']
137137
end
138138

139139
def self.webhook_url
140-
read_fixture_data['webhook_url']
140+
read_fixture_data['webhooks']['url']
141+
end
142+
143+
def self.webhook_custom_headers
144+
read_fixture_data['webhooks']['custom_headers']
141145
end
142146

143147
# The credit card details below are for a valid proxy card usable

spec/webhook_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
webhook = client.webhook.create(
1111
url: Fixture.webhook_url,
1212
webhook_secret: Fixture.webhook_secret,
13+
custom_headers: Fixture.webhook_custom_headers,
1314
)
1415

1516
expect(webhook).to be_an_instance_of(EasyPost::Models::Webhook)
1617
expect(webhook.id).to match('hook_')
1718
expect(webhook.url).to eq(Fixture.webhook_url)
19+
expect(webhook.custom_headers[0].name).to eq('test')
20+
expect(webhook.custom_headers[0].value).to eq('header')
1821

1922
# Remove the webhook once we have tested it so we don't pollute the account with test webhooks
2023
client.webhook.delete(webhook.id)
@@ -56,9 +59,14 @@
5659
url: Fixture.webhook_url,
5760
)
5861

59-
updated_webhook = client.webhook.update(webhook.id, { webhook_secret: Fixture.webhook_secret })
62+
updated_webhook = client.webhook.update(webhook.id, {
63+
webhook_secret: Fixture.webhook_secret,
64+
custom_headers: Fixture.webhook_custom_headers,
65+
})
6066

6167
expect(updated_webhook).to be_an_instance_of(EasyPost::Models::Webhook)
68+
expect(updated_webhook.custom_headers[0].name).to eq('test')
69+
expect(updated_webhook.custom_headers[0].value).to eq('header')
6270

6371
client.webhook.delete(webhook.id) # Remove the webhook once we have tested it so we don't pollute the account with test webhooks
6472
end

0 commit comments

Comments
 (0)