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
@@ -7,9 +7,9 @@ api_input = <<-eos
7
7
  "country_id": "1",
8
8
  "city_id": "2",
9
9
  "dialing_prefix": "+91",
10
- "mobile_number": "501370321",
11
- "uuid": "jh01u2g01h301h21h232",
12
- "device_token": "0182y3b28107b31",
10
+ "mobile_number": "<NEW MOBILE NUMBER>",
11
+ "uuid": "<NEW UUID>",
12
+ "device_token": "<NEW DEVICE TOKEN>",
13
13
  "device_name": "Apple iPhone",
14
14
  "device_type": "iPhone 7 Plus",
15
15
  "operating_system": "iOS",
@@ -21,35 +21,37 @@ api_output = <<-eos
21
21
  {
22
22
  "success": true,
23
23
  "alert": {
24
- "heading": "An OTP has been sent to you",
25
- "message": "Check your mobile for new message from us."
24
+ "heading": "An OTP has been sent to you",
25
+ "message": "Check your mobile for new message from us."
26
26
  },
27
27
  "data": {
28
- "registration": {
29
- "id": 5,
30
- "user_id": null,
31
- "country_id": 1,
32
- "city_id": null,
33
- "dialing_prefix": "+91",
34
- "mobile_number": "501370321"
35
- },
36
- "device": {
37
- "id": 6,
38
- "user_id": null,
39
- "registration_id": 5,
40
- "uuid": "jh01u2g01h301h21h232",
41
- "device_token": "0182y3b28107b31",
42
- "device_name": "Apple iPhone",
43
- "device_type": "iPhone 7 Plus",
44
- "operating_system": "iOS",
45
- "software_version": "iOS 11.2.2",
46
- "otp_verified_at": null
47
- }
28
+ "registration": {
29
+ "id": 5,
30
+ "user_id": null,
31
+ "country_id": 1,
32
+ "city_id": null,
33
+ "dialing_prefix": "+91",
34
+ "mobile_number": "501370321",
35
+ "status": "pending"
36
+ },
37
+ "device": {
38
+ "id": 6,
39
+ "user_id": null,
40
+ "registration_id": 5,
41
+ "uuid": "jh01u2g01h301h21h232",
42
+ "device_token": "0182y3b28107b31",
43
+ "device_name": "Apple iPhone",
44
+ "device_type": "iPhone 7 Plus",
45
+ "operating_system": "iOS",
46
+ "software_version": "iOS 11.2.2",
47
+ "status": "pending",
48
+ "otp_verified_at": null
49
+ }
48
50
  },
49
51
  "errors": {
50
- "heading": null,
51
- "message": null,
52
- "details": {}
52
+ "heading": null,
53
+ "message": null,
54
+ "details": {}
53
55
  }
54
56
  }
55
57
  eos
