Class: EasyPost::Services::Webhook

Inherits:
Service
  • Object
show all
Defined in:
lib/easypost/services/webhook.rb

Constant Summary collapse

MODEL_CLASS =
EasyPost::Models::Webhook

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from EasyPost::Services::Service

Instance Method Details

#all(params = {}) ⇒ Object

Retrieve a list of Webhooks



18
19
20
# File 'lib/easypost/services/webhook.rb', line 18

def all(params = {})
  @client.make_request(:get, 'webhooks', MODEL_CLASS, params)
end

#create(params = {}) ⇒ Object

Create a Webhook.



7
8
9
10
# File 'lib/easypost/services/webhook.rb', line 7

def create(params = {})
  wrapped_params = { webhook: params }
  @client.make_request(:post, 'webhooks', MODEL_CLASS, wrapped_params)
end

#delete(id) ⇒ Object

Delete a Webhook.



28
29
30
31
32
33
# File 'lib/easypost/services/webhook.rb', line 28

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

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

#retrieve(id) ⇒ Object

Retrieve a Webhook



13
14
15
# File 'lib/easypost/services/webhook.rb', line 13

def retrieve(id)
  @client.make_request(:get, "webhooks/#{id}", MODEL_CLASS)
end

#update(id, params = {}) ⇒ Object

Update a Webhook.



23
24
25
# File 'lib/easypost/services/webhook.rb', line 23

def update(id, params = {})
  @client.make_request(:patch, "webhooks/#{id}", MODEL_CLASS, params)
end