usman 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/usman/api/v1/base_controller.rb +15 -0
  3. data/app/controllers/usman/api/v1/docs_base_controller.rb +25 -0
  4. data/app/controllers/usman/api/v1/docs_controller.rb +165 -0
  5. data/app/controllers/usman/api/v1/profile_controller.rb +60 -0
  6. data/app/controllers/usman/api/v1/registrations_controller.rb +159 -0
  7. data/app/controllers/usman/registration_devices_controller.rb +141 -0
  8. data/app/controllers/usman/registrations_controller.rb +68 -0
  9. data/app/helpers/usman/api_helper.rb +21 -36
  10. data/app/helpers/usman/authentication_helper.rb +1 -1
  11. data/app/models/device.rb +30 -3
  12. data/app/models/registration.rb +12 -3
  13. data/app/models/user.rb +54 -4
  14. data/app/services/usman/mobile_registration_service.rb +3 -5
  15. data/app/views/kuppayam/api/docs/_navigation.html.erb +43 -0
  16. data/app/views/usman/api/v1/docs/register/_neg_case_1.html.erb +46 -0
  17. data/app/views/usman/api/v1/docs/register/_neg_case_2.html.erb +39 -0
  18. data/app/views/usman/api/v1/docs/register/_neg_case_3.html.erb +47 -0
  19. data/app/views/usman/api/v1/docs/register/_pos_case_1.html.erb +65 -0
  20. data/app/views/usman/api/v1/docs/resend_otp/_neg_case_1.html.erb +30 -0
  21. data/app/views/usman/api/v1/docs/resend_otp/_pos_case_1.html.erb +31 -0
  22. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_1.html.erb +34 -0
  23. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_2.html.erb +39 -0
  24. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_3.html.erb +33 -0
  25. data/app/views/usman/api/v1/docs/verify_otp/_pos_case_1.html.erb +35 -0
  26. data/app/views/usman/registration_devices/_form.html.erb +24 -0
  27. data/app/views/usman/registration_devices/_index.html.erb +80 -0
  28. data/app/views/usman/registration_devices/_row.html.erb +34 -0
  29. data/app/views/usman/registrations/_form.html.erb +23 -0
  30. data/app/views/usman/registrations/_index.html.erb +60 -0
  31. data/app/views/usman/registrations/_row.html.erb +24 -0
  32. data/app/views/usman/registrations/_show.html.erb +112 -0
  33. data/app/views/usman/registrations/index.html.erb +47 -0
  34. data/config/locales/usman/api.ar.yml +43 -0
  35. data/config/locales/usman/api.en.yml +43 -0
  36. data/config/locales/usman/authentication.ar.yml +14 -14
  37. data/config/locales/usman/authentication.en.yml +15 -18
  38. data/config/routes.rb +28 -9
  39. data/db/migrate/20170904080436_add_tac_accepted_at_to_devices.rb +5 -0
  40. data/db/migrate/20170905041104_add_gender_to_users.rb +6 -0
  41. data/lib/usman/version.rb +1 -1
  42. metadata +36 -15
  43. data/app/controllers/api/v1/base_controller.rb +0 -13
  44. data/app/controllers/api/v1/registrations_controller.rb +0 -115
  45. data/app/controllers/usman/docs_controller.rb +0 -41
  46. data/app/views/usman/docs/index.html.erb +0 -502
  47. data/app/views/usman/docs/register.html.erb +0 -0
  48. data/config/locales/usman/general.ar.yml +0 -5
  49. data/config/locales/usman/general.en.yml +0 -5
  50. data/config/locales/usman/mobile_registration.ar.yml +0 -26
  51. data/config/locales/usman/mobile_registration.en.yml +0 -26