@@ -0,0 +1,67 @@
1
+ <%
2
+
3
+ api_title = "Positive Case - 2 - should register and reuse an existing registration information"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "country_id": "1",
8
+ "city_id": "2",
9
+ "dialing_prefix": "+91",
10
+ "mobile_number": "<ALREADY REGISTERED MOBILE NUMBER>",
11
+ "uuid": "<NEW UUID>",
12
+ "device_token": "<NEW DEVICE TOKEN>",
13
+ "device_name": "Apple iPhone",
14
+ "device_type": "iPhone 7 Plus",
15
+ "operating_system": "iOS",
16
+ "software_version": "iOS 11.2.2"
17
+ }
18
+ eos
19
+
20
+ api_output = <<-eos
21
+ {
22
+ "success": true,
23
+ "alert": {
24
+ "heading": "An OTP has been sent to you",
25
+ "message": "Check your mobile for new message from us."
26
+ },
27
+ "data": {
28
+ "registration": {
29
+ "id": 5,
30
+ "user_id": null,
31
+ "country_id": 1,
32
+ "city_id": null,
33
+ "dialing_prefix": "+91",
34
+ "mobile_number": "501370321",
35
+ "status": "verified"
36
+ },
37
+ "device": {
38
+ "id": 6,
39
+ "user_id": null,
40
+ "registration_id": 5,
41
+ "uuid": "jh01u2g01h301h21h232",
42
+ "device_token": "0182y3b28107b31",
43
+ "device_name": "Apple iPhone",
44
+ "device_type": "iPhone 7 Plus",
45
+ "operating_system": "iOS",
46
+ "software_version": "iOS 11.2.2",
47
+ "status": "pending",
48
+ "otp_verified_at": null
49
+ }
50
+ },
51
+ "errors": {
52
+ "heading": null,
53
+ "message": null,
54
+ "details": {}
55
+ }
56
+ }
57
+ eos
58
+
59
+ %>
60
+
61
+ <%= render partial: "kuppayam/api/docs/example", locals: {
62
+ negative_case: false,
63
+ example_id: "pos_case_2",
64
+ api_title: api_title,
65
+ api_input: api_input,
66
+ api_output: api_output
67
+ } %>
@@ -0,0 +1,68 @@
1
+ <%
2
+
3
+ api_title = "Positive Case - 3 - should register and reuse an existing registration & device information"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "country_id": "1",
8
+ "city_id": "2",
9
+ "dialing_prefix": "+91",
10
+ "mobile_number": "<ALREADY REGISTERED MOBILE NUMBER>",
11
+ "uuid": "<ALREADY REGISTERED UUID>",
12
+ "device_token": "<ALREADY REGISTERED TOKEN>",
13
+ "device_name": "Apple iPhone",
14
+ "device_type": "iPhone 7 Plus",
15
+ "operating_system": "iOS",
16
+ "software_version": "iOS 11.2.2"
17
+ }
18
+ eos
19
+
20
+ api_output = <<-eos
21
+ {
22
+ "success": true,
23
+ "alert": {
24
+ "heading": "An OTP has been sent to you",
25
+ "message": "Check your mobile for new message from us."
26
+ },
27
+ "data": {
28
+ "registration": {
29
+ "id": 5,
30
+ "user_id": null,
31
+ "country_id": 1,
32
+ "city_id": null,
33
+ "dialing_prefix": "+91",
34
+ "mobile_number": "501370321",
35
+ "status": "verified"
36
+ },
37
+ "device": {
38
+ "id": 6,
39
+ "user_id": null,
40
+ "registration_id": 5,
41
+ "uuid": "jh01u2g01h301h21h232",
42
+ "device_token": "0182y3b28107b31",
43
+ "device_name": "Apple iPhone",
44
+ "device_type": "iPhone 7 Plus",
45
+ "operating_system": "iOS",
46
+ "software_version": "iOS 11.2.2",
47
+ "api_token": "257720f0d84c233d49b2490b240e0b10",
48
+ "status": "verified",
49
+ "otp_verified_at": null
50
+ }
51
+ },
52
+ "errors": {
53
+ "heading": null,
54
+ "message": null,
55
+ "details": {}
56
+ }
57
+ }
58
+ eos
59
+
60
+ %>
61
+
62
+ <%= render partial: "kuppayam/api/docs/example", locals: {
63
+ negative_case: false,
64
+ example_id: "pos_case_3",
65
+ api_title: api_title,
66
+ api_input: api_input,
67
+ api_output: api_output
68
+ } %>
@@ -1,6 +1,6 @@
1
1
  <%
2
2
 
3
- api_title = "Negative Case - 1 - should set proper errors if no input is given"
3
+ api_title = "Negative Case - 1 - should respond with proper errors if no parameters are passed"
4
4
 
5
5
  api_input = <<-eos
6
6
  {}
@@ -10,10 +10,10 @@ api_output = <<-eos
10
10
  {
11
11
  "success": false,
12
12
  "errors": {
13
- "heading": "Unexpected Failure",
14
- "message": "We're sorry, but something went wrong (500)",
13
+ "heading": "The mobile number is not registered",
14
+ "message": "Resending OTP Failed. Check if the mobile number entered is valid",
15
15
  "details": {
16
- "uuid": "is invalid"
16
+ "mobile_number": "is invalid"
17
17
  }
18
18
  }
19
19
  }
