usman 0.2.5 → 0.2.6

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/usman/api/v1/docs_controller.rb +5 -5
  3. data/app/controllers/usman/api/v1/registrations_controller.rb +136 -49
  4. data/app/models/device.rb +15 -16
  5. data/app/models/registration.rb +1 -1
  6. data/app/services/usman/mobile_registration_service.rb +5 -3
  7. data/app/views/usman/api/v1/docs/accept_tac/_neg_case_1.html.erb +32 -0
  8. data/app/views/usman/api/v1/docs/accept_tac/_neg_case_2.html.erb +30 -0
  9. data/app/views/usman/api/v1/docs/accept_tac/_neg_case_3.html.erb +35 -0
  10. data/app/views/usman/api/v1/docs/accept_tac/_pos_case_1.html.erb +35 -0
  11. data/app/views/usman/api/v1/docs/register/_neg_case_4.html.erb +35 -0
  12. data/app/views/usman/api/v1/docs/register/_pos_case_1.html.erb +30 -28
  13. data/app/views/usman/api/v1/docs/register/_pos_case_2.html.erb +67 -0
  14. data/app/views/usman/api/v1/docs/register/_pos_case_3.html.erb +68 -0
  15. data/app/views/usman/api/v1/docs/resend_otp/_neg_case_1.html.erb +4 -4
  16. data/app/views/usman/api/v1/docs/resend_otp/_neg_case_2.html.erb +34 -0
  17. data/app/views/usman/api/v1/docs/resend_otp/_neg_case_3.html.erb +34 -0
  18. data/app/views/usman/api/v1/docs/resend_otp/_neg_case_4.html.erb +32 -0
  19. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_1.html.erb +5 -9
  20. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_2.html.erb +8 -12
  21. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_3.html.erb +9 -7
  22. data/app/views/usman/api/v1/docs/verify_otp/_neg_case_4.html.erb +33 -0
  23. data/app/views/usman/api/v1/docs/verify_otp/_pos_case_1.html.erb +4 -6
  24. data/app/views/usman/api/v1/docs/verify_otp/_pos_case_2.html.erb +35 -0
  25. data/config/locales/usman/api.ar.yml +50 -8
  26. data/config/locales/usman/api.en.yml +50 -8
  27. data/config/routes.rb +1 -1
  28. data/lib/usman/version.rb +1 -1
  29. metadata +16 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be37dd5242c311e6541ccfb190c9aa54597526cb
4
- data.tar.gz: 0d2bef201228c383b53ea972b213d416cf0851c4
3
+ metadata.gz: 6e90151fe766fe30d80afab167a73f3f19695575
4
+ data.tar.gz: f7c1661db459e54c6842955f13a5d33e5ab7177b
5
5
  SHA512:
6
- metadata.gz: 31ccc69fc7604ce950a96d97615ac345b6197cf1c8a1c45d6433762410c80d47ca8a2fdec01ea7682dbc0d435815948b5b3a57e4e442518f71f011857ec44e66
7
- data.tar.gz: 77dbcef014783e75b470eab8a572f5f88c8c5c98ea185a8bd0c6e23609e0e2400edb3636fcb94e9cb2f028fb281a503bbe0b4e48808447c7acb0181a66412b32
6
+ metadata.gz: aa84b62ff326217fa57b3bfccee3c92fd10e5596b1d89f03dc89f20ce2d6a09e5e1d59ffbd343aecaec434d6f1b9fef2dbba60899ee17dc00581eec4cda330a1
7
+ data.tar.gz: 36bc606482819a366c70ad7f7a99d325139ad030db3ae01aaac86b05cbfc9e0eaf51bef78f3410b9b13e661dcc5a6914fca30c2afb079fc1209c9d207b5926bc
@@ -7,7 +7,7 @@ module Usman
7
7
  set_title("Register API")
8
8
  @request_type = "POST"
9
9
  @end_point = "/api/v1/register"
10
- @description = "This API will register the user and the devise and will send an OTP for verification"
10
+ @description = "This API will register the user and the device and will send an OTP for verification. API will return the api_token if the device is already registered."
11
11
 
12
12
  @input_headers = {
13
13
  "Content-Type" => { value: "application/json", description: "The MIME media type for JSON text is application/json. This is to make sure that a valid json is returned. The default encoding is UTF-8. " }
@@ -27,7 +27,7 @@ module Usman
27
27
  }
28
28
 
29
29
  @example_path = "usman/api/v1/docs/"
