Class: DuffelAPI::Services::WebhooksService
Defined Under Namespace
Classes: PingResult
Instance Method Summary
collapse
Methods inherited from BaseService
#initialize, #make_request
Instance Method Details
#create(options = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/duffel_api/services/webhooks_service.rb', line 20
def create(options = {})
path = "/air/webhooks"
params = options.delete(:params) || {}
options[:params] = {}
options[:params]["data"] = params
begin
response = make_request(:post, path, options)
response.tap(&:raw_body)
end
return if response.raw_body.nil?
Resources::Webhook.new(unenvelope_body(response.parsed_body), response)
end
|
#ping(id, options = {}) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/duffel_api/services/webhooks_service.rb', line 58
def ping(id, options = {})
path = substitute_url_pattern("/air/webhooks/:id/actions/ping", "id" => id)
params = options.delete(:params) || {}
options[:params] = {}
options[:params]["data"] = params
begin
response = make_request(:post, path, options)
response.tap(&:raw_body)
end
rescue DuffelAPI::Errors::Error => e
if e.api_response.status_code == 204
PingResult.new(e.api_response)
else
raise e
end
end
|
#update(id, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/duffel_api/services/webhooks_service.rb', line 39
def update(id, options = {})
path = substitute_url_pattern("/air/webhooks/:id", "id" => id)
params = options.delete(:params) || {}
options[:params] = {}
options[:params]["data"] = params
begin
response = make_request(:patch, path, options)
response.tap(&:raw_body)
end
return if response.raw_body.nil?
Resources::Webhook.new(unenvelope_body(response.parsed_body), response)
end
|