@@ -0,0 +1,34 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 2 - should respond with proper errors if mobile number is not registered"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "dialing_prefix": "+91",
8
+ "mobile_number": "<NEW MOBILE NUMBER>",
9
+ "uuid": "<NEW UUID>"
10
+ }
11
+ eos
12
+
13
+ api_output = <<-eos
14
+ {
15
+ "success": false,
16
+ "errors": {
17
+ "heading": "The mobile number is not registered",
18
+ "message": "Resending OTP Failed. Check if the mobile number entered is valid",
19
+ "details": {
20
+ "mobile_number": "is invalid"
21
+ }
22
+ }
23
+ }
24
+ eos
25
+
26
+ %>
27
+
28
+ <%= render partial: "kuppayam/api/docs/example", locals: {
29
+ negative_case: true,
30
+ example_id: "neg_case_2",
31
+ api_title: api_title,
32
+ api_input: api_input,
33
+ api_output: api_output
34
+ } %>
@@ -0,0 +1,34 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 3 - should respond with proper errors if uuid is not registered"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "dialing_prefix": "+91",
8
+ "mobile_number": "<REGISTERED MOBILE NUMBER>",
9
+ "uuid": "<NEW UUID>"
10
+ }
11
+ eos
12
+
13
+ api_output = <<-eos
14
+ {
15
+ "success": false,
16
+ "errors": {
17
+ "heading": "The device is not registered",
18
+ "message": "Resending OTP Failed. Check if the UUID entered is valid",
19
+ "details": {
20
+ "uuid": "is invalid"
21
+ }
22
+ }
23
+ }
24
+ eos
25
+
26
+ %>
27
+
28
+ <%= render partial: "kuppayam/api/docs/example", locals: {
29
+ negative_case: true,
30
+ example_id: "neg_case_3",
31
+ api_title: api_title,
32
+ api_input: api_input,
33
+ api_output: api_output
34
+ } %>
@@ -0,0 +1,32 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 4 - should respond with proper errors if the device is blocked"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "dialing_prefix": "+91",
8
+ "mobile_number": "<REGISTERED MOBILE NUMBER>",
9
+ "uuid": "<BLOCKED DEVICE UUID>"
10
+ }
11
+ eos
12
+
13
+ api_output = <<-eos
14
+ {
15
+ "success": false,
16
+ "errors": {
17
+ "heading": "This device is blocked",
18
+ "message": "You must have done some mal-practices",
19
+ "details": {}
20
+ }
21
+ }
22
+ eos
23
+
24
+ %>
25
+
26
+ <%= render partial: "kuppayam/api/docs/example", locals: {
27
+ negative_case: true,
28
+ example_id: "neg_case_4",
29
+ api_title: api_title,
30
+ api_input: api_input,
31
+ api_output: api_output
32
+ } %>
@@ -1,23 +1,19 @@
1
1
  <%
2
2
 
3
- api_title = "Negative Case - 1 - should set proper errors if no input is given"
3
+ api_title = "Negative Case - 1 - should respond with proper errors if no parameters are passed"
4
4
 
5
5
  api_input = <<-eos
6
- {
7
- "uuid": "asd907asdba78sbda",
8
- "mobile_number": "292991230",
9
- "dialing_prefix": "+91"
10
- }
6
+ {}
11
7
  eos
12
8
 
13
9
  api_output = <<-eos
14
10
  {
15
11
  "success": false,
16
12
  "errors": {
17
- "heading": "OTP verification was failed",
18
- "message": "Make sure that you enter the OTP correctly.",
13
+ "heading": "The mobile number is not registered",
14
+ "message": "Resending OTP Failed. Check if the mobile number entered is valid",
19
15
  "details": {
20
- "otp": "doesn't match with our database"
16
+ "mobile_number": "is invalid"
21
17
  }
22
18
  }
23
19
  }
@@ -1,12 +1,13 @@
1
1
  <%
2
2
 
3
- api_title = "Negative Case - 2 - should set proper errors when device information is missing"
3
+ api_title = "Negative Case - 2 - should respond with proper errors if mobile number is not registered"
4
4
 
5
5
  api_input = <<-eos
6
6
  {
7
- "country_id": "1",
8
- "dialing_prefix": "+92",
9
- "mobile_number": "501370323"
7
+ "otp": "11111",
8
+ "dialing_prefix": "+91",
9
+ "mobile_number": "<NEW MOBILE NUMBER>",
10
+ "uuid": "<NEW UUID>"
10
11
  }
11
12
  eos
12
13
 
@@ -14,15 +15,10 @@ api_output = <<-eos
14
15
  {
15
16
  "success": false,
16
17
  "errors": {
17
- "heading": "Registring new mobile number FAILED",
18
- "message": "Check if all mandatory details are passed. Refer the error details for technical information",
18
+ "heading": "The mobile number is not registered",
19
+ "message": "Resending OTP Failed. Check if the mobile number entered is valid",
19
20
  "details": {
20
- "uuid": [
21
- "can't be blank"
22
- ],
23
- "device_token": [
24
- "can't be blank"
25
- ]
21
+ "mobile_number": "is invalid"
26
22
  }
27
23
  }
28
24
  }
