Class: Modulr::API::NotificationsService
- Inherits:
-
Service
- Object
- Service
- Modulr::API::NotificationsService
show all
- Defined in:
- lib/modulr/api/notifications_service.rb
Instance Attribute Summary
Attributes inherited from Service
#client
Instance Method Summary
collapse
Methods inherited from Service
#format_datetime, #initialize
Instance Method Details
#create(type:, channel:, destinations:, config:, **opts) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/modulr/api/notifications_service.rb', line 20
def create(type:, channel:, destinations:, config:, **opts)
payload = {
type: type,
channel: channel,
destinations: destinations,
config: config,
}
response = client.post("#{base_notification_url(opts)}/notifications", payload)
attributes = response.body
Resources::Notifications::Notification.new(response, attributes)
end
|
#find(id:, **opts) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/modulr/api/notifications_service.rb', line 6
def find(id:, **opts)
response = client.get("#{base_notification_url(opts)}/notifications/#{id}")
attributes = response.body
Resources::Notifications::Notification.new(response, attributes)
end
|
#list(**opts) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/modulr/api/notifications_service.rb', line 13
def list(**opts)
response = client.get("#{base_notification_url(opts)}/notifications")
attributes_collection = response.body
Resources::Notifications::Collection.new(response, attributes_collection)
end
|
#update(id:, status:, destinations:, config:, **opts) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/modulr/api/notifications_service.rb', line 33
def update(id:, status:, destinations:, config:, **opts)
payload = {
status: status,
destinations: destinations,
config: config,
}
response = client.put("#{base_notification_url(opts)}/notifications/#{id}", payload)
attributes = response.body
Resources::Notifications::Notification.new(response, attributes)
end
|