Sha256: 78d46fb00d214bc04e28553ef43af5d5ae029e0d5b393b62221a85423cce5247

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

class EasyPost::Services::Webhook < EasyPost::Services::Service
  MODEL_CLASS = EasyPost::Models::Webhook

  # Create a Webhook.
  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

  # Retrieve a Webhook
  def retrieve(id)
    response = @client.make_request(:get, "webhooks/#{id}")

    EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
  end

  # Retrieve a list of Webhooks
  def all(params = {})
    filters = { 'key' => 'webhooks' }

    get_all_helper('webhooks', MODEL_CLASS, params, filters)
  end

  # Update a Webhook.
  def update(id, params = {})
    response = @client.make_request(:patch, "webhooks/#{id}", params)

    EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
  end

  # Delete a Webhook.
  def delete(id)
    @client.make_request(:delete, "webhooks/#{id}")

    # Return true if succeeds, an error will be thrown if it fails
    true
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easypost-6.4.1 lib/easypost/services/webhook.rb
easypost-6.4.0 lib/easypost/services/webhook.rb
easypost-6.3.0 lib/easypost/services/webhook.rb
easypost-6.2.0 lib/easypost/services/webhook.rb
easypost-6.1.1 lib/easypost/services/webhook.rb
easypost-6.1.0 lib/easypost/services/webhook.rb
easypost-6.0.0 lib/easypost/services/webhook.rb