@@ -1,13 +1,13 @@
1
1
  <%
2
2
 
3
- api_title = "Negative Case - 3 - should respond with proper errors if the device is blocked"
3
+ api_title = "Negative Case - 3 - should respond with proper errors if uuid is not registered"
4
4
 
5
5
  api_input = <<-eos
6
6
  {
7
7
  "otp": "11111",
8
- "uuid": "asd907asdba78sbda",
9
- "mobile_number": "292991230",
10
- "dialing_prefix": "+91"
8
+ "dialing_prefix": "+91",
9
+ "mobile_number": "<REGISTERED MOBILE NUMBER>",
10
+ "uuid": "<NEW UUID>"
11
11
  }
12
12
  eos
13
13
 
@@ -15,9 +15,11 @@ api_output = <<-eos
15
15
  {
16
16
  "success": false,
17
17
  "errors": {
18
- "heading": "This device is blocked.",
19
- "message": "You must have done some mal-practices.",
20
- "details": {}
18
+ "heading": "The device is not registered",
19
+ "message": "Resending OTP Failed. Check if the UUID entered is valid",
20
+ "details": {
21
+ "uuid": "is invalid"
22
+ }
21
23
  }
22
24
  }
23
25
  eos
@@ -0,0 +1,33 @@
1
+ <%
2
+
3
+ api_title = "Negative Case - 4 - should respond with proper errors if the device is blocked"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "otp": "11111",
8
+ "dialing_prefix": "+91",
9
+ "mobile_number": "<REGISTERED MOBILE NUMBER>",
10
+ "uuid": "<BLOCKED DEVICE UUID>"
11
+ }
12
+ eos
13
+
14
+ api_output = <<-eos
15
+ {
16
+ "success": false,
17
+ "errors": {
18
+ "heading": "This device is blocked",
19
+ "message": "You must have done some mal-practices",
20
+ "details": {}
21
+ }
22
+ }
23
+ eos
24
+
25
+ %>
26
+
27
+ <%= render partial: "kuppayam/api/docs/example", locals: {
28
+ negative_case: true,
29
+ example_id: "neg_case_4",
30
+ api_title: api_title,
31
+ api_input: api_input,
32
+ api_output: api_output
33
+ } %>
@@ -5,8 +5,8 @@ api_title = "Positive Case - 1 - should verify an otp verification request from
5
5
  api_input = <<-eos
6
6
  {
7
7
  "otp": "11111",
8
- "uuid": "90a0dadsand",
9
- "mobile_number": "9102993912",
8
+ "uuid": "<PENDING UUID>",
9
+ "mobile_number": "<PENDING MOBILE NUMBER>",
10
10
  "dialing_prefix": "+91"
11
11
  }
12
12
  eos
@@ -16,11 +16,9 @@ api_output = <<-eos
16
16
  "success": true,
17
17
  "alert": {
18
18
  "heading": "OTP was verified succesfully",
19
- "message": "Store and use the API token for further communication"
19
+ "message": "You may need to accept the terms and conditions to get the API token if you have not yet finised the registration"
20
20
  },
21
- "data": {
22
- "api_token": "cfc0eb18c8f3b5922e702f1e10437fa1"
23
- }
21
+ "data": {}
24
22
  }
25
23
  eos
26
24
 
@@ -0,0 +1,35 @@
1
+ <%
2
+
3
+ api_title = "Positive Case - 2 - should verify the otp if the device is verified, tac is accpted and return the api token"
4
+
5
+ api_input = <<-eos
6
+ {
7
+ "otp": "11111",
8
+ "uuid": "<REGISTERED UUID>",
9
+ "mobile_number": "<REGISTERED MOBILE NUMBER>",
10
+ "dialing_prefix": "+91"
11
+ }
12
+ eos
13
+
14
+ api_output = <<-eos
15
+ {
16
+ "success": true,
17
+ "alert": {
18
+ "heading": "OTP was verified succesfully",
19
+ "message": "You may need to accept the terms and conditions to get the API token if you have not yet finised the registration"
20
+ },
21
+ "data": {
22
+ "api_token": "cfc0eb18c8f3b5922e702f1e10437fa1"
23
+ }
24
+ }
25
+ eos
26
+
27
+ %>
28
+
29
+ <%= render partial: "kuppayam/api/docs/example", locals: {
30
+ negative_case: false,
31
+ example_id: "pos_case_2",
32
+ api_title: api_title,
33
+ api_input: api_input,
34
+ api_output: api_output
35
+ } %>
@@ -3,37 +3,79 @@ en:
3
3
  general:
