Class: ShipEngine::Domain::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/shipengine/domains/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initializeWebhooks

Returns a new instance of Webhooks.



8
9
10
# File 'lib/shipengine/domains/webhooks.rb', line 8

def initialize
  @client = ShipEngine::Client.new
end

Instance Method Details

#create_webhook(params: {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/shipengine/domains/webhooks.rb', line 21

def create_webhook(params: {})
  response = @client.post(
    path: ShipEngine::Constants::PATHS.v1.webhooks.root,
    options: params
  )

  Hashie::Mash.new(response.body)
end

#delete_webhook_by_id(webhook_id:, params: {}) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/shipengine/domains/webhooks.rb', line 48

def delete_webhook_by_id(webhook_id:, params: {})
  response = @client.delete(
    path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
    options: params
  )

  Hashie::Mash.new(response.body)
end

#list_webhooks(params: {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/shipengine/domains/webhooks.rb', line 12

def list_webhooks(params: {})
  response = @client.get(
    path: ShipEngine::Constants::PATHS.v1.webhooks.root,
    options: params
  )

  response.body.map { |webhook| Hashie::Mash.new(webhook) }
end

#update_webhook_by_id(webhook_id:, params: {}) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/shipengine/domains/webhooks.rb', line 39

def update_webhook_by_id(webhook_id:, params: {})
  response = @client.put(
    path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
    options: params
  )

  Hashie::Mash.new(response.body)
end

#webhook_by_id(webhook_id:, params: {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/shipengine/domains/webhooks.rb', line 30

def webhook_by_id(webhook_id:, params: {})
  response = @client.get(
    path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
    options: params
  )

  Hashie::Mash.new(response.body)
end