Skip to content

Commit ac33e50

Browse files
committed
fix: wrap params for update webhook function
1 parent 36cfe42 commit ac33e50

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Fixes the wrapping of params on the request for the update webhook function
6+
37
## v7.5.5 (2025-02-06)
48

59
- Fixes type importing and constructor creation (closes #446)

src/services/webhook_service.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ export default (easypostClient) =>
3232
*/
3333
static async update(id, params) {
3434
const url = `webhooks/${id}`;
35+
const wrappedParams = {
36+
webhook: params,
37+
};
38+
3539
try {
36-
const response = await easypostClient._patch(url, params);
40+
const response = await easypostClient._patch(url, wrappedParams);
3741

38-
return this._convertToEasyPostObject(response.body, params);
42+
return this._convertToEasyPostObject(response.body, wrappedParams);
3943
} catch (e) {
4044
return Promise.reject(e);
4145
}

test/services/webhook.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('Webhook Service', function () {
2525
it('creates a webhook', async function () {
2626
const webhook = await client.Webhook.create({
2727
url: Fixture.webhookUrl(),
28+
webhook_secret: Fixture.webhookSecret(),
2829
});
2930

3031
expect(webhook).to.be.an.instanceOf(Webhook);
@@ -67,7 +68,9 @@ describe('Webhook Service', function () {
6768
url: Fixture.webhookUrl(),
6869
});
6970

70-
const updatedWebhook = await client.Webhook.update(webhook.id);
71+
const updatedWebhook = await client.Webhook.update(webhook.id, {
72+
webhook_secret: Fixture.webhookSecret(),
73+
});
7174

7275
expect(updatedWebhook).to.be.an.instanceOf(Webhook);
7376

0 commit comments

Comments
 (0)