Sha256: 4c256d081d5b24df24fcf88a5d291a85547f9ec74c7d6f36f817249974d3e9ed

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

Contents

class EasyPost::Webhook < EasyPost::Resource
  def update(params={})
    # NOTE: This method is redefined here since the "url" method conflicts
    # with the objects field
    unless self.id
      raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{self.id.inspect}")
    end
    instance_url = "#{self.class.url}/#{CGI.escape(id)}"

    response = EasyPost.make_request(:put, instance_url, @api_key, params)
    self.refresh_from(response, api_key, true)

    return self
  end

  def delete
    # NOTE: This method is redefined here since the "url" method conflicts
    # with the objects field
    unless self.id
      raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{self.id.inspect}")
    end
    instance_url = "#{self.class.url}/#{CGI.escape(id)}"

    response = EasyPost.make_request(:delete, instance_url, @api_key)
    refresh_from(response, api_key)

    return self
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
easypost-3.5.1 lib/easypost/webhook.rb
easypost-3.5.0 lib/easypost/webhook.rb
easypost-3.4.0 lib/easypost/webhook.rb
easypost-3.3.0 lib/easypost/webhook.rb
easypost-3.2.0 lib/easypost/webhook.rb
easypost-3.1.5 lib/easypost/webhook.rb