30
- @examples = ["pos_case_1", "neg_case_1", "neg_case_2", "neg_case_3"]
30
+ @examples = ["pos_case_1", "pos_case_2", "pos_case_3", "neg_case_1", "neg_case_2", "neg_case_3"]
31
31
 
32
32
  set_nav("docs/register")
33
33
 
@@ -53,7 +53,7 @@ module Usman
53
53
  }
54
54
 
55
55
  @example_path = "usman/api/v1/docs/"
56
- @examples = ["pos_case_1", "neg_case_1"]
56
+ @examples = ["pos_case_1", "neg_case_1", "neg_case_2", "neg_case_3", "neg_case_4"]
57
57
 
58
58
  set_nav("docs/resend_otp")
59
59
 
@@ -78,7 +78,7 @@ module Usman
78
78
  }
79
79
 
80
80
  @example_path = "usman/api/v1/docs/"
81
- @examples = ["pos_case_1", "neg_case_1", "neg_case_2", "neg_case_3"]
81
+ @examples = ["pos_case_1", "pos_case_2", "neg_case_1", "neg_case_2", "neg_case_3", "neg_case_4"]
82
82
 
83
83
  set_nav("docs/verify_otp")
84
84
 
@@ -104,7 +104,7 @@ module Usman
104
104
  }
105
105
 
106
106
  @example_path = "usman/api/v1/docs/"#
107
- # @examples = ["pos_case_1", "neg_case_1", "neg_case_2", "neg_case_3"]
107
+ @examples = ["pos_case_1", "neg_case_1", "neg_case_2", "neg_case_3"]
108
108
 
109
109
  set_nav("docs/accept_tac")
110
110
 
@@ -13,8 +13,8 @@ module Usman
13
13
  if @errors[:heading].blank?
14
14
  @success = true
15
15
  @alert = {
16
- heading: I18n.translate("api.mobile_registration.otp_sent.heading"),
17
- message: I18n.translate("api.mobile_registration.otp_sent.message")
16
+ heading: I18n.translate("api.register.otp_sent.heading"),
17
+ message: I18n.translate("api.register.otp_sent.message")
18
18
  }