@@ -1,502 +0,0 @@
1
- <div class="tabs-vertical-env">
2
-
3
- <ul class="nav tabs-vertical">
4
- <li class="active">
5
- <a href="#register" data-toggle="tab">
6
- <i class="fa-globe visible-xs"></i>
7
- <span class="hidden-xs">Register</span>
8
- </a>
9
- </li>
10
- <li class="">
11
- <a href="#resend_otp" data-toggle="tab">
12
- <i class="fa-globe visible-xs"></i>
13
- <span class="hidden-xs">Resend OTP</span>
14
- </a>
15
- </li>
16
- <li class="">
17
- <a href="#verify" data-toggle="tab">
18
- <i class="fa-globe visible-xs"></i>
19
- <span class="hidden-xs">Verify</span>
20
- </a>
21
- </li>
22
- <li class="">
23
- <a href="#terms_and_conditions" data-toggle="tab">
24
- <i class="fa-globe visible-xs"></i>
25
- <span class="hidden-xs">Terms & Conditions</span>
26
- </a>
27
- </li>
28
- <li class="">
29
- <a href="#create_profile" data-toggle="tab">
30
- <i class="fa-globe visible-xs"></i>
31
- <span class="hidden-xs">Create Profile</span>
32
- </a>
33
- </li>
34
- <li class="">
35
- <a href="#create_profile" data-toggle="tab">
36
- <i class="fa-globe visible-xs"></i>
37
- <span class="hidden-xs">Update Profile</span>
38
- </a>
39
- </li>
40
- </ul>
41
-
42
- <div class="tab-content">
43
-
44
- <!-- Sample Search Results Tab -->
45
- <div class="tab-pane active" id="register">
46
-
47
- <h3>
48
- <span class="text-success">Register API</span><br>
49
- <small>/api/v1/register</small>
50
- </h3>
51
-
52
- <div class="panel-group panel-group-joined">
53
-
54
- <div class="panel panel-default panel-positive" style="width:100%;">
55
- <div class="panel-heading">
56
- <h4 class="panel-title">
57
- <a data-toggle="collapse" data-parent="#register-pos-1" href="#register-pos-1" class="collapsed" aria-expanded="false">
58
- Positive Case - 1 - should register and add a new device
59
- </a>
60
- </h4>
61
- </div>
62
- <div id="register-pos-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
63
- <div class="panel-body">
64
- <div class="mt-10 mb-20">Input</div>
65
- <pre>
66
- {
67
- "country_id": "1",
68
- "city_id": "2",
69
- "dialing_prefix": "+91",
70
- "mobile_number": "501370321",
71
- "uuid": "jh01u2g01h301h21h232",
72
- "device_token": "0182y3b28107b31",
73
- "device_name": "Apple iPhone",
74
- "device_type": "iPhone 7 Plus",
75
- "operating_system": "iOS",
76
- "software_version": "iOS 11.2.2"
77
- }</pre>
78
-
79
- <div class="mt-10 mb-20">Output</div>
80
- <pre>
81
- {
82
- "success": true,
83
- "alert": {
84
- "heading": "An OTP has been sent to you",
85
- "message": "Check your mobile for new message from us."
86
- },
87
- "data": {
88
- "registration": {
89
- "id": 5,
90
- "user_id": null,
91
- "country_id": 1,
92
- "city_id": null,
93
- "dialing_prefix": "+91",
94
- "mobile_number": "501370321"
95
- },
96
- "device": {
97
- "id": 6,
98
- "user_id": null,
99
- "registration_id": 5,
100
- "uuid": "jh01u2g01h301h21h232",
101
- "device_token": "0182y3b28107b31",
102
- "device_name": "Apple iPhone",
103
- "device_type": "iPhone 7 Plus",
104
- "operating_system": "iOS",
105
- "software_version": "iOS 11.2.2",
106
- "otp_verified_at": null
107
- }
108
- },
109
- "errors": {
110
- "heading": null,
111
- "message": null,
112
- "details": {}
113
- }
114
- }</pre>
115
- </div>
116
- </div>
117
- </div>
118
-
119
- <div class="panel panel-default panel-negative" style="width:100%;">
120
- <div class="panel-heading">
121
- <h4 class="panel-title">
122
- <a data-toggle="collapse" data-parent="#register-neg-1" href="#register-neg-1" class="collapsed" aria-expanded="false">
123
- Negative Case - 1 - should set proper errors if no input is given
124
- </a>
125
- </h4>
126
- </div>
127
- <div id="register-neg-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
128
- <div class="panel-body">
129
- <div class="mt-10 mb-20">Input</div>
130
- <pre>
131
- {}</pre>
132
-
133
- <div class="mt-10 mb-20">Output</div>
134
- <pre>
135
- {
136
- "success": false,
137
- "errors": {
138
- "heading": "Registring new mobile number FAILED.",
139
- "message": "Check if all mandatory details are passed. Refer the error details for technical information.",
140
- "details": {
141
- "country": [
142
- "must exist"
143
- ],
144
- "dialing_prefix": [
145
- "can't be blank",
146
- "is too short (minimum is 2 characters)"
147
- ],
148
- "mobile_number": [
149
- "can't be blank",
150
- "is too short (minimum is 9 characters)"
151
- ],
152
- "uuid": [
153
- "can't be blank"
154
- ],
155
- "device_token": [
156
- "can't be blank"
157
- ]
158
- }
159
- }
160
- }</pre>
161
- </div>
162
- </div>
163
- </div>
164
-
165
- <div class="panel panel-default panel-negative" style="width:100%;">
166
- <div class="panel-heading">
167
- <h4 class="panel-title">
168
- <a data-toggle="collapse" data-parent="#register-neg-2" href="#register-neg-2" class="collapsed" aria-expanded="false">
169
- Negative Case - 2 - should set proper errors when device information is missing
170
- </a>
171
- </h4>
172
- </div>
173
- <div id="register-neg-2" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
174
- <div class="panel-body">
175
- <div class="mt-10 mb-20">Input</div>
176
- <pre>
177
- {
178
- "country_id": "1",
179
- "dialing_prefix": "+92",
180
- "mobile_number": "501370323"
181
- }</pre>
182
-
183
- <div class="mt-10 mb-20">Output</div>
184
- <pre>
185
- {
186
- "success": false,
187
- "errors": {
188
- "heading": "Registring new mobile number FAILED.",
189
- "message": "Check if all mandatory details are passed. Refer the error details for technical information.",
190
- "details": {
191
- "uuid": [
192
- "can't be blank"
193
- ],
194
- "device_token": [
195
- "can't be blank"
196
- ]
197
- }
198
- }
199
- }</pre>
200
- </div>
201
- </div>
202
- </div>
203
-
204
- <div class="panel panel-default panel-negative" style="width:100%;">
205
- <div class="panel-heading">
206
- <h4 class="panel-title">
207
- <a data-toggle="collapse" data-parent="#register-neg-3" href="#register-neg-3" class="collapsed" aria-expanded="false">
208
- Negative Case - 3 - should set proper errors when registration information is missing
209
- </a>
210
- </h4>
211
- </div>
212
- <div id="register-neg-3" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
213
- <div class="panel-body">
214
- <div class="mt-10 mb-20">Input</div>
215
- <pre>
216
- {
217
- "uuid": "jh01u2g01h301h21h23",
218
- "device_token": "0182y3b28107b31",
219
- "device_name": "Apple iPhone",
220
- "device_type": "iPhone 7 Plus",
221
- "operating_system": "iOS",
222
- "software_version": "iOS 11.2.2"
223
- }</pre>
224
-
225
- <div class="mt-10 mb-20">Output</div>
226
- <pre>
227
- {
228
- "success": false,
229
- "errors": {
230
- "heading": "Registring new mobile number FAILED.",
231
- "message": "Check if all mandatory details are passed. Refer the error details for technical information.",
232
- "details": {
233
- "country": [
234
- "must exist"
235
- ],
236
- "dialing_prefix": [
237
- "can't be blank",
238
- "is too short (minimum is 2 characters)"
239
- ],
240
- "mobile_number": [
241
- "can't be blank",
242
- "is too short (minimum is 9 characters)"
243
- ]
244
- }
245
- }
246
- }</pre>
247
- </div>
248
- </div>
249
- </div>
250
-
251
- </div>
252
- </div>
253
-
254
- <!-- Search Results Tab -->
255
- <div class="tab-pane" id="resend_otp">
256
- <h3>
257
- <span class="text-success">Resend OTP</span><br>
258
- <small>/api/v1/resend_otp</small>
259
- </h3>
260
-
261
- <div class="panel-group panel-group-joined">
262
- <div class="panel panel-default panel-positive" style="width:100%;">
263
- <div class="panel-heading">
264
- <h4 class="panel-title">
265
- <a data-toggle="collapse" data-parent="#resend-otp-pos-1" href="#resend-otp-pos-1" class="collapsed" aria-expanded="false">
266
- Positive Case - 1 - should resend the otp for valid inputs
267
- </a>
268
- </h4>
269
- </div>
270
- <div id="resend-otp-pos-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
271
- <div class="panel-body">
272
- <div class="mt-10 mb-20">Input</div>
273
- <pre>
274
- {
275
- "uuid": "asd907asdba78sbda",
276
- "mobile_number": "292991230",
277
- "dialing_prefix": "+91"
278
- }</pre>
279
-
280
- <div class="mt-10 mb-20">Output</div>
281
- <pre>
282
- {
283
- "success": true,
284
- "alert": {
285
- "heading": "An new OTP has been sent to you",
286
- "message": "Check your mobile for new message from us."
287
- }
288
- }</pre>
289
- </div>
290
- </div>
291
- </div>
292
-
293
- <div class="panel panel-default panel-negative" style="width:100%;">
294
- <div class="panel-heading">
295
- <h4 class="panel-title">
296
- <a data-toggle="collapse" data-parent="#resend-otp-neg-1" href="#resend-otp-neg-1" class="collapsed" aria-expanded="false">
297
- Negative Case - 1 - should set proper errors if no input is given
298
- </a>
299
- </h4>
300
- </div>
301
- <div id="resend-otp-neg-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
302
- <div class="panel-body">
303
- <div class="mt-10 mb-20">Input</div>
304
- <pre>
305
- {}</pre>
306
-
307
- <div class="mt-10 mb-20">Output</div>
308
- <pre>
309
- {
310
- "success": false,
311
- "errors": {
312
- "heading": "Unexpected Failure",
313
- "message": "We're sorry, but something went wrong (500)",
314
- "details": {
315
- "uuid": "is invalid"
316
- }
317
- }
318
- }</pre>
319
- </div>
320
- </div>
321
- </div>
322
- </div>
323
- </div>
324
-
325
- <!-- Search Results Tab -->
326
- <div class="tab-pane" id="verify">
327
- <h3>
328
- <span class="text-success">Verify API</span><br>
329
- <small>/api/v1/verify</small>
330
- </h3>
331
-
332
- <div class="panel-group panel-group-joined">
333
- <div class="panel panel-default panel-positive" style="width:100%;">
334
- <div class="panel-heading">
335
- <h4 class="panel-title">
336
- <a data-toggle="collapse" data-parent="#verify-pos-1" href="#verify-pos-1" class="collapsed" aria-expanded="false">
337
- Positive Case - 1 - should verify an otp verification request from a pending device
338
- </a>
339
- </h4>
340
- </div>
341
- <div id="verify-pos-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
342
- <div class="panel-body">
343
- <div class="mt-10 mb-20">Input</div>
344
- <pre>
345
- {
346
- "otp": "11111",
347
- "uuid": "90a0dadsand",
348
- "mobile_number": "9102993912",
349
- "dialing_prefix": "+91"
350
- }</pre>
351
-
352
- <div class="mt-10 mb-20">Output</div>
353
- <pre>
354
- {
355
- "success": true,
356
- "alert": {
357
- "heading": "OTP was verified succesfully",
358
- "message": "Store and use the API token for further communication"
359
- },
360
- "data": {
361
- "api_token": "cfc0eb18c8f3b5922e702f1e10437fa1"
362
- }
363
- }</pre>
364
- </div>
365
- </div>
366
- </div>
367
-
368
- <div class="panel panel-default panel-negative" style="width:100%;">
369
- <div class="panel-heading">
370
- <h4 class="panel-title">
371
- <a data-toggle="collapse" data-parent="#verify-neg-1" href="#verify-neg-1" class="collapsed" aria-expanded="false">
372
- Negative Case - 1 - should set proper errors if no input is given
373
- </a>
374
- </h4>
375
- </div>
376
- <div id="verify-neg-1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
377
- <div class="panel-body">
378
- <div class="mt-10 mb-20">Input</div>
379
- <pre>
380
- {
381
- "uuid": "asd907asdba78sbda",
382
- "mobile_number": "292991230",
383
- "dialing_prefix": "+91"
384
- }</pre>
385
-
386
- <div class="mt-10 mb-20">Output</div>
387
- <pre>
388
- {
389
- "success": false,
390
- "errors": {
391
- "heading": "OTP verification was failed",
392
- "message": "Make sure that you enter the OTP correctly.",
393
- "details": {
394
- "otp": "doesn't match with our database"
395
- }
396
- }
397
- }</pre>
398
- </div>
399
- </div>
400
- </div>
401
-
402
- <div class="panel panel-default panel-negative" style="width:100%;">
403
- <div class="panel-heading">
404
- <h4 class="panel-title">
405
- <a data-toggle="collapse" data-parent="#verify-neg-2" href="#verify-neg-2" class="collapsed" aria-expanded="false">
406
- Negative Case - 2 - should respond with proper errors if the otp is already used once
407
- </a>
408
- </h4>
409
- </div>
410
- <div id="verify-neg-2" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
411
- <div class="panel-body">
412
- <div class="mt-10 mb-20">Input</div>
413
- <pre>
414
- {
415
- "otp": "11111",
416
- "uuid": "asd907asdba78sbda",
417
- "mobile_number": "292991230",
418
- "dialing_prefix": "+91"
419
- }</pre>
420
-
421
- <div class="mt-10 mb-20">Output</div>
422
- <pre>
423
- {
424
- "success": false,
425
- "errors": {
426
- "heading": "OTP verification was failed",
427
- "message": "Make sure that you enter the OTP correctly.",
428
- "details": {
429
- "otp_verified_at": "This OTP was already used."
430
- }
431
- }
432
- }</pre>
433
- </div>
434
- </div>
435
- </div>
436
-
437
- <div class="panel panel-default panel-negative" style="width:100%;">
438
- <div class="panel-heading">
439
- <h4 class="panel-title">
440
- <a data-toggle="collapse" data-parent="#verify-neg-3" href="#verify-neg-3" class="collapsed" aria-expanded="false">
441
- Negative Case - 2 - should respond with proper errors if the device is blocked
442
- </a>
443
- </h4>
444
- </div>
445
- <div id="verify-neg-3" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
446
- <div class="panel-body">
447
- <div class="mt-10 mb-20">Input</div>
448
- <pre>
449
- {
450
- "otp": "11111",
451
- "uuid": "asd907asdba78sbda",
452
- "mobile_number": "292991230",
453
- "dialing_prefix": "+91"
454
- }</pre>
455
-
456
- <div class="mt-10 mb-20">Output</div>
457
- <pre>
458
- {
459
- "success": false,
460
- "errors": {
461
- "heading": "This device is blocked.",
462
- "message": "You must have done some mal-practices.",
463
- "details": {}
464
- }
465
- }</pre>
466
- </div>
467
- </div>
468
- </div>
469
- </div>
470
- </div>
471
-
472
- <!-- Search Results Tab -->
473
- <div class="tab-pane" id="terms_and_conditions">
474
- <h3>
475
- <span class="text-success">Accept TAC API</span><br>
476
- <small>/api/v1/accept_tac</small>
477
- </h3>
478
- </div>
479
-
480
- <!-- Search Results Tab -->
481
- <div class="tab-pane" id="create_profile">
482
- <h3>
483
- <span class="text-success">Create Profile API</span><br>
484
- <small>/api/v1/create_profile</small>
485
- </h3>
486
- </div>
487
-
488
- <!-- Search Results Tab -->
489
- <div class="tab-pane" id="create_profile">
490
- <h3>
491
- <span class="text-success">Update Profile API</span><br>
492
- <small>/api/v1/update_profile</small>
493
- </h3>
494
- </div>
495
- </div>
496
-
497
- </div>
498
-
499
- <style type="text/css">
500
- .panel-positive h4.panel-title a { color: #68b828 !important; }
501
- .panel-negative h4.panel-title a { color: #cc3f44 !important; }
502
- </style>
File without changes
@@ -1,5 +0,0 @@
1
- en:
2
- general:
3
- unexpected_failure:
4
- heading: "Unexpected Failure"
5
- message: "We're sorry, but something went wrong (500)"
@@ -1,5 +0,0 @@
1
- en:
2
- general:
3
- unexpected_failure:
4
- heading: "Unexpected Failure"
5
- message: "We're sorry, but something went wrong (500)"
@@ -1,26 +0,0 @@
1
- en:
2
- mobile_registration:
3
- device_blocked:
4
- heading: "This device is blocked."
5
- message: "You must have done some mal-practices."
6
- invalid_inputs:
7
- heading: "Registring new mobile number FAILED."
8
- message: "Check if all mandatory details are passed. Refer the error details for technical information."
9
- otp_sent:
10
- heading: "An OTP has been sent to you"
11
- message: "Check your mobile for new message from us."
12
- new_otp_sent:
13
- heading: "An new OTP has been sent to you"
14
- message: "Check your mobile for new message from us."
15
- otp_not_sent:
16
- heading: "OTP was not sent"
17
- message: "There was some technical glitch and OTP was not sent. Try after some time."
18
- otp_not_matching:
19
- heading: "OTP verification was failed"
20
- message: "Make sure that you enter the OTP correctly."
21
- verification_failed:
22
- heading: "OTP verification was failed"
23
- message: "Check if you have properly given the OTP along with dialing prefix, mobile number & UUID"
24
- verification_success:
25
- heading: "OTP was verified succesfully"
26
- message: "Store and use the API token for further communication"
@@ -1,26 +0,0 @@
1
- en:
2
- mobile_registration:
3
- device_blocked:
4
- heading: "This device is blocked."
5
- message: "You must have done some mal-practices."
6
- invalid_inputs:
7
- heading: "Registring new mobile number FAILED."
8
- message: "Check if all mandatory details are passed. Refer the error details for technical information."
9
- otp_sent:
10
- heading: "An OTP has been sent to you"
11
- message: "Check your mobile for new message from us."
12
- new_otp_sent:
13
- heading: "An new OTP has been sent to you"
14
- message: "Check your mobile for new message from us."
15
- otp_not_sent:
16
- heading: "OTP was not sent"
17
- message: "There was some technical glitch and OTP was not sent. Try after some time."
18
- otp_not_matching:
19
- heading: "OTP verification was failed"
20
- message: "Make sure that you enter the OTP correctly."
21
- verification_failed:
22
- heading: "OTP verification was failed"
23
- message: "Check if you have properly given the OTP along with dialing prefix, mobile number & UUID"
24
- verification_success:
25
- heading: "OTP was verified succesfully"
26
- message: "Store and use the API token for further communication"