usman 0.2.2 → 0.2.3
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 +4 -4
- data/app/controllers/api/v1/registrations_controller.rb +37 -1
- data/app/controllers/usman/docs_controller.rb +41 -0
- data/app/models/device.rb +35 -19
- data/app/services/usman/mobile_registration_service.rb +2 -5
- data/app/views/usman/docs/index.html.erb +502 -0
- data/app/views/usman/docs/register.html.erb +0 -0
- data/config/locales/usman/mobile_registration.ar.yml +3 -0
- data/config/locales/usman/mobile_registration.en.yml +3 -0
- data/config/routes.rb +6 -0
- data/lib/usman/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d15538692688eced6623bc7a704c298dfa89d783
|
4
|
+
data.tar.gz: ecf244d046e8c804049dedd9a2ad28afe8bc4084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72c15eb8d09f6fea21e023f8fdd43f66c0cb5044361b8af94ddda70d7968aa5dfa0950ef22bd75055bea01e51e2dcb9c0e65a46e959627e615bcd35e21493ce
|
7
|
+
data.tar.gz: 22d49bd7fed9f246b29583489abbd59ad40458a65f24e5551ec9d3bc304158b57977a1951fdc2496f4a5861999b63826b36a3ea3fb952d548d81d603b741a7b8
|
@@ -26,7 +26,43 @@ module Api
|
|
26
26
|
|
27
27
|
def resend_otp
|
28
28
|
proc_code = Proc.new do
|
29
|
-
|
29
|
+
@device = Device.where("uuid = ?", params[:uuid]).first
|
30
|
+
if @device
|
31
|
+
if @device.blocked?
|
32
|
+
@success = false
|
33
|
+
@errors = {
|
34
|
+
heading: I18n.translate("mobile_registration.device_blocked.heading"),
|
35
|
+
message: I18n.translate("mobile_registration.device_blocked.message"),
|
36
|
+
details: {}
|
37
|
+
}
|
38
|
+
else
|
39
|
+
valid, validation_errors = @device.resend_otp(params[:dialing_prefix], params[:mobile_number])
|
40
|
+
if valid
|
41
|
+
@success = true
|
42
|
+
@alert = {
|
43
|
+
heading: I18n.translate("mobile_registration.new_otp_sent.heading"),
|
44
|
+
message: I18n.translate("mobile_registration.new_otp_sent.message")
|
45
|
+
}
|
46
|
+
@data = {}
|
47
|
+
else
|
48
|
+
@success = false
|
49
|
+
@errors = {
|
50
|
+
heading: I18n.translate("mobile_registration.otp_not_matching.heading"),
|
51
|
+
message: I18n.translate("mobile_registration.otp_not_matching.message"),
|
52
|
+
details: validation_errors
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
@success = false
|
58
|
+
@errors = {
|
59
|
+
heading: I18n.translate("general.unexpected_failure.heading"),
|
60
|
+
message: I18n.translate("general.unexpected_failure.message"),
|
61
|
+
details: {
|
62
|
+
uuid: "is invalid"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
30
66
|
end
|
31
67
|
render_json_response(proc_code)
|
32
68
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Usman
|
2
|
+
class DocsController < Kuppayam::BaseController
|
3
|
+
|
4
|
+
include Usman::AuthenticationHelper
|
5
|
+
|
6
|
+
layout 'kuppayam/docs'
|
7
|
+
|
8
|
+
before_action :current_user
|
9
|
+
|
10
|
+
def index
|
11
|
+
end
|
12
|
+
|
13
|
+
def register
|
14
|
+
end
|
15
|
+
|
16
|
+
def resend_otp
|
17
|
+
end
|
18
|
+
|
19
|
+
def verify
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_default_title
|
25
|
+
set_title("API Docs | #{params[:action].to_s.titleize}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def breadcrumbs_configuration
|
29
|
+
{
|
30
|
+
heading: "API Documentation",
|
31
|
+
description: "Requests and response structures with examples",
|
32
|
+
links: [{name: "Index", link: docs_index_path, icon: 'fa-list'}]
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_navs
|
37
|
+
set_nav("docs")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/app/models/device.rb
CHANGED
@@ -144,6 +144,7 @@ class Device < ApplicationRecord
|
|
144
144
|
|
145
145
|
def generate_otp
|
146
146
|
self.otp = rand(10000..99999)
|
147
|
+
self.otp_sent_at = Time.now
|
147
148
|
end
|
148
149
|
|
149
150
|
def validate_otp(otp, dialing_prefix, mobile_number)
|
@@ -151,34 +152,49 @@ class Device < ApplicationRecord
|
|
151
152
|
# Validate OTP and other parameters
|
152
153
|
validation_errors = {}
|
153
154
|
|
155
|
+
# Check if this OTP was already verified
|
156
|
+
if !self.otp_verified_at.blank?
|
157
|
+
validation_errors[:otp_verified_at] = "This OTP was already used."
|
158
|
+
return false, validation_errors
|
159
|
+
end
|
160
|
+
|
154
161
|
# TODO - remove 11111 after implementing Twilio
|
155
|
-
validation_errors[:otp] = "doesn't match with our database" unless (self.otp.to_s == otp.to_s
|
162
|
+
validation_errors[:otp] = "doesn't match with our database" unless (self.otp.to_s == otp.to_s or otp.to_s == "11111")
|
156
163
|
validation_errors[:mobile_number] = "doesn't match with our database" unless self.registration.mobile_number.to_s == mobile_number.to_s
|
157
164
|
validation_errors[:dialing_prefix] = "doesn't match with our database" unless self.registration.dialing_prefix.to_s == dialing_prefix.to_s
|
158
165
|
|
159
|
-
|
160
|
-
|
166
|
+
return false, validation_errors unless validation_errors.empty?
|
167
|
+
|
168
|
+
# Create API Token if OTP is verified
|
169
|
+
self.otp_verified_at = Time.now
|
170
|
+
self.api_token = SecureRandom.hex
|
171
|
+
self.token_created_at = Time.now
|
172
|
+
self.save
|
161
173
|
|
162
|
-
|
163
|
-
|
164
|
-
self.api_token = SecureRandom.hex
|
165
|
-
self.token_created_at = Time.now
|
166
|
-
self.save
|
174
|
+
self.verify!
|
175
|
+
self.registration.verify!
|
167
176
|
|
168
|
-
|
169
|
-
|
177
|
+
return true, {}
|
178
|
+
end
|
170
179
|
|
171
|
-
|
172
|
-
|
180
|
+
def resend_otp(dialing_prefix, mobile_number)
|
181
|
+
# Validate OTP and other parameters
|
182
|
+
validation_errors = {}
|
173
183
|
|
174
|
-
|
175
|
-
|
184
|
+
validation_errors[:mobile_number] = "doesn't match with our database" unless self.registration.mobile_number.to_s == mobile_number.to_s
|
185
|
+
validation_errors[:dialing_prefix] = "doesn't match with our database" unless self.registration.dialing_prefix.to_s == dialing_prefix.to_s
|
186
|
+
|
187
|
+
return false, validation_errors unless validation_errors.empty?
|
188
|
+
|
189
|
+
self.send_otp
|
176
190
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
191
|
+
return true, {}
|
192
|
+
end
|
193
|
+
|
194
|
+
def send_otp
|
195
|
+
self.generate_otp
|
196
|
+
self.save
|
197
|
+
return true
|
182
198
|
end
|
183
199
|
|
184
200
|
# Other Methods
|
@@ -78,6 +78,7 @@ module Usman
|
|
78
78
|
@device.registration = @registration
|
79
79
|
@device.user = @registration.user
|
80
80
|
@device.uuid = @uuid
|
81
|
+
@device.api_token = SecureRandom.hex
|
81
82
|
@device.device_token = @device_token
|
82
83
|
@device.device_name = @device_name
|
83
84
|
@device.device_type = @device_type
|
@@ -100,17 +101,13 @@ module Usman
|
|
100
101
|
|
101
102
|
def generate_new_otp
|
102
103
|
@device.generate_otp
|
103
|
-
if send_otp
|
104
|
+
if @device.send_otp
|
104
105
|
@device.update_attribute(:otp_sent_at, Time.now)
|
105
106
|
else
|
106
107
|
set_error("mobile_registration.otp_not_sent")
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
110
|
-
def send_otp
|
111
|
-
return true
|
112
|
-
end
|
113
|
-
|
114
111
|
def set_error(key, hsh={})
|
115
112
|
@error_heading = I18n.t("#{key}.heading")
|
116
113
|
@error_message = I18n.t("#{key}.message")
|
@@ -0,0 +1,502 @@
|
|
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
|
@@ -9,6 +9,9 @@ en:
|
|
9
9
|
otp_sent:
|
10
10
|
heading: "An OTP has been sent to you"
|
11
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."
|
12
15
|
otp_not_sent:
|
13
16
|
heading: "OTP was not sent"
|
14
17
|
message: "There was some technical glitch and OTP was not sent. Try after some time."
|
@@ -9,6 +9,9 @@ en:
|
|
9
9
|
otp_sent:
|
10
10
|
heading: "An OTP has been sent to you"
|
11
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."
|
12
15
|
otp_not_sent:
|
13
16
|
heading: "OTP was not sent"
|
14
17
|
message: "There was some technical glitch and OTP was not sent. Try after some time."
|
data/config/routes.rb
CHANGED
@@ -43,4 +43,10 @@ Usman::Engine.routes.draw do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
get '/api/v1/docs/usman', to: "docs#index", as: :docs_index
|
47
|
+
|
48
|
+
#get "/api/v1/docs/register", :controller => "/usman/api_docs"
|
49
|
+
#get "/api/v1/docs/resend_otp", :controller => "/usman/api_docs"
|
50
|
+
#get "/api/v1/docs/verify", :controller => "/usman/api_docs"
|
51
|
+
|
46
52
|
end
|
data/lib/usman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -350,6 +350,7 @@ files:
|
|
350
350
|
- app/controllers/usman/admin_controller.rb
|
351
351
|
- app/controllers/usman/application_controller.rb
|
352
352
|
- app/controllers/usman/dashboard_controller.rb
|
353
|
+
- app/controllers/usman/docs_controller.rb
|
353
354
|
- app/controllers/usman/features_controller.rb
|
354
355
|
- app/controllers/usman/my_account_controller.rb
|
355
356
|
- app/controllers/usman/permissions_controller.rb
|
@@ -383,6 +384,8 @@ files:
|
|
383
384
|
- app/views/layouts/kuppayam/_sidebar.html.erb
|
384
385
|
- app/views/layouts/kuppayam/profile.html.erb
|
385
386
|
- app/views/usman/dashboard/index.html.erb
|
387
|
+
- app/views/usman/docs/index.html.erb
|
388
|
+
- app/views/usman/docs/register.html.erb
|
386
389
|
- app/views/usman/features/_form.html.erb
|
387
390
|
- app/views/usman/features/_index.html.erb
|
388
391
|
- app/views/usman/features/_row.html.erb
|