19
19
  @data = {
20
20
  registration: @reg_data.registration,
@@ -27,40 +27,52 @@ module Usman
27
27
 
28
28
  def resend_otp
29
29
  proc_code = Proc.new do
30
- @device = Device.where("uuid = ?", params[:uuid]).first
31
- if @device
32
- if @device.blocked?
33
- @success = false
34
- @errors = {
35
- heading: I18n.translate("api.mobile_registration.device_blocked.heading"),
36
- message: I18n.translate("api.mobile_registration.device_blocked.message"),
37
- details: {}
38
- }
39
- else
40
- valid, validation_errors = @device.resend_otp(params[:dialing_prefix], params[:mobile_number])
41
- if valid
42
- @success = true
43
- @alert = {
44
- heading: I18n.translate("api.mobile_registration.new_otp_sent.heading"),
45
- message: I18n.translate("api.mobile_registration.new_otp_sent.message")
46
- }
47
- @data = {}
48
- else
30
+ @registration = Registration.where("mobile_number = ?", params[:mobile_number]).first
31
+ if @registration
32
+ @device = @registration.devices.where("uuid = ?", params[:uuid]).first
33
+ if @device
34
+ if @device.blocked?
49
35
  @success = false
50
36
  @errors = {
51
- heading: I18n.translate("api.mobile_registration.otp_not_matching.heading"),
52
- message: I18n.translate("api.mobile_registration.otp_not_matching.message"),
53
- details: validation_errors
37
+ heading: I18n.translate("api.resend_otp.device_blocked.heading"),
38
+ message: I18n.translate("api.resend_otp.device_blocked.message"),
39
+ details: {}
54
40
  }
41
+ else
42
+ valid, validation_errors = @device.resend_otp(params[:dialing_prefix], params[:mobile_number])
43
+ if valid
44
+ @success = true
45
+ @alert = {
46
+ heading: I18n.translate("api.resend_otp.new_otp_sent.heading"),
47
+ message: I18n.translate("api.resend_otp.new_otp_sent.message")
48
+ }
49
+ @data = {}
50
+ else
51
+ @success = false
52
+ @errors = {
53
+ heading: I18n.translate("api.resend_otp.otp_not_matching.heading"),
54
+ message: I18n.translate("api.resend_otp.otp_not_matching.message"),
55
+ details: validation_errors
56
+ }
57
+ end
55
58
  end
59
+ else
60
+ @success = false
61
+ @errors = {
62
+ heading: I18n.translate("api.resend_otp.device_not_registered.heading"),
63
+ message: I18n.translate("api.resend_otp.device_not_registered.message"),
64
+ details: {
65
+ uuid: "is invalid"
66
+ }
67
+ }
56
68
  end
57
69
  else
58
70
  @success = false
59
71
  @errors = {
60
- heading: I18n.translate("api.general.unexpected_failure.heading"),
61
- message: I18n.translate("api.general.unexpected_failure.message"),
72
+ heading: I18n.translate("api.resend_otp.mobile_number_not_registered.heading"),
73
+ message: I18n.translate("api.resend_otp.mobile_number_not_registered.message"),
62
74
  details: {
63
- uuid: "is invalid"
75
+ mobile_number: "is invalid"
64
76
  }
65
77
  }
66
78
  end
@@ -68,41 +80,116 @@ module Usman
68
80
  render_json_response(proc_code)
69
81
  end
70
82
 
71
- def verify
83
+ def verify_otp
72
84
  proc_code = Proc.new do
73
- @device = Device.where("uuid = ?", params[:uuid]).first
74
- if @device
75
- if @device.blocked?
85
+ @registration = Registration.where("mobile_number = ?", params[:mobile_number]).first
86
+ if @registration
87
+ @device = @registration.devices.where("uuid = ?", params[:uuid]).first
88
+ if @device
89
+ if @device.blocked?
90
+ @success = false
91
+ @errors = {
92
+ heading: I18n.translate("api.verify_otp.device_blocked.heading"),
93
+ message: I18n.translate("api.verify_otp.device_blocked.message"),
94
+ details: {}
95
+ }
96
+ else
97
+ valid, validation_errors = @device.validate_otp(params[:otp], params[:dialing_prefix], params[:mobile_number])
98
+ if valid
99
+ @success = true
100
+ @alert = {
101
+ heading: I18n.translate("api.verify_otp.verification_success.heading"),
102
+ message: I18n.translate("api.verify_otp.verification_success.message")
103
+ }
104
+ @data = { api_token: @device.api_token } if @device.verified? && @device.tac_accepted?
105
+ else
106
+ @success = false
107
+ @errors = {
108
+ heading: I18n.translate("api.verify_otp.otp_not_matching.heading"),
109
+ message: I18n.translate("api.verify_otp.otp_not_matching.message"),
110
+ details: validation_errors
111
+ }
112
+ end
113
+ end
114
+ else
76
115
  @success = false
77
116
  @errors = {
78
- heading: I18n.translate("api.mobile_registration.device_blocked.heading"),
79
- message: I18n.translate("api.mobile_registration.device_blocked.message"),
80
- details: {}
117
+ heading: I18n.translate("api.verify_otp.device_not_registered.heading"),
118
+ message: I18n.translate("api.verify_otp.device_not_registered.message"),
119
+ details: {
120
+ uuid: "is invalid"
121
+ }
81
122
  }
82
- else
83
- valid, validation_errors = @device.validate_otp(params[:otp], params[:dialing_prefix], params[:mobile_number])
84
- if valid
85
- @success = true
86
- @alert = {
87
- heading: I18n.translate("api.mobile_registration.verification_success.heading"),
88
- message: I18n.translate("api.mobile_registration.verification_success.message")
123
+ end
124
+ else
125
+ @success = false
126
+ @errors = {
127
+ heading: I18n.translate("api.verify_otp.mobile_number_not_registered.heading"),
128
+ message: I18n.translate("api.verify_otp.mobile_number_not_registered.message"),
129
+ details: {
130
+ mobile_number: "is invalid"
131
+ }
132
+ }
133
+ end
134
+ end
135
+ render_json_response(proc_code)
136
+ end
137
+
138
+ def accept_tac
139
+ proc_code = Proc.new do
140
+ @registration = Registration.where("mobile_number = ?", params[:mobile_number]).first
141
+ if @registration
142
+ @device = @registration.devices.where("uuid = ?", params[:uuid]).first
143
+ if @device
144
+ if @device.blocked?
145
+ @success = false
146
+ @errors = {
147
+ heading: I18n.translate("api.accept_tac.device_blocked.heading"),
148
+ message: I18n.translate("api.accept_tac.device_blocked.message"),
149
+ details: {}
89
150
  }
90
- else
151
+ elsif @device.pending?
91
152
  @success = false
92
153
  @errors = {
93
- heading: I18n.translate("api.mobile_registration.otp_not_matching.heading"),
94
- message: I18n.translate("api.mobile_registration.otp_not_matching.message"),
95
- details: validation_errors
154
+ heading: I18n.translate("api.accept_tac.device_pending.heading"),
155
+ message: I18n.translate("api.accept_tac.device_pending.message"),
156
+ details: {}
96
157
  }
158
+ else
159
+ valid, validation_errors = @device.accept_tac(params[:terms_and_conditions], params[:dialing_prefix], params[:mobile_number])
160
+ if valid
161
+ @success = true
162
+ @alert = {
163
+ heading: I18n.translate("api.accept_tac.tac_accepted.heading"),
164
+ message: I18n.translate("api.accept_tac.tac_accepted.message")
165
+ }
166
+ @data = { api_token: @device.api_token } if @device.verified? && @device.tac_accepted?
167
+ else
168
+ @success = false
169
+ @errors = {
170
+ heading: I18n.translate("api.accept_tac.tac_not_accepted.heading"),
171
+ message: I18n.translate("api.accept_tac.tac_not_accepted.message"),
172
+ details: validation_errors
173
+ }
174
+ end
97
175
  end
176
+ else
177
+ @success = false
178
+ @errors = {
179
+ heading: I18n.translate("api.accept_tac.device_not_registered.heading"),
180
+ message: I18n.translate("api.accept_tac.device_not_registered.message"),
181
+ details: {
182
+ uuid: "is invalid"
183
+ }
184
+ }
98
185
  end
99
186
  else
100
187
  @success = false
101
188
  @errors = {
102
- heading: I18n.translate("api.general.unexpected_failure.heading"),
103
- message: I18n.translate("api.general.unexpected_failure.message"),
189
+ heading: I18n.translate("api.verify_otp.mobile_number_not_registered.heading"),
190
+ message: I18n.translate("api.verify_otp.mobile_number_not_registered.message"),
104
191
  details: {
105
- uuid: "is invalid"
192
+ mobile_number: "is invalid"
106
193
  }
107
194
  }
108
195
  end
@@ -110,7 +197,7 @@ module Usman
110
197
  render_json_response(proc_code)
111
198
  end
112
199
 
113
- def accept_tac
200
+ def accept_tac1
114
201
  proc_code = Proc.new do
115
202
  @device = Device.where("uuid = ?", params[:uuid]).first
116
203
  if @device
data/app/models/device.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Device < ApplicationRecord
2
2
 
3
3
  # Constants
4
- EXCLUDED_JSON_ATTRIBUTES = [:last_accessed_at, :last_accessed_api, :otp, :otp_sent_at, :api_token, :token_created_at, :status, :tac_accepted_at, :created_at, :updated_at]
4
+ EXCLUDED_JSON_ATTRIBUTES = [:last_accessed_at, :last_accessed_api, :otp, :otp_sent_at, :api_token, :token_created_at, :tac_accepted_at, :created_at, :updated_at]
5
5
 
6
6
  PENDING = "pending"
7
7
  VERIFIED = "verified"
@@ -68,9 +68,8 @@ class Device < ApplicationRecord
68
68
  # Exclude some attributes info from json output.
69
69
  def as_json(options={})
70
70
  options[:except] ||= EXCLUDED_JSON_ATTRIBUTES
71
- #options[:include] ||= []
72
71
  #options[:methods] = []
73
- #options[:methods] << :profile_image
72
+ #options[:methods] << :api_token
74
73
  json = super(options)
75
74
  Hash[*json.map{|k, v| [k, v || ""]}.flatten]
76
75
  end
@@ -145,7 +144,9 @@ class Device < ApplicationRecord
145
144
 
146
145
  def generate_otp
147
146
  self.otp = rand(10000..99999)
148
- self.otp_sent_at = Time.now
147
+ self.otp_sent_at = nil
148
+ self.otp_verified_at = nil
149
+ self.save
149
150
  end
150
151
 
151
152
  def validate_otp(otp, dialing_prefix, mobile_number)
@@ -153,12 +154,6 @@ class Device < ApplicationRecord
153
154
  # Validate OTP and other parameters
154
155
  validation_errors = {}
155
156
 
156
- # Check if this OTP was already verified
157
- if !self.otp_verified_at.blank?
158
- validation_errors[:otp_verified_at] = "This OTP was already used"
159
- return false, validation_errors
160
- end
161
-
162
157
  # TODO - remove 11111 after implementing Twilio
163
158
  validation_errors[:otp] = "doesn't match with our database" unless (self.otp.to_s == otp.to_s or otp.to_s == "11111")
164
159
  validation_errors[:mobile_number] = "doesn't match with our database" unless self.registration.mobile_number.to_s == mobile_number.to_s
@@ -175,6 +170,10 @@ class Device < ApplicationRecord
175
170
  self.verify!
176
171
  self.registration.verify!
177
172
 
173
+ # Clearing the OTP so that next time if he uses the same, it shows error
174
+ self.otp = nil
175
+ self.save
176
+
178
177
  return true, {}
179
178
  end
180
179
 
@@ -194,7 +193,6 @@ class Device < ApplicationRecord
194
193
 
195
194
  def send_otp
196
195
  self.generate_otp
197
- self.save
198
196
  return true
199
197
  end
200
198
 
@@ -204,8 +202,8 @@ class Device < ApplicationRecord
204
202
  validation_errors = {}
205
203
 
206
204
  # Check if terms and conditions was accepted
207
- unless ["true", "yes", "t", "y"].include?(tac.to_s.downcase)
208
- validation_errors[:terms_and_conditions] = "T&C should be true"
205
+ unless ["true", "yes", "t", "y", "1"].include?(tac.to_s.downcase)
206
+ validation_errors[:terms_and_conditions] = "must be true"
209
207
  return false, validation_errors
210
208
  end
211
209
 
@@ -218,12 +216,13 @@ class Device < ApplicationRecord
218
216
  self.tac_accepted_at = Time.now
219
217
  self.save
220
218
 
221
- self.verify!
222
- self.registration.verify!
223
-
224
219
  return true, {}
225
220
  end
226
221
 
222
+ def tac_accepted?
223
+ self.tac_accepted_at.present? && self.tac_accepted_at < Time.now
224
+ end
225
+
227
226
  # Other Methods
228
227
  # -------------
229
228
 
@@ -1,7 +1,7 @@
1
1
  class Registration < ApplicationRecord
2
2
 
3
3
  # Constants
4
- EXCLUDED_JSON_ATTRIBUTES = [:status, :created_at, :updated_at]
4
+ EXCLUDED_JSON_ATTRIBUTES = [:created_at, :updated_at]
5
5
 
6
6
  PENDING = "pending"
7
7
  VERIFIED = "verified"
@@ -44,7 +44,7 @@ module Usman
44
44
 
45
45
  if @registration.errors.any? or @device.errors.any?
46
46
  errors = @registration.errors.to_hash.merge(@device.errors.to_hash)
47
- set_error("api.mobile_registration.invalid_inputs", errors)
47
+ set_error("api.register.invalid_inputs", errors)
48
48
  end
49
49
  end
50
50
 
@@ -55,12 +55,14 @@ module Usman
55
55
  @registration.city = @city
56
56
  end
57
57
  @device = Device.where("LOWER(uuid) = LOWER('#{@uuid}')").first if @registration
58
+
59
+ @device.generate_otp if @device
58
60
  end
59
61
 
60
62
  def register_new_device
61
63
 
62
64
  if @device && @device.blocked?
63
- set_error("api.mobile_registration.device_blocked")
65
+ set_error("api.register.device_blocked")
64
66
  return
65
67
  end
66
68
 
@@ -102,7 +104,7 @@ module Usman
102
104
  if @device.send_otp
103
105
  @device.update_attribute(:otp_sent_at, Time.now)
104
106
  else
105
- set_error("api.mobile_registration.otp_not_sent")
107
+ set_error("api.register.otp_not_sent")
106
108
  end
107
109
  end
108
110
 
@@ -0,0 +1,32 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 1 - should not accept the terms and conditions if the device is not verified"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "terms_and_conditions": 1,
8
+ "uuid": "<PENDING UUID>",
9
+ "mobile_number": "<PENDING MOBILE NUMBER>",
10
+ "dialing_prefix": "+91"
11
+ }
12
+ eos
13
+
14
+ api_output = <<-eos
15
+ {
16
+ "success": false,
17
+ "errors": {
18
+ "heading": "This device is not verified",
19
+ "message": "You need to verify this device before you can accept the terms and conditions"
20
+ }
21
+ }
22
+ eos
23
+
24
+ %>
25
+
26
+ <%= render partial: "kuppayam/api/docs/example", locals: {
27
+ negative_case: true,
28
+ example_id: "neg_case_1",
29
+ api_title: api_title,
30
+ api_input: api_input,
31
+ api_output: api_output
32
+ } %>
@@ -0,0 +1,30 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 2 - should respond with proper errors if no params are passed"
4
+
5
+ api_input = <<-eos
6
+ {}
7
+ eos
8
+
9
+ api_output = <<-eos
10
+ {
11
+ "success": false,
12
+ "errors": {
13
+ "heading": "The mobile number is not registered",
14
+ "message": "Accepting T&C Failed. Check if the mobile number entered is valid",
15
+ "details": {
16
+ "mobile_number": "is invalid"
17
+ }
18
+ }
19
+ }
20
+ eos
21
+
22
+ %>
23
+
24
+ <%= render partial: "kuppayam/api/docs/example", locals: {
25
+ negative_case: true,
26
+ example_id: "neg_case_2",
27
+ api_title: api_title,
28
+ api_input: api_input,
29
+ api_output: api_output
30
+ } %>
@@ -0,0 +1,35 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 3 - should respond with proper errors if T&C is not accepted"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "terms_and_conditions": 0,
8
+ "uuid": "<VERIFIED UUID>",
9
+ "mobile_number": "<VERIFIED MOBILE NUMBER>",
10
+ "dialing_prefix": "+91"
11
+ }
12
+ eos
13
+
14
+ api_output = <<-eos
15
+ {
16
+ "success": false,
17
+ "errors": {
18
+ "heading": "You have not accepted the Terms & Conditions. Registration is complete only if you accept the T&C",
19
+ "message": "Accept the T&C to finish the Registration. Pass true",
20
+ "details": {
21
+ "terms_and_conditions": "must be true"
22
+ }
23
+ }
24
+ }
25
+ eos
26
+
27
+ %>
28
+
29
+ <%= render partial: "kuppayam/api/docs/example", locals: {
30
+ negative_case: true,
31
+ example_id: "neg_case_3",
32
+ api_title: api_title,
33
+ api_input: api_input,
34
+ api_output: api_output
35
+ } %>
@@ -0,0 +1,35 @@
1
+ <%
2
+
3
+ api_title = "Positive Case - 1 - should accept the terms and conditions if the device is verified and all inputs are valid"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "terms_and_conditions": 1,
8
+ "uuid": "<VERIFIED UUID>",
9
+ "mobile_number": "<VERIFIED MOBILE NUMBER>",
10
+ "dialing_prefix": "+91"
11
+ }
12
+ eos
13
+
14
+ api_output = <<-eos
15
+ {
16
+ "success": true,
17
+ "alert": {
18
+ "heading": "You have successfully accepted the Terms & Conditions. Proceed with Registration process if any",
19
+ "message": "Store and use the API token for further communication"
20
+ },
21
+ "data": {
22
+ "api_token": "ajshdjkashdkjasdas"
23
+ }
24
+ }
25
+ eos
26
+
27
+ %>
28
+
29
+ <%= render partial: "kuppayam/api/docs/example", locals: {
30
+ negative_case: false,
31
+ example_id: "pos_case_1",
32
+ api_title: api_title,
33
+ api_input: api_input,
34
+ api_output: api_output
35
+ } %>
@@ -0,0 +1,35 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 4 - should set proper errors for device is blocked"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "uuid": "<BLOCKED DEVICE UUID>",
8
+ "device_token": "<BLOCKED DEVICE DEVICE TOKEN>",
9
+ "device_name": "Apple iPhone",
10
+ "device_type": "iPhone 7 Plus",
11
+ "operating_system": "iOS",
12
+ "software_version": "iOS 11.2.2"
13
+ }
14
+ eos
15
+
16
+ api_output = <<-eos
17
+ {
18
+ "success": false,
19
+ "errors": {
20
+ "heading": "This device is blocked",
21
+ "message": "You must have done some mal-practices",
22
+ "details": {}
23
+ }
24
+ }
25
+ eos
26
+
27
+ %>
28
+
29
+ <%= render partial: "kuppayam/api/docs/example", locals: {
30
+ negative_case: true,
31
+ example_id: "neg_case_3",
32
+ api_title: api_title,
33
+ api_input: api_input,
34
+ api_output: api_output
35
+ } %>