Class: Myparcel::API::WebhookSubscriptions
- Inherits:
-
Base
- Object
- Base
- Myparcel::API::WebhookSubscriptions
show all
- Defined in:
- lib/myparcel/api/webhook_subscriptions.rb
Overview
Class for getting delivery options
Instance Attribute Summary
Attributes inherited from Base
#authentication
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#create(options = {}) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/myparcel/api/webhook_subscriptions.rb', line 14
def create(options = {})
subscriptions = options.fetch(:subscriptions, [])
options[:body] = JSON.generate(data: { webhook_subscriptions: subscriptions })
options[:headers] ||= {}
options[:headers]['Content-Type'] = 'application/json; charset=utf-8'
response = request :post, path, options
response['data']['ids']
end
|
#find(options = {}) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/myparcel/api/webhook_subscriptions.rb', line 5
def find(options = {})
subscription_ids = options.fetch(:subscription_ids, [])
raise ArgumentError, 'options[:subscription_ids] cannot be empty' if subscription_ids.empty?
subscription_ids = subscription_ids.join(';')
full_path = [path, subscription_ids].join('/')
response = request :get, full_path
response['data']['webhook_subscriptions']
end
|
#path ⇒ Object
23
24
25
|
# File 'lib/myparcel/api/webhook_subscriptions.rb', line 23
def path
'webhook_subscriptions'
end
|