Class: Notifications::Client
- Inherits:
-
Object
- Object
- Notifications::Client
show all
- Extended by:
- Forwardable
- Defined in:
- lib/notifications/client.rb,
lib/notifications/client/speaker.rb,
lib/notifications/client/version.rb,
lib/notifications/client/notification.rb,
lib/notifications/client/received_text.rb,
lib/notifications/client/request_error.rb,
lib/notifications/client/template_preview.rb,
lib/notifications/client/response_template.rb,
lib/notifications/client/template_collection.rb,
lib/notifications/client/response_notification.rb,
lib/notifications/client/notifications_collection.rb,
lib/notifications/client/received_text_collection.rb
Defined Under Namespace
Classes: Notification, NotificationsCollection, ReceivedText, ReceivedTextCollection, RequestError, ResponseNotification, Speaker, Template, TemplateCollection, TemplatePreview
Constant Summary
collapse
- PRODUCTION_BASE_URL =
"https://api.notifications.service.gov.uk".freeze
- VERSION =
"2.5.1".freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Client
Returns a new instance of Client.
24
25
26
|
# File 'lib/notifications/client.rb', line 24
def initialize(*args)
@speaker = Speaker.new(*args)
end
|
Instance Attribute Details
#speaker ⇒ Object
Returns the value of attribute speaker.
15
16
17
|
# File 'lib/notifications/client.rb', line 15
def speaker
@speaker
end
|
Instance Method Details
#generate_template_preview(id, options = {}) ⇒ TemplatePreview
120
121
122
123
124
125
|
# File 'lib/notifications/client.rb', line 120
def generate_template_preview(id, options = {})
path = "/v2/template/" << id << "/preview"
TemplatePreview.new(
speaker.post_with_url(path, options)
)
end
|
109
110
111
112
113
114
|
# File 'lib/notifications/client.rb', line 109
def get_all_templates(options = {})
path = "/v2/templates"
TemplateCollection.new(
speaker.get_with_url(path, options)
)
end
|
59
60
61
62
63
|
# File 'lib/notifications/client.rb', line 59
def get_notification(id)
Notification.new(
speaker.get(id)
)
end
|
78
79
80
81
82
|
# File 'lib/notifications/client.rb', line 78
def get_notifications(options = {})
NotificationsCollection.new(
speaker.get(nil, options)
)
end
|
131
132
133
134
135
136
|
# File 'lib/notifications/client.rb', line 131
def get_received_texts(options = {})
path = "/v2/received-text-messages"
ReceivedTextCollection.new(
speaker.get_with_url(path, options)
)
end
|
#get_template_by_id(id, options = {}) ⇒ Template
87
88
89
90
91
92
|
# File 'lib/notifications/client.rb', line 87
def get_template_by_id(id, options = {})
path = "/v2/template/" << id
Template.new(
speaker.get_with_url(path, options)
)
end
|
#get_template_version(id, version, options = {}) ⇒ Template
98
99
100
101
102
103
|
# File 'lib/notifications/client.rb', line 98
def get_template_version(id, version, options = {})
path = "/v2/template/" << id << "/version/" << version.to_s
Template.new(
speaker.get_with_url(path, options)
)
end
|
@see Notifications::Client::Speaker#post
31
32
33
34
35
|
# File 'lib/notifications/client.rb', line 31
def send_email(args)
ResponseNotification.new(
speaker.post("email", args)
)
end
|
49
50
51
52
53
|
# File 'lib/notifications/client.rb', line 49
def send_letter(args)
ResponseNotification.new(
speaker.post("letter", args)
)
end
|
40
41
42
43
44
|
# File 'lib/notifications/client.rb', line 40
def send_sms(args)
ResponseNotification.new(
speaker.post("sms", args)
)
end
|