Skip to content

Commit efb6c64

Browse files
authored
Update test_webhooks_controller.rb
1 parent 919b2ff commit efb6c64

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

test/controllers/test_webhooks_controller.rb

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,35 @@ def self.startup
77
self.controller = @@api_client.webhooks
88
end
99

10-
# Delete a webhook that was previously created for the connected account.
11-
#A webhook can be cancelled by appending the UUID of the webhook to the endpoint and submitting a DELETE request to the /webhooks/messages endpoint.
12-
#*Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.*
13-
def test_delete_webhook_1()
14-
# Parameters for the API call
15-
webhook_id = 'a7f11bb0-f299-4861-a5ca-9b29d04bc5ad'
10+
def test_create_webhook_1()
11+
body = CreateWebhookRequest.new("http://webhook.com",
12+
"POST",
13+
"JSON",
14+
nil,
15+
["ENROUTE_DR"],
16+
"{\"id\":\"$mtId\",\"status\":\"$statusCode\"}"
17+
)
1618

1719
# Perform the API call through the SDK function
18-
self.class.controller.delete_webhook(webhook_id)
20+
result = self.class.controller.create_webhook(body)
1921

20-
# Test response code
21-
assert_equal(@response_catcher.response.status_code, 404)
22+
assert_equal(@response_catcher.response.status_code, 201)
2223
end
2324

24-
# Update a webhook. You can update individual attributes or all of them by submitting a PATCH request to the /webhooks/messages endpoint (the same endpoint used above to delete a webhook)
25-
#A successful request to the retrieve webhook endpoint will return a response body as follows:
26-
#```
27-
#{
28-
# "url": "https://webhook.com",
29-
# "method": "POST",
30-
# "id": "04442623-0961-464e-9cbc-ec50804e0413",
31-
# "encoding": "JSON",
32-
# "events": [
33-
# "RECEIVED_SMS"
34-
# ],
35-
# "headers": {},
36-
# "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}"
37-
#}
38-
#```
25+
26+
# Delete a webhook that was previously created for the connected account.
27+
#A webhook can be cancelled by appending the UUID of the webhook to the endpoint and submitting a DELETE request to the /webhooks/messages endpoint.
3928
#*Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.*
40-
def test_update_webhook_1()
41-
# Parameters for the API call
42-
webhook_id = 'a7f11bb0-f299-4861-a5ca-9b29d04bc5ad'
43-
body = UpdateWebhookRequest.from_hash(JSON.parse(
44-
'{"url":"https://myurl.com","method":"POST","encoding":"FORM_ENCODED","event'\
45-
's":["ENROUTE_DR"],"template":"{\\"id\\":\\"$mtId\\", \\"status\\":\\"$statu'\
46-
'sCode\\"}"}'
47-
))
29+
def test_delete_webhook_1()
30+
# Retrieve the id of the last webhook created
31+
result = self.class.controller.retrieve_webhook
32+
webhook_id = result['pageData'][0]['id']
4833

4934
# Perform the API call through the SDK function
50-
result = self.class.controller.update_webhook(webhook_id, body)
35+
self.class.controller.delete_webhook(webhook_id)
5136

5237
# Test response code
53-
assert_equal(@response_catcher.response.status_code, 404)
38+
assert_equal(@response_catcher.response.status_code, 204)
5439
end
5540

5641
end

0 commit comments

Comments
 (0)