4
4
  heading: "Invalid API Token"
5
5
  message: "Use the API Token you have received after accepting the terms and agreement"
6
- mobile_registration:
6
+ register:
7
7
  device_blocked:
8
8
  heading: "This device is blocked"
9
9
  message: "You must have done some mal-practices"
10
- invalid_inputs:
11
- heading: "Registring new mobile number FAILED"
12
- message: "Check if all mandatory details are passed. Refer the error details for technical information"
13
10
  otp_sent:
14
11
  heading: "An OTP has been sent to you"
15
12
  message: "Check your mobile for new message from us"
13
+ otp_not_sent:
14
+ heading: "OTP was not sent"
15
+ message: "There was some technical glitch and OTP was not sent. Try after some time"
16
+ invalid_inputs:
17
+ heading: "Registring new mobile number FAILED"
18
+ message: "Check if all mandatory details are passed. Refer the error details for technical information"
19
+ resend_otp:
20
+ device_blocked:
21
+ heading: "This device is blocked"
22
+ message: "You must have done some mal-practices"
16
23
  new_otp_sent:
17
24
  heading: "An new OTP has been sent to you"
18
25
  message: "Check your mobile for new message from us"
19
26
  otp_not_sent:
20
- heading: "OTP was not sent"
21
- message: "There was some technical glitch and OTP was not sent. Try after some time"
27
+ heading: "OTP sent failed"
28
+ message: "Check if all the inputs are valid"
22
29
  otp_not_matching:
23
30
  heading: "OTP verification was failed"
24
- message: "Make sure that you enter the OTP correctly"
31
+ message: "Make sure that you enter the OTP correctly"
32
+ mobile_number_not_registered:
33
+ heading: "The mobile number is not registered"
34
+ message: "Resending OTP Failed. Check if the mobile number entered is valid"
35
+ device_not_registered:
36
+ heading: "The device is not registered"
37
+ message: "Resending OTP Failed. Check if the UUID entered is valid"
38
+ verify_otp:
39
+ device_blocked:
40
+ heading: "This device is blocked"
41
+ message: "You must have done some mal-practices"
42
+ device_verified:
43
+ heading: "OTP sent failed"
44
+ message: "This device may be already verified"
45
+ otp_not_matching:
46
+ heading: "OTP verification was failed"
47
+ message: "Make sure that you enter the OTP correctly"
48
+ mobile_number_not_registered:
49
+ heading: "The mobile number is not registered"
50
+ message: "Verifying OTP Failed. Check if the mobile number entered is valid"
51
+ device_not_registered:
52
+ heading: "The device is not registered"
53
+ message: "Verifying OTP Failed. Check if the UUID entered is valid"
25
54
  verification_failed:
26
55
  heading: "OTP verification was failed"
27
56
  message: "Check if you have properly given the OTP along with dialing prefix, mobile number & UUID"
28
57
  verification_success:
29
58
  heading: "OTP was verified succesfully"
30
- message: "Now, accept the terms and conditions to finish the registration process and get API token"
59
+ message: "You may need to accept the terms and conditions to get the API token if you have not yet finised the registration"
60
+ accept_tac:
31
61
  tac_accepted:
32
62
  heading: "You have successfully accepted the Terms & Conditions. Proceed with Registration process if any"
33
63
  message: "Store and use the API token for further communication"
34
64
  tac_not_accepted:
35
65
  heading: "You have not accepted the Terms & Conditions. Registration is complete only if you accept the T&C"
36
66
  message: "Accept the T&C to finish the Registration. Pass true"
67
+ device_blocked:
68
+ heading: "This device is blocked"
69
+ message: "You must have done some mal-practices"
70
+ device_pending:
71
+ heading: "This device is not verified"
72
+ message: "You need to verify this device before you can accept the terms and conditions"
73
+ mobile_number_not_registered:
74
+ heading: "The mobile number is not registered"
75
+ message: "Accepting T&C Failed. Check if the mobile number entered is valid"
76
+ device_not_registered:
77
+ heading: "The device is not registered"
78
+ message: "Accepting T&C Failed. Check if the UUID entered is valid"
37
79
  profile:
38
80
  user_already_exists:
39
81
  heading: "A profile already exists for the mobile number you have provided"