Class: Unit::Resource::WebhookResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Unit::Resource::WebhookResource
- Defined in:
- lib/unit/api_resources/webhook_resource.rb
Class Method Summary collapse
-
.create_webhook(request) ⇒ UnitResponse, UnitError
Create a webhook by calling Unit’s API.
-
.disable_webhook(webhook_id) ⇒ UnitResponse, UnitError
Disable a webhook by calling Unit’s API.
-
.enable_webhook(webhook_id) ⇒ UnitResponse, UnitError
Enable a webhook by calling Unit’s API.
-
.get_webhook(webhook_id) ⇒ UnitResponse, UnitError
Get a webhook by calling Unit’s API.
-
.list_webhooks(params = nil) ⇒ UnitResponse, UnitError
List webhooks by calling Unit’s API.
-
.update_webhook(request) ⇒ UnitResponse, UnitError
Update a webhook by calling Unit’s API.
Methods inherited from BaseResource
file_response_handler, response_handler
Class Method Details
.create_webhook(request) ⇒ UnitResponse, UnitError
Create a webhook by calling Unit’s API
16 17 18 19 20 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 16 def create_webhook(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/webhooks", body: payload, headers: headers) response_handler(response) end |
.disable_webhook(webhook_id) ⇒ UnitResponse, UnitError
Disable a webhook by calling Unit’s API
58 59 60 61 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 58 def disable_webhook(webhook_id) response = HttpHelper.post("#{api_url}/webhooks/#{webhook_id}/disable", headers: headers) response_handler(response) end |
.enable_webhook(webhook_id) ⇒ UnitResponse, UnitError
Enable a webhook by calling Unit’s API
50 51 52 53 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 50 def enable_webhook(webhook_id) response = HttpHelper.post("#{api_url}/webhooks/#{webhook_id}/enable", headers: headers) response_handler(response) end |
.get_webhook(webhook_id) ⇒ UnitResponse, UnitError
Get a webhook by calling Unit’s API
25 26 27 28 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 25 def get_webhook(webhook_id) response = HttpHelper.get("#{api_url}/webhooks/#{webhook_id}", headers: headers) response_handler(response) end |
.list_webhooks(params = nil) ⇒ UnitResponse, UnitError
List webhooks by calling Unit’s API
33 34 35 36 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 33 def list_webhooks(params = nil) response = HttpHelper.get("#{api_url}/webhooks", params: params.to_hash, headers: headers) response_handler(response) end |
.update_webhook(request) ⇒ UnitResponse, UnitError
Update a webhook by calling Unit’s API
41 42 43 44 45 |
# File 'lib/unit/api_resources/webhook_resource.rb', line 41 def update_webhook(request) payload = request.to_json_api response = HttpHelper.patch("#{api_url}/webhooks/#{request.webhook_id}", body: payload, headers: headers) response_handler(response) end |