Sha256: ed28cba3ab6fa3239949c75934d7dc79ff0800db81ee076662bfe01e78ff0a81

Contents?: true

Size: 929 Bytes

Versions: 9

Compression:

Stored size: 929 Bytes

Contents

module EasyPost
  class Webhook < Resource
    def update(params={})
      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, api_key = EasyPost.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, api_key = EasyPost.request(:delete, instance_url, @api_key)
      refresh_from(response, api_key)

      return self
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
easypost-3.0.1 lib/easypost/webhook.rb
easypost-3.0.0 lib/easypost/webhook.rb
easypost-2.7.3 lib/easypost/webhook.rb
easypost-2.7.2 lib/easypost/webhook.rb
easypost-2.7.1 lib/easypost/webhook.rb
easypost-2.7.0 lib/easypost/webhook.rb
easypost-2.6.2 lib/easypost/webhook.rb
easypost-2.6.1 lib/easypost/webhook.rb
easypost-2.6.0 lib/easypost/webhook.rb