Skip to content

Commit 68cc9a5

Browse files
committed
feat(webhooks): add list method to get all webhooks for a form
1 parent 237df8c commit 68cc9a5

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/webhooks.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class Webhooks {
2323
})
2424
}
2525

26+
list ({ uid } = {}) {
27+
return this._http.request({
28+
method: 'get',
29+
url: `/forms/${uid}/webhooks`
30+
})
31+
}
32+
2633
update (args) {
2734
return createOrUpdateWebhook(this._http, args)
2835
}

tests/unit/webhooks.test.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ const http = clientConstructor({
1313
})
1414
const webhooksRequest = webhooks(http)
1515

16-
test('List webhooks has the correct path and method', () => {
17-
webhooksRequest.get({ uid: 2, tag: 'test' })
18-
expect(fetch.mock.calls[0][1].method).toBe('get')
19-
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms/2/webhooks/test`)
20-
})
21-
2216
test('Create a new webhooks has the correct path, method and url', () => {
2317
webhooksRequest.create({
2418
uid: 2,
@@ -37,6 +31,18 @@ test('Create a new webhooks requires a url', () => {
3731
expect(() => webhooksRequest.create({ uid: 2, tag: 'test' })).toThrow()
3832
})
3933

34+
test('`get()` webhooks has the correct path and method', () => {
35+
webhooksRequest.get({ uid: 2, tag: 'test' })
36+
expect(fetch.mock.calls[0][1].method).toBe('get')
37+
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms/2/webhooks/test`)
38+
})
39+
40+
test('`list()` webhooks has the correct path and method', () => {
41+
webhooksRequest.list({ uid: 2 })
42+
expect(fetch.mock.calls[0][1].method).toBe('get')
43+
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms/2/webhooks`)
44+
})
45+
4046
test('update a new webhooks sends the correct payload', () => {
4147
webhooksRequest.update({
4248
uid: 2,

0 commit comments

Comments
 (0)