Class: EasyPost::Webhook
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Webhook
- Defined in:
- lib/easypost/webhook.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Instance Method Summary collapse
-
#delete ⇒ Object
Delete a Webhook.
-
#update(params = {}) ⇒ Object
Update a Webhook.
Methods inherited from Resource
all, class_name, create, each, #refresh, retrieve, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #deconstruct_keys, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Instance Method Details
#delete ⇒ Object
Delete a Webhook.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/easypost/webhook.rb', line 22 def delete # NOTE: This method is redefined here since the "url" method conflicts with the objects field unless id raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{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) self end |
#update(params = {}) ⇒ Object
Update a Webhook.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/easypost/webhook.rb', line 7 def update(params = {}) # NOTE: This method is redefined here since the "url" method conflicts with the objects field unless id raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}") end instance_url = "#{self.class.url}/#{CGI.escape(id)}" response = EasyPost.make_request(:put, instance_url, @api_key, params) refresh_from(response, api_key) self end |