Class: EasyPost::Services::Webhook
- Defined in:
- lib/easypost/services/webhook.rb
Constant Summary collapse
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Retrieve a list of Webhooks.
-
#create(params = {}) ⇒ Object
Create a Webhook.
-
#delete(id) ⇒ Object
Delete a Webhook.
-
#retrieve(id) ⇒ Object
Retrieve a Webhook.
-
#update(id, params = {}) ⇒ Object
Update a Webhook.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#all(params = {}) ⇒ Object
Retrieve a list of Webhooks
22 23 24 25 26 |
# File 'lib/easypost/services/webhook.rb', line 22 def all(params = {}) filters = { 'key' => 'webhooks' } get_all_helper('webhooks', MODEL_CLASS, params, filters) end |
#create(params = {}) ⇒ Object
Create a Webhook.
7 8 9 10 11 12 |
# File 'lib/easypost/services/webhook.rb', line 7 def create(params = {}) wrapped_params = { webhook: params } response = @client.make_request(:post, 'webhooks', wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |
#delete(id) ⇒ Object
Delete a Webhook.
36 37 38 39 40 41 |
# File 'lib/easypost/services/webhook.rb', line 36 def delete(id) @client.make_request(:delete, "webhooks/#{id}") # Return true if succeeds, an error will be thrown if it fails true end |
#retrieve(id) ⇒ Object
Retrieve a Webhook
15 16 17 18 19 |
# File 'lib/easypost/services/webhook.rb', line 15 def retrieve(id) response = @client.make_request(:get, "webhooks/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |
#update(id, params = {}) ⇒ Object
Update a Webhook.
29 30 31 32 33 |
# File 'lib/easypost/services/webhook.rb', line 29 def update(id, params = {}) response = @client.make_request(:patch, "webhooks/#{id}", params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |