cpaas-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -0
- data/LICENSE.md +1 -0
- data/README.md +25 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cpaas-sdk.gemspec +32 -0
- data/docs/Cpaas.html +446 -0
- data/docs/Cpaas/Conversation.html +1742 -0
- data/docs/Cpaas/Notification.html +301 -0
- data/docs/Cpaas/TwoFactor.html +908 -0
- data/docs/_index.html +146 -0
- data/docs/_index.md +21 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +102 -0
- data/docs/file._index.html +94 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +94 -0
- data/docs/js/app.js +303 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +251 -0
- data/docs/mv_index.html +102 -0
- data/docs/top-level-namespace.html +663 -0
- data/examples/2fa/.env.example +6 -0
- data/examples/2fa/.gitignore +159 -0
- data/examples/2fa/.ruby-gemset +1 -0
- data/examples/2fa/.ruby-version +1 -0
- data/examples/2fa/Gemfile +8 -0
- data/examples/2fa/README.md +34 -0
- data/examples/2fa/app.rb +134 -0
- data/examples/2fa/config.ru +10 -0
- data/examples/2fa/helper.rb +37 -0
- data/examples/2fa/public/stylesheets/forms.css +28 -0
- data/examples/2fa/public/stylesheets/global.css +7 -0
- data/examples/2fa/public/stylesheets/layout.css +45 -0
- data/examples/2fa/public/stylesheets/main.css +3 -0
- data/examples/2fa/views/alert.erb +5 -0
- data/examples/2fa/views/dashboard.erb +4 -0
- data/examples/2fa/views/index.erb +17 -0
- data/examples/2fa/views/login.erb +13 -0
- data/examples/2fa/views/verify.erb +8 -0
- data/examples/sms/.env.example +4 -0
- data/examples/sms/.gitignore +159 -0
- data/examples/sms/.ruby-gemset +1 -0
- data/examples/sms/.ruby-version +1 -0
- data/examples/sms/Gemfile +8 -0
- data/examples/sms/README.md +80 -0
- data/examples/sms/app.rb +87 -0
- data/examples/sms/config.ru +10 -0
- data/examples/sms/helper.rb +33 -0
- data/examples/sms/public/scripts/notification.js +46 -0
- data/examples/sms/public/stylesheets/forms.css +28 -0
- data/examples/sms/public/stylesheets/global.css +7 -0
- data/examples/sms/public/stylesheets/layout.css +74 -0
- data/examples/sms/public/stylesheets/main.css +3 -0
- data/examples/sms/views/alert.erb +5 -0
- data/examples/sms/views/index.erb +48 -0
- data/lib/cpaas-sdk.rb +30 -0
- data/lib/cpaas-sdk/api.rb +139 -0
- data/lib/cpaas-sdk/config.rb +9 -0
- data/lib/cpaas-sdk/resources.rb +4 -0
- data/lib/cpaas-sdk/resources/conversation.rb +268 -0
- data/lib/cpaas-sdk/resources/notification.rb +62 -0
- data/lib/cpaas-sdk/resources/notification_channel.rb +39 -0
- data/lib/cpaas-sdk/resources/twofactor.rb +136 -0
- data/lib/cpaas-sdk/util.rb +93 -0
- data/lib/cpaas-sdk/version.rb +3 -0
- data/tutorials/2FA.md +109 -0
- data/tutorials/2fa-flow.png +0 -0
- data/tutorials/GetStarted.md +86 -0
- data/tutorials/SMSMessaging.md +132 -0
- data/tutorials/index.html +86 -0
- data/tutorials/quickstarts.yml +15 -0
- metadata +238 -0
@@ -0,0 +1,301 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Cpaas::Notification
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.20
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Cpaas::Notification";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (N)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Notification</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Cpaas::Notification
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Cpaas::Notification</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/cpaas/resources/notification.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>CPaaS notification helper methods</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Class Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#parse-class_method" title="parse (class method)">.<strong>parse</strong>(notification) ⇒ Object </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'>
|
146
|
+
<p>Parse inbound sms notification received in webhook.</p>
|
147
|
+
</div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<div id="class_method_details" class="method_details_list">
|
158
|
+
<h2>Class Method Details</h2>
|
159
|
+
|
160
|
+
|
161
|
+
<div class="method_details first">
|
162
|
+
<h3 class="signature first" id="parse-class_method">
|
163
|
+
|
164
|
+
.<strong>parse</strong>(notification) ⇒ <tt>Object</tt>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</h3><div class="docstring">
|
171
|
+
<div class="discussion">
|
172
|
+
|
173
|
+
<p>Parse inbound sms notification received in webhook. It parses the
|
174
|
+
notification and returns simplified version of the response.</p>
|
175
|
+
|
176
|
+
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
<div class="tags">
|
180
|
+
<p class="tag_title">Parameters:</p>
|
181
|
+
<ul class="param">
|
182
|
+
|
183
|
+
<li>
|
184
|
+
|
185
|
+
<span class='name'>notification</span>
|
186
|
+
|
187
|
+
|
188
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
—
|
193
|
+
<div class='inline'>
|
194
|
+
<p>JSON received in the subscription webhook.</p>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
</ul>
|
200
|
+
|
201
|
+
|
202
|
+
</div><table class="source_code">
|
203
|
+
<tr>
|
204
|
+
<td>
|
205
|
+
<pre class="lines">
|
206
|
+
|
207
|
+
|
208
|
+
14
|
209
|
+
15
|
210
|
+
16
|
211
|
+
17
|
212
|
+
18
|
213
|
+
19
|
214
|
+
20
|
215
|
+
21
|
216
|
+
22
|
217
|
+
23
|
218
|
+
24
|
219
|
+
25
|
220
|
+
26
|
221
|
+
27
|
222
|
+
28
|
223
|
+
29
|
224
|
+
30
|
225
|
+
31
|
226
|
+
32
|
227
|
+
33
|
228
|
+
34
|
229
|
+
35
|
230
|
+
36
|
231
|
+
37
|
232
|
+
38
|
233
|
+
39
|
234
|
+
40
|
235
|
+
41
|
236
|
+
42
|
237
|
+
43
|
238
|
+
44
|
239
|
+
45
|
240
|
+
46
|
241
|
+
47
|
242
|
+
48
|
243
|
+
49</pre>
|
244
|
+
</td>
|
245
|
+
<td>
|
246
|
+
<pre class="code"><span class="info file"># File 'lib/cpaas/resources/notification.rb', line 14</span>
|
247
|
+
|
248
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_notification'>notification</span><span class='rparen'>)</span>
|
249
|
+
<span class='id identifier rubyid_parsed_notification'>parsed_notification</span> <span class='op'>=</span> <span class='id identifier rubyid_convert_hash_keys'><span class='object_link'><a href="../top-level-namespace.html#convert_hash_keys-instance_method" title="#convert_hash_keys (method)">convert_hash_keys</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_notification'>notification</span><span class='rparen'>)</span>
|
250
|
+
<span class='id identifier rubyid_top_level_key'>top_level_key</span> <span class='op'>=</span> <span class='id identifier rubyid_parsed_notification'>parsed_notification</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
251
|
+
<span class='id identifier rubyid_notification_obj'>notification_obj</span> <span class='op'>=</span> <span class='id identifier rubyid_parsed_notification'>parsed_notification</span><span class='lbracket'>[</span><span class='id identifier rubyid_top_level_key'>top_level_key</span><span class='rbracket'>]</span>
|
252
|
+
|
253
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_top_level_key'>top_level_key</span>
|
254
|
+
<span class='kw'>when</span> <span class='symbol'>:outbound_sms_message_notification</span><span class='comma'>,</span> <span class='symbol'>:inbound_sms_message_notification</span>
|
255
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:outbound_sms_message</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:inbound_sms_message</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:outbound_sms_message</span><span class='rparen'>)</span>
|
256
|
+
|
257
|
+
<span class='lbrace'>{</span>
|
258
|
+
<span class='label'>notification_id:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='comma'>,</span>
|
259
|
+
<span class='label'>notification_date_time:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:date_time</span><span class='rparen'>)</span><span class='comma'>,</span>
|
260
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_types'>types</span><span class='lbracket'>[</span><span class='id identifier rubyid_top_level_key'>top_level_key</span><span class='rbracket'>]</span>
|
261
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
|
262
|
+
<span class='kw'>when</span> <span class='symbol'>:sms_subscription_cancellation_notification</span>
|
263
|
+
<span class='lbrace'>{</span>
|
264
|
+
<span class='label'>subscription_id:</span> <span class='id identifier rubyid_id_from'><span class='object_link'><a href="../top-level-namespace.html#id_from-instance_method" title="#id_from (method)">id_from</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:link</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='symbol'>:href</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='comma'>,</span>
|
265
|
+
<span class='label'>notification_id:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='comma'>,</span>
|
266
|
+
<span class='label'>notification_date_time:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:date_time</span><span class='rparen'>)</span><span class='comma'>,</span>
|
267
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_types'>types</span><span class='lbracket'>[</span><span class='id identifier rubyid_top_level_key'>top_level_key</span><span class='rbracket'>]</span>
|
268
|
+
<span class='rbrace'>}</span>
|
269
|
+
<span class='kw'>when</span> <span class='symbol'>:sms_event_notification</span>
|
270
|
+
<span class='lbrace'>{</span>
|
271
|
+
<span class='label'>notification_id:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='comma'>,</span>
|
272
|
+
<span class='label'>notification_date_time:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:date_time</span><span class='rparen'>)</span><span class='comma'>,</span>
|
273
|
+
<span class='label'>message_id:</span> <span class='id identifier rubyid_id_from'><span class='object_link'><a href="../top-level-namespace.html#id_from-instance_method" title="#id_from (method)">id_from</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:link</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='symbol'>:href</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='comma'>,</span>
|
274
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_types'>types</span><span class='lbracket'>[</span><span class='id identifier rubyid_top_level_key'>top_level_key</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
275
|
+
<span class='label'>event_details:</span> <span class='lbrace'>{</span>
|
276
|
+
<span class='label'>description:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:event_description</span><span class='rparen'>)</span><span class='comma'>,</span>
|
277
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_notification_obj'>notification_obj</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:event_type</span><span class='rparen'>)</span>
|
278
|
+
<span class='rbrace'>}</span>
|
279
|
+
<span class='rbrace'>}</span>
|
280
|
+
<span class='kw'>else</span>
|
281
|
+
<span class='id identifier rubyid_notification_obj'>notification_obj</span>
|
282
|
+
<span class='kw'>end</span>
|
283
|
+
<span class='kw'>end</span></pre>
|
284
|
+
</td>
|
285
|
+
</tr>
|
286
|
+
</table>
|
287
|
+
</div>
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
<div id="footer">
|
294
|
+
Generated on Thu Oct 17 17:28:29 2019 by
|
295
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
296
|
+
0.9.20 (ruby-2.5.0).
|
297
|
+
</div>
|
298
|
+
|
299
|
+
</div>
|
300
|
+
</body>
|
301
|
+
</html>
|
@@ -0,0 +1,908 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Cpaas::Twofactor
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.20
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Cpaas::Twofactor";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (T)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Twofactor</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Cpaas::Twofactor
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Cpaas::Twofactor</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/cpaas/resources/twofactor.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>CPaaS provides Authentication API where a two-factor authentication (2FA)
|
106
|
+
flow can be implemented by using that. Sections below describe two sample
|
107
|
+
use cases, two-factor authentication via SMS and two-factor authentication
|
108
|
+
via e-mail</p>
|
109
|
+
|
110
|
+
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
<div class="tags">
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<h2>
|
125
|
+
Class Method Summary
|
126
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
127
|
+
</h2>
|
128
|
+
|
129
|
+
<ul class="summary">
|
130
|
+
|
131
|
+
<li class="public ">
|
132
|
+
<span class="summary_signature">
|
133
|
+
|
134
|
+
<a href="#delete_code-class_method" title="delete_code (class method)">.<strong>delete_code</strong>(params = {}) ⇒ Object </a>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
</span>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<span class="summary_desc"><div class='inline'>
|
149
|
+
<p>Delete authentication code resource.</p>
|
150
|
+
</div></span>
|
151
|
+
|
152
|
+
</li>
|
153
|
+
|
154
|
+
|
155
|
+
<li class="public ">
|
156
|
+
<span class="summary_signature">
|
157
|
+
|
158
|
+
<a href="#resend_code-class_method" title="resend_code (class method)">.<strong>resend_code</strong>(params = {}) ⇒ Object </a>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
</span>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
<span class="summary_desc"><div class='inline'>
|
173
|
+
<p>Resending the authentication code via same code resource, invalidating the
|
174
|
+
previously sent code.</p>
|
175
|
+
</div></span>
|
176
|
+
|
177
|
+
</li>
|
178
|
+
|
179
|
+
|
180
|
+
<li class="public ">
|
181
|
+
<span class="summary_signature">
|
182
|
+
|
183
|
+
<a href="#send_code-class_method" title="send_code (class method)">.<strong>send_code</strong>(params = {}) ⇒ Object </a>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
</span>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
<span class="summary_desc"><div class='inline'>
|
198
|
+
<p>Create a new authentication code.</p>
|
199
|
+
</div></span>
|
200
|
+
|
201
|
+
</li>
|
202
|
+
|
203
|
+
|
204
|
+
<li class="public ">
|
205
|
+
<span class="summary_signature">
|
206
|
+
|
207
|
+
<a href="#verify_code-class_method" title="verify_code (class method)">.<strong>verify_code</strong>(params = {}) ⇒ Object </a>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
</span>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'>
|
222
|
+
<p>Verifying authentication code.</p>
|
223
|
+
</div></span>
|
224
|
+
|
225
|
+
</li>
|
226
|
+
|
227
|
+
|
228
|
+
</ul>
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<div id="class_method_details" class="method_details_list">
|
234
|
+
<h2>Class Method Details</h2>
|
235
|
+
|
236
|
+
|
237
|
+
<div class="method_details first">
|
238
|
+
<h3 class="signature first" id="delete_code-class_method">
|
239
|
+
|
240
|
+
.<strong>delete_code</strong>(params = {}) ⇒ <tt>Object</tt>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
</h3><div class="docstring">
|
247
|
+
<div class="discussion">
|
248
|
+
|
249
|
+
<p>Delete authentication code resource.</p>
|
250
|
+
|
251
|
+
|
252
|
+
</div>
|
253
|
+
</div>
|
254
|
+
<div class="tags">
|
255
|
+
<p class="tag_title">Parameters:</p>
|
256
|
+
<ul class="param">
|
257
|
+
|
258
|
+
<li>
|
259
|
+
|
260
|
+
<span class='name'>params</span>
|
261
|
+
|
262
|
+
|
263
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
264
|
+
|
265
|
+
|
266
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
267
|
+
|
268
|
+
|
269
|
+
</li>
|
270
|
+
|
271
|
+
</ul>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
<p class="tag_title">Options Hash (<tt>params</tt>):</p>
|
277
|
+
<ul class="option">
|
278
|
+
|
279
|
+
<li>
|
280
|
+
<span class="name">:code_id</span>
|
281
|
+
<span class="type">(<tt>String</tt>)</span>
|
282
|
+
<span class="default">
|
283
|
+
|
284
|
+
</span>
|
285
|
+
|
286
|
+
— <div class='inline'>
|
287
|
+
<p>ID of the authentication code.</p>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
</li>
|
291
|
+
|
292
|
+
</ul>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
</div><table class="source_code">
|
297
|
+
<tr>
|
298
|
+
<td>
|
299
|
+
<pre class="lines">
|
300
|
+
|
301
|
+
|
302
|
+
126
|
303
|
+
127
|
304
|
+
128</pre>
|
305
|
+
</td>
|
306
|
+
<td>
|
307
|
+
<pre class="code"><span class="info file"># File 'lib/cpaas/resources/twofactor.rb', line 126</span>
|
308
|
+
|
309
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete_code'>delete_code</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
310
|
+
<span class='const'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span><span class='period'>.</span><span class='id identifier rubyid_api'><span class='object_link'><a href="../Cpaas.html#api-class_method" title="Cpaas.api (method)">api</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send_request'>send_request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_base_url'>base_url</span><span class='embexpr_end'>}</span><span class='tstring_content'>/codes/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:code_id</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:delete</span><span class='rparen'>)</span>
|
311
|
+
<span class='kw'>end</span></pre>
|
312
|
+
</td>
|
313
|
+
</tr>
|
314
|
+
</table>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
<div class="method_details ">
|
318
|
+
<h3 class="signature " id="resend_code-class_method">
|
319
|
+
|
320
|
+
.<strong>resend_code</strong>(params = {}) ⇒ <tt>Object</tt>
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
</h3><div class="docstring">
|
327
|
+
<div class="discussion">
|
328
|
+
|
329
|
+
<p>Resending the authentication code via same code resource, invalidating the
|
330
|
+
previously sent code.</p>
|
331
|
+
|
332
|
+
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
<div class="tags">
|
336
|
+
<p class="tag_title">Parameters:</p>
|
337
|
+
<ul class="param">
|
338
|
+
|
339
|
+
<li>
|
340
|
+
|
341
|
+
<span class='name'>params</span>
|
342
|
+
|
343
|
+
|
344
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
345
|
+
|
346
|
+
|
347
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
348
|
+
|
349
|
+
|
350
|
+
</li>
|
351
|
+
|
352
|
+
</ul>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
<p class="tag_title">Options Hash (<tt>params</tt>):</p>
|
358
|
+
<ul class="option">
|
359
|
+
|
360
|
+
<li>
|
361
|
+
<span class="name">:destination_address</span>
|
362
|
+
<span class="type">(<tt>String|Array[string]</tt>)</span>
|
363
|
+
<span class="default">
|
364
|
+
|
365
|
+
</span>
|
366
|
+
|
367
|
+
— <div class='inline'>
|
368
|
+
<p>Destination address of the authentication code being sent. For sms type
|
369
|
+
authentication codes, it should contain a E164 phone number. For e-mail
|
370
|
+
type authentication codes, it should contain a valid e-mail address.</p>
|
371
|
+
</div>
|
372
|
+
|
373
|
+
</li>
|
374
|
+
|
375
|
+
<li>
|
376
|
+
<span class="name">:message</span>
|
377
|
+
<span class="type">(<tt>String</tt>)</span>
|
378
|
+
<span class="default">
|
379
|
+
|
380
|
+
</span>
|
381
|
+
|
382
|
+
— <div class='inline'>
|
383
|
+
<p>Message text sent to the destination, containing the placeholder for the
|
384
|
+
code within the text. CPaaS requires to have *code* string within the
|
385
|
+
text in order to generate a code and inject into the text. For email type
|
386
|
+
code, one usage is to have the *code* string located within the link in
|
387
|
+
order to get a unique link.</p>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
</li>
|
391
|
+
|
392
|
+
<li>
|
393
|
+
<span class="name">:code_id</span>
|
394
|
+
<span class="type">(<tt>String</tt>)</span>
|
395
|
+
<span class="default">
|
396
|
+
|
397
|
+
</span>
|
398
|
+
|
399
|
+
— <div class='inline'>
|
400
|
+
<p>ID of the authentication code.</p>
|
401
|
+
</div>
|
402
|
+
|
403
|
+
</li>
|
404
|
+
|
405
|
+
<li>
|
406
|
+
<span class="name">:method</span>
|
407
|
+
<span class="type">(<tt>String</tt>)</span>
|
408
|
+
<span class="default">
|
409
|
+
|
410
|
+
— default:
|
411
|
+
<tt>'sms'</tt>
|
412
|
+
|
413
|
+
</span>
|
414
|
+
|
415
|
+
— <div class='inline'>
|
416
|
+
<p><code>optional</code> Type of the authentication code delivery method, sms
|
417
|
+
and email are supported types. Possible values: sms, email</p>
|
418
|
+
</div>
|
419
|
+
|
420
|
+
</li>
|
421
|
+
|
422
|
+
<li>
|
423
|
+
<span class="name">:expiry</span>
|
424
|
+
<span class="type">(<tt>Number</tt>)</span>
|
425
|
+
<span class="default">
|
426
|
+
|
427
|
+
— default:
|
428
|
+
<tt>120</tt>
|
429
|
+
|
430
|
+
</span>
|
431
|
+
|
432
|
+
— <div class='inline'>
|
433
|
+
<p><code>optional</code> Lifetime duration of the code sent in seconds. This
|
434
|
+
can contain values between 30 and 3600 seconds.</p>
|
435
|
+
</div>
|
436
|
+
|
437
|
+
</li>
|
438
|
+
|
439
|
+
<li>
|
440
|
+
<span class="name">:length</span>
|
441
|
+
<span class="type">(<tt>Number</tt>)</span>
|
442
|
+
<span class="default">
|
443
|
+
|
444
|
+
— default:
|
445
|
+
<tt>6</tt>
|
446
|
+
|
447
|
+
</span>
|
448
|
+
|
449
|
+
— <div class='inline'>
|
450
|
+
<p><code>optional</code> Length of the authentication code tha CPaaS should
|
451
|
+
generate for this request. It can contain values between 4 and 10.</p>
|
452
|
+
</div>
|
453
|
+
|
454
|
+
</li>
|
455
|
+
|
456
|
+
<li>
|
457
|
+
<span class="name">:type</span>
|
458
|
+
<span class="type">(<tt>String</tt>)</span>
|
459
|
+
<span class="default">
|
460
|
+
|
461
|
+
— default:
|
462
|
+
<tt>'numeric'</tt>
|
463
|
+
|
464
|
+
</span>
|
465
|
+
|
466
|
+
— <div class='inline'>
|
467
|
+
<p><code>optional</code> Type of the code that is generated. If not provided,
|
468
|
+
default value is numeric. Possible values: numeric, alphanumeric,
|
469
|
+
alphabetic</p>
|
470
|
+
</div>
|
471
|
+
|
472
|
+
</li>
|
473
|
+
|
474
|
+
</ul>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
</div><table class="source_code">
|
479
|
+
<tr>
|
480
|
+
<td>
|
481
|
+
<pre class="lines">
|
482
|
+
|
483
|
+
|
484
|
+
93
|
485
|
+
94
|
486
|
+
95
|
487
|
+
96
|
488
|
+
97
|
489
|
+
98
|
490
|
+
99
|
491
|
+
100
|
492
|
+
101
|
493
|
+
102
|
494
|
+
103
|
495
|
+
104
|
496
|
+
105
|
497
|
+
106
|
498
|
+
107
|
499
|
+
108
|
500
|
+
109
|
501
|
+
110
|
502
|
+
111
|
503
|
+
112
|
504
|
+
113
|
505
|
+
114
|
506
|
+
115
|
507
|
+
116
|
508
|
+
117
|
509
|
+
118</pre>
|
510
|
+
</td>
|
511
|
+
<td>
|
512
|
+
<pre class="code"><span class="info file"># File 'lib/cpaas/resources/twofactor.rb', line 93</span>
|
513
|
+
|
514
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_resend_code'>resend_code</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
515
|
+
<span class='id identifier rubyid_address'>address</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='lbracket'>[</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span> <span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span>
|
516
|
+
|
517
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
518
|
+
<span class='label'>body:</span> <span class='lbrace'>{</span>
|
519
|
+
<span class='label'>code:</span> <span class='lbrace'>{</span>
|
520
|
+
<span class='label'>address:</span> <span class='id identifier rubyid_address'>address</span><span class='comma'>,</span>
|
521
|
+
<span class='label'>method:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:method</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sms</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
522
|
+
<span class='label'>format:</span> <span class='lbrace'>{</span>
|
523
|
+
<span class='label'>length:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:length</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>6</span><span class='comma'>,</span>
|
524
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>numeric</span><span class='tstring_end'>'</span></span>
|
525
|
+
<span class='rbrace'>}</span><span class='comma'>,</span>
|
526
|
+
<span class='label'>expiry:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:expiry</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>120</span><span class='comma'>,</span>
|
527
|
+
<span class='label'>message:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:message</span><span class='rbracket'>]</span>
|
528
|
+
<span class='rbrace'>}</span>
|
529
|
+
<span class='rbrace'>}</span>
|
530
|
+
<span class='rbrace'>}</span>
|
531
|
+
|
532
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span><span class='period'>.</span><span class='id identifier rubyid_api'><span class='object_link'><a href="../Cpaas.html#api-class_method" title="Cpaas.api (method)">api</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send_request'>send_request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_base_url'>base_url</span><span class='embexpr_end'>}</span><span class='tstring_content'>/codes/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:code_id</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='symbol'>:put</span><span class='rparen'>)</span>
|
533
|
+
|
534
|
+
<span class='id identifier rubyid_process_response'><span class='object_link'><a href="../top-level-namespace.html#process_response-instance_method" title="#process_response (method)">process_response</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_res'>res</span><span class='op'>|</span>
|
535
|
+
<span class='lbrace'>{</span>
|
536
|
+
<span class='label'>code_id:</span> <span class='id identifier rubyid_id_from'><span class='object_link'><a href="../top-level-namespace.html#id_from-instance_method" title="#id_from (method)">id_from</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:code</span><span class='comma'>,</span> <span class='symbol'>:resource_url</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
537
|
+
<span class='rbrace'>}</span>
|
538
|
+
<span class='kw'>end</span>
|
539
|
+
<span class='kw'>end</span></pre>
|
540
|
+
</td>
|
541
|
+
</tr>
|
542
|
+
</table>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
<div class="method_details ">
|
546
|
+
<h3 class="signature " id="send_code-class_method">
|
547
|
+
|
548
|
+
.<strong>send_code</strong>(params = {}) ⇒ <tt>Object</tt>
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
</h3><div class="docstring">
|
555
|
+
<div class="discussion">
|
556
|
+
|
557
|
+
<p>Create a new authentication code.</p>
|
558
|
+
|
559
|
+
|
560
|
+
</div>
|
561
|
+
</div>
|
562
|
+
<div class="tags">
|
563
|
+
<p class="tag_title">Parameters:</p>
|
564
|
+
<ul class="param">
|
565
|
+
|
566
|
+
<li>
|
567
|
+
|
568
|
+
<span class='name'>params</span>
|
569
|
+
|
570
|
+
|
571
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
572
|
+
|
573
|
+
|
574
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
575
|
+
|
576
|
+
|
577
|
+
</li>
|
578
|
+
|
579
|
+
</ul>
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
<p class="tag_title">Options Hash (<tt>params</tt>):</p>
|
585
|
+
<ul class="option">
|
586
|
+
|
587
|
+
<li>
|
588
|
+
<span class="name">:destination_address</span>
|
589
|
+
<span class="type">(<tt>String|Array[string]</tt>)</span>
|
590
|
+
<span class="default">
|
591
|
+
|
592
|
+
</span>
|
593
|
+
|
594
|
+
— <div class='inline'>
|
595
|
+
<p>Destination address of the authentication code being sent. For sms type
|
596
|
+
authentication codes, it should contain a E164 phone number. For e-mail
|
597
|
+
type authentication codes, it should contain a valid e-mail address.</p>
|
598
|
+
</div>
|
599
|
+
|
600
|
+
</li>
|
601
|
+
|
602
|
+
<li>
|
603
|
+
<span class="name">:message</span>
|
604
|
+
<span class="type">(<tt>String</tt>)</span>
|
605
|
+
<span class="default">
|
606
|
+
|
607
|
+
</span>
|
608
|
+
|
609
|
+
— <div class='inline'>
|
610
|
+
<p>Message text sent to the destination, containing the placeholder for the
|
611
|
+
code within the text. CPaaS requires to have *code* string within the
|
612
|
+
text in order to generate a code and inject into the text. For email type
|
613
|
+
code, one usage is to have the *code* string located within the link in
|
614
|
+
order to get a unique link.</p>
|
615
|
+
</div>
|
616
|
+
|
617
|
+
</li>
|
618
|
+
|
619
|
+
<li>
|
620
|
+
<span class="name">:method</span>
|
621
|
+
<span class="type">(<tt>String</tt>)</span>
|
622
|
+
<span class="default">
|
623
|
+
|
624
|
+
— default:
|
625
|
+
<tt>'sms'</tt>
|
626
|
+
|
627
|
+
</span>
|
628
|
+
|
629
|
+
— <div class='inline'>
|
630
|
+
<p><code>optional</code> Type of the authentication code delivery method, sms
|
631
|
+
and email are supported types. Possible values: sms, email</p>
|
632
|
+
</div>
|
633
|
+
|
634
|
+
</li>
|
635
|
+
|
636
|
+
<li>
|
637
|
+
<span class="name">:expiry</span>
|
638
|
+
<span class="type">(<tt>Number</tt>)</span>
|
639
|
+
<span class="default">
|
640
|
+
|
641
|
+
— default:
|
642
|
+
<tt>120</tt>
|
643
|
+
|
644
|
+
</span>
|
645
|
+
|
646
|
+
— <div class='inline'>
|
647
|
+
<p><code>optional</code> Lifetime duration of the code sent in seconds. This
|
648
|
+
can contain values between 30 and 3600 seconds.</p>
|
649
|
+
</div>
|
650
|
+
|
651
|
+
</li>
|
652
|
+
|
653
|
+
<li>
|
654
|
+
<span class="name">:length</span>
|
655
|
+
<span class="type">(<tt>Number</tt>)</span>
|
656
|
+
<span class="default">
|
657
|
+
|
658
|
+
— default:
|
659
|
+
<tt>6</tt>
|
660
|
+
|
661
|
+
</span>
|
662
|
+
|
663
|
+
— <div class='inline'>
|
664
|
+
<p><code>optional</code> Length of the authentication code tha CPaaS should
|
665
|
+
generate for this request. It can contain values between 4 and 10.</p>
|
666
|
+
</div>
|
667
|
+
|
668
|
+
</li>
|
669
|
+
|
670
|
+
<li>
|
671
|
+
<span class="name">:type</span>
|
672
|
+
<span class="type">(<tt>String</tt>)</span>
|
673
|
+
<span class="default">
|
674
|
+
|
675
|
+
— default:
|
676
|
+
<tt>'numeric'</tt>
|
677
|
+
|
678
|
+
</span>
|
679
|
+
|
680
|
+
— <div class='inline'>
|
681
|
+
<p><code>optional</code> Type of the code that is generated. If not provided,
|
682
|
+
default value is numeric. Possible values: numeric, alphanumeric,
|
683
|
+
alphabetic</p>
|
684
|
+
</div>
|
685
|
+
|
686
|
+
</li>
|
687
|
+
|
688
|
+
</ul>
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
</div><table class="source_code">
|
693
|
+
<tr>
|
694
|
+
<td>
|
695
|
+
<pre class="lines">
|
696
|
+
|
697
|
+
|
698
|
+
21
|
699
|
+
22
|
700
|
+
23
|
701
|
+
24
|
702
|
+
25
|
703
|
+
26
|
704
|
+
27
|
705
|
+
28
|
706
|
+
29
|
707
|
+
30
|
708
|
+
31
|
709
|
+
32
|
710
|
+
33
|
711
|
+
34
|
712
|
+
35
|
713
|
+
36
|
714
|
+
37
|
715
|
+
38
|
716
|
+
39
|
717
|
+
40
|
718
|
+
41
|
719
|
+
42
|
720
|
+
43
|
721
|
+
44
|
722
|
+
45
|
723
|
+
46</pre>
|
724
|
+
</td>
|
725
|
+
<td>
|
726
|
+
<pre class="code"><span class="info file"># File 'lib/cpaas/resources/twofactor.rb', line 21</span>
|
727
|
+
|
728
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send_code'>send_code</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
729
|
+
<span class='id identifier rubyid_address'>address</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='lbracket'>[</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span> <span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:destination_address</span><span class='rbracket'>]</span>
|
730
|
+
|
731
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
732
|
+
<span class='label'>body:</span> <span class='lbrace'>{</span>
|
733
|
+
<span class='label'>code:</span> <span class='lbrace'>{</span>
|
734
|
+
<span class='label'>address:</span> <span class='id identifier rubyid_address'>address</span><span class='comma'>,</span>
|
735
|
+
<span class='label'>method:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:method</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sms</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
736
|
+
<span class='label'>format:</span> <span class='lbrace'>{</span>
|
737
|
+
<span class='label'>length:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:length</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>6</span><span class='comma'>,</span>
|
738
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>numeric</span><span class='tstring_end'>'</span></span>
|
739
|
+
<span class='rbrace'>}</span><span class='comma'>,</span>
|
740
|
+
<span class='label'>expiry:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:expiry</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>120</span><span class='comma'>,</span>
|
741
|
+
<span class='label'>message:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:message</span><span class='rbracket'>]</span>
|
742
|
+
<span class='rbrace'>}</span>
|
743
|
+
<span class='rbrace'>}</span>
|
744
|
+
<span class='rbrace'>}</span>
|
745
|
+
|
746
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span><span class='period'>.</span><span class='id identifier rubyid_api'><span class='object_link'><a href="../Cpaas.html#api-class_method" title="Cpaas.api (method)">api</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send_request'>send_request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_base_url'>base_url</span><span class='embexpr_end'>}</span><span class='tstring_content'>/codes</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='symbol'>:post</span><span class='rparen'>)</span>
|
747
|
+
|
748
|
+
<span class='id identifier rubyid_process_response'><span class='object_link'><a href="../top-level-namespace.html#process_response-instance_method" title="#process_response (method)">process_response</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_res'>res</span><span class='op'>|</span>
|
749
|
+
<span class='lbrace'>{</span>
|
750
|
+
<span class='label'>code_id:</span> <span class='id identifier rubyid_id_from'><span class='object_link'><a href="../top-level-namespace.html#id_from-instance_method" title="#id_from (method)">id_from</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='symbol'>:code</span><span class='comma'>,</span> <span class='symbol'>:resource_url</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
751
|
+
<span class='rbrace'>}</span>
|
752
|
+
<span class='kw'>end</span>
|
753
|
+
<span class='kw'>end</span></pre>
|
754
|
+
</td>
|
755
|
+
</tr>
|
756
|
+
</table>
|
757
|
+
</div>
|
758
|
+
|
759
|
+
<div class="method_details ">
|
760
|
+
<h3 class="signature " id="verify_code-class_method">
|
761
|
+
|
762
|
+
.<strong>verify_code</strong>(params = {}) ⇒ <tt>Object</tt>
|
763
|
+
|
764
|
+
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
</h3><div class="docstring">
|
769
|
+
<div class="discussion">
|
770
|
+
|
771
|
+
<p>Verifying authentication code</p>
|
772
|
+
|
773
|
+
|
774
|
+
</div>
|
775
|
+
</div>
|
776
|
+
<div class="tags">
|
777
|
+
<p class="tag_title">Parameters:</p>
|
778
|
+
<ul class="param">
|
779
|
+
|
780
|
+
<li>
|
781
|
+
|
782
|
+
<span class='name'>params</span>
|
783
|
+
|
784
|
+
|
785
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
786
|
+
|
787
|
+
|
788
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
789
|
+
|
790
|
+
|
791
|
+
</li>
|
792
|
+
|
793
|
+
</ul>
|
794
|
+
|
795
|
+
|
796
|
+
|
797
|
+
|
798
|
+
<p class="tag_title">Options Hash (<tt>params</tt>):</p>
|
799
|
+
<ul class="option">
|
800
|
+
|
801
|
+
<li>
|
802
|
+
<span class="name">:code_id</span>
|
803
|
+
<span class="type">(<tt>String</tt>)</span>
|
804
|
+
<span class="default">
|
805
|
+
|
806
|
+
</span>
|
807
|
+
|
808
|
+
— <div class='inline'>
|
809
|
+
<p>ID of the authentication code.</p>
|
810
|
+
</div>
|
811
|
+
|
812
|
+
</li>
|
813
|
+
|
814
|
+
<li>
|
815
|
+
<span class="name">:verification_code</span>
|
816
|
+
<span class="type">(<tt>String</tt>)</span>
|
817
|
+
<span class="default">
|
818
|
+
|
819
|
+
</span>
|
820
|
+
|
821
|
+
— <div class='inline'>
|
822
|
+
<p>Code that is being verified</p>
|
823
|
+
</div>
|
824
|
+
|
825
|
+
</li>
|
826
|
+
|
827
|
+
</ul>
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
</div><table class="source_code">
|
832
|
+
<tr>
|
833
|
+
<td>
|
834
|
+
<pre class="lines">
|
835
|
+
|
836
|
+
|
837
|
+
55
|
838
|
+
56
|
839
|
+
57
|
840
|
+
58
|
841
|
+
59
|
842
|
+
60
|
843
|
+
61
|
844
|
+
62
|
845
|
+
63
|
846
|
+
64
|
847
|
+
65
|
848
|
+
66
|
849
|
+
67
|
850
|
+
68
|
851
|
+
69
|
852
|
+
70
|
853
|
+
71
|
854
|
+
72
|
855
|
+
73
|
856
|
+
74
|
857
|
+
75
|
858
|
+
76
|
859
|
+
77
|
860
|
+
78
|
861
|
+
79</pre>
|
862
|
+
</td>
|
863
|
+
<td>
|
864
|
+
<pre class="code"><span class="info file"># File 'lib/cpaas/resources/twofactor.rb', line 55</span>
|
865
|
+
|
866
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_verify_code'>verify_code</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
867
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
868
|
+
<span class='label'>body:</span> <span class='lbrace'>{</span>
|
869
|
+
<span class='label'>code:</span> <span class='lbrace'>{</span>
|
870
|
+
<span class='label'>verify:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:verification_code</span><span class='rbracket'>]</span>
|
871
|
+
<span class='rbrace'>}</span>
|
872
|
+
<span class='rbrace'>}</span>
|
873
|
+
<span class='rbrace'>}</span>
|
874
|
+
|
875
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Cpaas.html" title="Cpaas (module)">Cpaas</a></span></span><span class='period'>.</span><span class='id identifier rubyid_api'><span class='object_link'><a href="../Cpaas.html#api-class_method" title="Cpaas.api (method)">api</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send_request'>send_request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_base_url'>base_url</span><span class='embexpr_end'>}</span><span class='tstring_content'>/codes/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:code_id</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>/verify</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='symbol'>:put</span><span class='rparen'>)</span>
|
876
|
+
|
877
|
+
<span class='id identifier rubyid_process_response'><span class='object_link'><a href="../top-level-namespace.html#process_response-instance_method" title="#process_response (method)">process_response</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_res'>res</span><span class='op'>|</span>
|
878
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='symbol'>:status_code</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='int'>204</span>
|
879
|
+
<span class='lbrace'>{</span>
|
880
|
+
<span class='label'>verified:</span> <span class='kw'>true</span><span class='comma'>,</span>
|
881
|
+
<span class='label'>message:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Success</span><span class='tstring_end'>'</span></span>
|
882
|
+
<span class='rbrace'>}</span>
|
883
|
+
<span class='kw'>else</span>
|
884
|
+
<span class='lbrace'>{</span>
|
885
|
+
<span class='label'>verified:</span> <span class='kw'>false</span><span class='comma'>,</span>
|
886
|
+
<span class='label'>message:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Code invalid or expired</span><span class='tstring_end'>'</span></span>
|
887
|
+
<span class='rbrace'>}</span>
|
888
|
+
<span class='kw'>end</span>
|
889
|
+
<span class='kw'>end</span>
|
890
|
+
<span class='kw'>end</span></pre>
|
891
|
+
</td>
|
892
|
+
</tr>
|
893
|
+
</table>
|
894
|
+
</div>
|
895
|
+
|
896
|
+
</div>
|
897
|
+
|
898
|
+
</div>
|
899
|
+
|
900
|
+
<div id="footer">
|
901
|
+
Generated on Thu Oct 17 17:28:29 2019 by
|
902
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
903
|
+
0.9.20 (ruby-2.5.0).
|
904
|
+
</div>
|
905
|
+
|
906
|
+
</div>
|
907
|
+
</body>
|
908
|
+
</html>
|