class EasyPost::Services::Webhook

Constants

MODEL_CLASS

Each Webhook contains the url which EasyPost will notify whenever an object in our system updates. Several types of objects are processed asynchronously in the EasyPost system, so whenever an object updates, an Event is sent via HTTP POST to each configured webhook URL.

Public Instance Methods

all(params = {}) click to toggle source

Retrieve a list of Webhooks

# 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 = {}) click to toggle source

Create a Webhook.

# 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) click to toggle source

Delete a Webhook.

# 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) click to toggle source

Retrieve a Webhook

# 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 = {}) click to toggle source

Update a Webhook.

# 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