usman 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/usman/api/v1/docs_controller.rb +84 -0
- data/app/controllers/usman/api/v1/profile_controller.rb +27 -2
- data/app/controllers/usman/api/v1/profile_picture_controller.rb +178 -0
- data/app/serializers/profile_picture_serializer.rb +19 -0
- data/app/serializers/profile_serializer.rb +6 -0
- data/app/uploaders/feature_image_uploader.rb +1 -0
- data/app/uploaders/profile_picture_uploader.rb +4 -0
- data/app/views/kuppayam/api/docs/_navigation.html.erb +24 -0
- data/app/views/usman/api/v1/docs/base64_profile_picture/_neg_case_1.html.erb +27 -0
- data/app/views/usman/api/v1/docs/base64_profile_picture/_neg_case_2.html.erb +28 -0
- data/app/views/usman/api/v1/docs/base64_profile_picture/_pos_case_1.html.erb +36 -0
- data/app/views/usman/api/v1/docs/create_profile/_pos_case_1.html.erb +15 -14
- data/app/views/usman/api/v1/docs/destroy_profile_picture/_neg_case_1.html.erb +27 -0
- data/app/views/usman/api/v1/docs/destroy_profile_picture/_neg_case_2.html.erb +27 -0
- data/app/views/usman/api/v1/docs/destroy_profile_picture/_pos_case_1.html.erb +27 -0
- data/app/views/usman/api/v1/docs/profile/_neg_case_1.html.erb +34 -0
- data/app/views/usman/api/v1/docs/profile/_neg_case_2.html.erb +27 -0
- data/app/views/usman/api/v1/docs/profile/_pos_case_1.html.erb +39 -0
- data/app/views/usman/api/v1/docs/profile_picture/_neg_case_1.html.erb +27 -0
- data/app/views/usman/api/v1/docs/profile_picture/_neg_case_2.html.erb +28 -0
- data/app/views/usman/api/v1/docs/profile_picture/_neg_case_3.html.erb +27 -0
- data/app/views/usman/api/v1/docs/profile_picture/_pos_case_1.html.erb +36 -0
- data/app/views/usman/api/v1/docs/update_profile/_neg_case_2.html.erb +3 -10
- data/app/views/usman/api/v1/docs/update_profile/_neg_case_3.html.erb +1 -1
- data/app/views/usman/api/v1/docs/update_profile/_pos_case_1.html.erb +7 -13
- data/app/views/usman/api/v1/docs/verify_otp/_pos_case_2.html.erb +2 -1
- data/config/locales/usman/api.en.yml +20 -1
- data/config/routes.rb +12 -0
- data/lib/usman/version.rb +1 -1
- metadata +65 -24
- data/app/uploaders/image_uploader.rb +0 -90
@@ -0,0 +1,36 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - should upload a profile picture in base64 format"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": true,
|
12
|
+
"alert": {
|
13
|
+
"heading": "User/Profile Image was saved successfully",
|
14
|
+
"message": "You may now use the URL to download the image in future"
|
15
|
+
},
|
16
|
+
"data": {
|
17
|
+
"id": 8,
|
18
|
+
"created_at": "21-09-2017 13:02:45",
|
19
|
+
"profile_id": 6,
|
20
|
+
"image_large_path": "/uploads/profile_pictures/8/large_profile_picture.jpg",
|
21
|
+
"image_medium_path": "/uploads/profile_pictures/8/medium_profile_picture.jpg",
|
22
|
+
"image_small_path": "/uploads/profile_pictures/8/small_profile_picture.jpg",
|
23
|
+
"image_tiny_path": "/uploads/profile_pictures/8/tiny_profile_picture.jpg"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
eos
|
27
|
+
|
28
|
+
%>
|
29
|
+
|
30
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
31
|
+
negative_case: false,
|
32
|
+
example_id: "pos_case_1",
|
33
|
+
api_title: api_title,
|
34
|
+
api_input: api_input,
|
35
|
+
api_output: api_output
|
36
|
+
} %>
|
@@ -21,20 +21,21 @@ api_output = <<-eos
|
|
21
21
|
"message": "You may access the profile API with API token to get the profile details in future"
|
22
22
|
},
|
23
23
|
"data": {
|
24
|
-
"
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
"id": 9,
|
25
|
+
"name": "Nayan Tara",
|
26
|
+
"gender": "female",
|
27
|
+
"date_of_birth": "1984-10-27",
|
28
|
+
"username": "d0dca578",
|
29
|
+
"email": "nayan.tara@yopmail.com",
|
30
|
+
"phone": null
|
31
|
+
"profile_picture":
|
32
|
+
{
|
33
|
+
"id": 1,
|
34
|
+
"created_at": "22-09-2017 07:32:51",
|
35
|
+
"user_id": 1,
|
36
|
+
"image_large_path": "/uploads/profile_pictures/1/large_test.jpeg",
|
37
|
+
"image_small_path": "/uploads/profile_pictures/1/small_test.jpeg"}}
|
38
|
+
}
|
38
39
|
}
|
39
40
|
eos
|
40
41
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if no api token"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "Invalid API Token",
|
14
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: true,
|
23
|
+
example_id: "neg_case_1",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 2 - should set proper errors if the profile doesn't exists"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "Profile doesn't exists for the mobile number you have provided",
|
14
|
+
"message": "You are trying to create a profile once again when you already have a profile. Use Profile API with your API Token, to get your profile details and use them instead of creating a new one."
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: true,
|
23
|
+
example_id: "neg_case_2",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - should delete a profile picture for a user"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": true,
|
12
|
+
"alert": {
|
13
|
+
"heading": "User/Profile Image was deleted successfully",
|
14
|
+
"message": "You may use Profile Picture Upload API to add one again"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: false,
|
23
|
+
example_id: "pos_case_1",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if api token is not present"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{
|
7
|
+
"name": "Name",
|
8
|
+
"gender": "male",
|
9
|
+
"date_of_birth": "10/10/1980",
|
10
|
+
"email": "name@domain.com",
|
11
|
+
"country_id": "1",
|
12
|
+
"city_id": "2"
|
13
|
+
}
|
14
|
+
eos
|
15
|
+
|
16
|
+
api_output = <<-eos
|
17
|
+
{
|
18
|
+
"success": false,
|
19
|
+
"errors": {
|
20
|
+
"heading": "Invalid API Token",
|
21
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
eos
|
25
|
+
|
26
|
+
%>
|
27
|
+
|
28
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
29
|
+
negative_case: true,
|
30
|
+
example_id: "neg_case_1",
|
31
|
+
api_title: api_title,
|
32
|
+
api_input: api_input,
|
33
|
+
api_output: api_output
|
34
|
+
} %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 2 - should set proper errors if the profile didn't exist"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "A profile doesn't exists for the mobile number you have provided",
|
14
|
+
"message": "You are trying to u a profile once again when you already have a profile. Use Profile API with your API Token, to get your profile details and use them instead of creating a new one."
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: true,
|
23
|
+
example_id: "neg_case_2",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - should return the profile details along with picture"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": true,
|
12
|
+
"data": {
|
13
|
+
"id": 9,
|
14
|
+
"name": "Nayan Tara",
|
15
|
+
"gender": "female",
|
16
|
+
"date_of_birth": "1984-10-27",
|
17
|
+
"username": "d0dca578",
|
18
|
+
"email": "nayan.tara@yopmail.com",
|
19
|
+
"phone": null,
|
20
|
+
"profile_picture": {
|
21
|
+
"id": 8,
|
22
|
+
"profile_id": 9,
|
23
|
+
"created_at": "21-09-2017 13:02:45",
|
24
|
+
"image_large_path": "/uploads/profile_pictures/8/large_profile_picture.jpg",
|
25
|
+
"image_small_path": "/uploads/profile_pictures/8/small_profile_picture.jpg"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
eos
|
30
|
+
|
31
|
+
%>
|
32
|
+
|
33
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
34
|
+
negative_case: false,
|
35
|
+
example_id: "pos_case_1",
|
36
|
+
api_title: api_title,
|
37
|
+
api_input: api_input,
|
38
|
+
api_output: api_output
|
39
|
+
} %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if no api token"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "Invalid API Token",
|
14
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: true,
|
23
|
+
example_id: "neg_case_1",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should respond with proper errors for invalid arguments"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "Saving user/profile image was failed",
|
14
|
+
"message": "Make sure that the arguments are passed according to the API documentation. Please check the API Documentation for more details.",
|
15
|
+
"details": "Image can't be blank"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
eos
|
19
|
+
|
20
|
+
%>
|
21
|
+
|
22
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
23
|
+
negative_case: true,
|
24
|
+
example_id: "neg_case_2",
|
25
|
+
api_title: api_title,
|
26
|
+
api_input: api_input,
|
27
|
+
api_output: api_output
|
28
|
+
} %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 2 - should set proper errors if invalid image data is passed"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{ "image": "<upload a file format which is not supported. e.g: csv>"}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": false,
|
12
|
+
"errors": {
|
13
|
+
"heading": "Saving user/profile image was failed",
|
14
|
+
"message": "Make sure that the arguments are passed according to the API documentation. Please check the API Documentation for more details."
|
15
|
+
}
|
16
|
+
}
|
17
|
+
eos
|
18
|
+
|
19
|
+
%>
|
20
|
+
|
21
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
|
+
negative_case: true,
|
23
|
+
example_id: "neg_case_3",
|
24
|
+
api_title: api_title,
|
25
|
+
api_input: api_input,
|
26
|
+
api_output: api_output
|
27
|
+
} %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - should upload a profile picture"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{}
|
7
|
+
eos
|
8
|
+
|
9
|
+
api_output = <<-eos
|
10
|
+
{
|
11
|
+
"success": true,
|
12
|
+
"alert": {
|
13
|
+
"heading": "User/Profile Image was saved successfully",
|
14
|
+
"message": "You may now use the URL to download the image in future"
|
15
|
+
},
|
16
|
+
"data": {
|
17
|
+
"id": 8,
|
18
|
+
"created_at": "21-09-2017 13:02:45",
|
19
|
+
"profile_picture_id" :6,
|
20
|
+
"image_large_path": "/uploads/profile_pictures/8/large_profile_picture.jpg",
|
21
|
+
"image_medium_path": "/uploads/profile_pictures/8/medium_profile_picture.jpg",
|
22
|
+
"image_small_path": "/uploads/profile_pictures/8/small_profile_picture.jpg",
|
23
|
+
"image_tiny_path": "/uploads/profile_pictures/8/tiny_profile_picture.jpg"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
eos
|
27
|
+
|
28
|
+
%>
|
29
|
+
|
30
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
31
|
+
negative_case: false,
|
32
|
+
example_id: "pos_case_1",
|
33
|
+
api_title: api_title,
|
34
|
+
api_input: api_input,
|
35
|
+
api_output: api_output
|
36
|
+
} %>
|
@@ -1,23 +1,16 @@
|
|
1
1
|
<%
|
2
2
|
|
3
|
-
api_title = "Negative Case - 2 - should set proper errors if the profile
|
3
|
+
api_title = "Negative Case - 2 - should set proper errors if the profile doesn't exist"
|
4
4
|
|
5
5
|
api_input = <<-eos
|
6
|
-
{
|
7
|
-
"name": "Name",
|
8
|
-
"gender": "male",
|
9
|
-
"date_of_birth": "10/10/1980",
|
10
|
-
"email": "name@domain.com",
|
11
|
-
"country_id": "1",
|
12
|
-
"city_id": "2"
|
13
|
-
}
|
6
|
+
{}
|
14
7
|
eos
|
15
8
|
|
16
9
|
api_output = <<-eos
|
17
10
|
{
|
18
11
|
"success": false,
|
19
12
|
"errors": {
|
20
|
-
"heading": "A profile
|
13
|
+
"heading": "A profile doesn't exists for the mobile number you have provided",
|
21
14
|
"message": "You are trying to create a profile once again when you already have a profile. Use Profile API with your API Token, to get your profile details and use them instead of creating a new one."
|
22
15
|
}
|
23
16
|
}
|
@@ -10,7 +10,7 @@ api_output = <<-eos
|
|
10
10
|
{
|
11
11
|
"success": false,
|
12
12
|
"errors": {
|
13
|
-
"heading": "
|
13
|
+
"heading": "Updating Profile Failed",
|
14
14
|
"message": "Check if all mandatory details are passed. Refer the error details for technical information",
|
15
15
|
"details": {
|
16
16
|
"name": ["can't be blank", "is too short (minimum is 3 characters)"]
|
@@ -21,19 +21,13 @@ api_output = <<-eos
|
|
21
21
|
"message": "You may access the profile API with API token to get the profile details in future"
|
22
22
|
},
|
23
23
|
"data": {
|
24
|
-
"
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
"super_admin": "",
|
32
|
-
"token_created_at": "",
|
33
|
-
"registration_id": "",
|
34
|
-
"gender": "male",
|
35
|
-
"date_of_birth": "1954-10-27"
|
36
|
-
}
|
24
|
+
"id": 9,
|
25
|
+
"name": "Nayan Tara",
|
26
|
+
"gender": "female",
|
27
|
+
"date_of_birth": "1984-10-27",
|
28
|
+
"username": "d0dca578",
|
29
|
+
"email": "nayan.tara@yopmail.com",
|
30
|
+
"phone": null
|
37
31
|
}
|
38
32
|
}
|
39
33
|
eos
|