Sha256: e6d96b59edaf440dad7c4ebd2dcca08fbd4a334d7496c6ca495e58b4cb42e71e

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module EasyPost
  class Webhook < Resource
    def update(params={})
      # NOTE: This method is redefined here since the "url" method conflicts
      # with the objects field
      unless self.id
        raise 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 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
easypost-3.1.4 lib/easypost/webhook.rb
easypost-3.1.3 lib/easypost/webhook.rb