pattana 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/pattana/api/v1/cities_controller.rb +8 -4
- data/app/controllers/pattana/api/v1/countries_controller.rb +4 -2
- data/app/controllers/pattana/api/v1/docs_controller.rb +3 -3
- data/app/controllers/pattana/api/v1/regions_controller.rb +4 -2
- data/app/models/city.rb +11 -8
- data/app/serializers/city_preview_serializer.rb +8 -0
- data/app/serializers/country_preview_serializer.rb +4 -0
- data/app/serializers/region_preview_serializer.rb +6 -0
- data/app/views/pattana/api/v1/docs/cities_in_a_country/_pos_case_1.html.erb +26 -28
- data/app/views/pattana/api/v1/docs/cities_in_a_country/_pos_case_2.html.erb +63 -0
- data/app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_1.html.erb +2 -2
- data/app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_2.html.erb +2 -2
- data/app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_3.html.erb +2 -2
- data/app/views/pattana/api/v1/docs/cities_in_a_region/_pos_case_1.html.erb +27 -29
- data/app/views/pattana/api/v1/docs/cities_in_a_region/_pos_case_2.html.erb +31 -31
- data/app/views/pattana/api/v1/docs/countries/_pos_case_1.html.erb +4 -46
- data/app/views/pattana/api/v1/docs/countries/_pos_case_2.html.erb +50 -0
- data/app/views/pattana/api/v1/docs/regions/_pos_case_1.html.erb +30 -21
- data/app/views/pattana/api/v1/docs/regions/_pos_case_2.html.erb +65 -0
- data/lib/pattana/engine.rb +1 -0
- data/lib/pattana/version.rb +1 -1
- metadata +49 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adfb07bf5da7444615c50e71d6c94544f2e0f1e3
|
4
|
+
data.tar.gz: 7551cd69fa0253398532697b39d096a842bb6791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c80ecfda52ba2a395d52d87aa9f274e60435e9b10f8e029efd1e86cd6fd5069d43ced51b917e2aaed230ef772901e20da4dd2ac8d7a08b18eaf11226b9383125
|
7
|
+
data.tar.gz: fe782b0e033bf664a55a340ace4d418806c1a430d48a0cd6c81b9bb16ede93ca53490871627ad9433aa971d4a1a6e44200a7971fc21239bc8e8a913fddb7dd4b
|
@@ -7,9 +7,11 @@ module Pattana
|
|
7
7
|
proc_code = Proc.new do
|
8
8
|
@country = Country.find_by_id(params[:country_id])
|
9
9
|
if @country
|
10
|
-
@
|
10
|
+
@relation = @country.cities.includes(:region, :country).where("cities.show_in_api is true").order("cities.name ASC")
|
11
|
+
@relation = @relation.search(params[:q]) if params[:q]
|
12
|
+
@cities = @relation.all
|
13
|
+
@data = ActiveModelSerializers::SerializableResource.new(@cities, each_serializer: CityPreviewSerializer)
|
11
14
|
@success = true
|
12
|
-
@data = @cities
|
13
15
|
else
|
14
16
|
@success = false
|
15
17
|
@errors = {
|
@@ -28,9 +30,11 @@ module Pattana
|
|
28
30
|
@country = Country.find_by_id(params[:country_id])
|
29
31
|
if @country
|
30
32
|
if @region.country_id == @country.id
|
31
|
-
@
|
33
|
+
@relation = @region.cities.includes(:region, :country).where("cities.show_in_api is true").order("cities.name ASC")
|
34
|
+
@relation = @relation.search(params[:q]) if params[:q]
|
35
|
+
@cities = @relation.all
|
36
|
+
@data = ActiveModelSerializers::SerializableResource.new(@cities, each_serializer: CityPreviewSerializer)
|
32
37
|
@success = true
|
33
|
-
@data = @cities
|
34
38
|
else
|
35
39
|
@success = false
|
36
40
|
@errors = {
|
@@ -5,9 +5,11 @@ module Pattana
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
proc_code = Proc.new do
|
8
|
-
@
|
8
|
+
@relation = Country.where("countries.show_in_api is true").order("countries.name ASC")
|
9
|
+
@relation = @relation.search(params[:q]) if params[:q]
|
10
|
+
@countries = @relation.all
|
11
|
+
@data = ActiveModelSerializers::SerializableResource.new(@countries, each_serializer: CountryPreviewSerializer)
|
9
12
|
@success = true
|
10
|
-
@data = @countries
|
11
13
|
end
|
12
14
|
render_json_response(proc_code)
|
13
15
|
end
|
@@ -18,7 +18,7 @@ module Pattana
|
|
18
18
|
}
|
19
19
|
|
20
20
|
@example_path = "pattana/api/v1/docs/"
|
21
|
-
@examples = ["pos_case_1"]
|
21
|
+
@examples = ["pos_case_1", "pos_case_2"]
|
22
22
|
|
23
23
|
set_nav("docs/countries")
|
24
24
|
|
@@ -42,7 +42,7 @@ module Pattana
|
|
42
42
|
}
|
43
43
|
|
44
44
|
@example_path = "pattana/api/v1/docs/"
|
45
|
-
@examples = ["pos_case_1", "neg_case_1"]
|
45
|
+
@examples = ["pos_case_1", "pos_case_2", "neg_case_1"]
|
46
46
|
|
47
47
|
set_nav("docs/regions")
|
48
48
|
|
@@ -66,7 +66,7 @@ module Pattana
|
|
66
66
|
}
|
67
67
|
|
68
68
|
@example_path = "pattana/api/v1/docs/"
|
69
|
-
@examples = ["pos_case_1", "neg_case_1"]
|
69
|
+
@examples = ["pos_case_1", "pos_case_2", "neg_case_1"]
|
70
70
|
|
71
71
|
set_nav("docs/cities_in_a_country")
|
72
72
|
|
@@ -7,9 +7,11 @@ module Pattana
|
|
7
7
|
proc_code = Proc.new do
|
8
8
|
@country = Country.find_by_id(params[:country_id])
|
9
9
|
if @country
|
10
|
-
@
|
10
|
+
@relation = @country.regions.includes(:country).where("regions.show_in_api is true").order("regions.name ASC")
|
11
|
+
@relation = @relation.search(params[:q]) if params[:q]
|
12
|
+
@regions = @relation.all
|
13
|
+
@data = ActiveModelSerializers::SerializableResource.new(@regions, each_serializer: RegionPreviewSerializer)
|
11
14
|
@success = true
|
12
|
-
@data = @regions
|
13
15
|
else
|
14
16
|
@success = false
|
15
17
|
@errors = {
|
data/app/models/city.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class City < Pattana::ApplicationRecord
|
2
2
|
|
3
|
+
include ActiveModel::Serializers::JSON
|
4
|
+
|
3
5
|
# Constants
|
4
6
|
EXCLUDED_JSON_ATTRIBUTES = [:created_at, :updated_at, :show_in_api]
|
5
7
|
|
@@ -17,15 +19,16 @@ class City < Pattana::ApplicationRecord
|
|
17
19
|
# Class Methods
|
18
20
|
# ------------------
|
19
21
|
|
22
|
+
# BACKUP - TODO - REMOVE - TBR
|
20
23
|
# Exclude some attributes info from json output.
|
21
|
-
def as_json(options={})
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
# def as_json(options={})
|
25
|
+
# options[:except] ||= EXCLUDED_JSON_ATTRIBUTES
|
26
|
+
# #options[:include] ||= []
|
27
|
+
# #options[:methods] = []
|
28
|
+
# #options[:methods] << :profile_image
|
29
|
+
# json = super(options)
|
30
|
+
# Hash[*json.map{|k, v| [k, v || ""]}.flatten]
|
31
|
+
# end
|
29
32
|
|
30
33
|
# Scopes Methods
|
31
34
|
|
@@ -13,26 +13,19 @@ api_output = <<-eos
|
|
13
13
|
{
|
14
14
|
"id": 21,
|
15
15
|
"name": "Abu Dhabi",
|
16
|
-
"
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"iso_code": "",
|
30
|
-
"country_id": 235,
|
31
|
-
"region_id": 11,
|
32
|
-
"latitude": "25.28812",
|
33
|
-
"longitude": "55.88157",
|
34
|
-
"population": 24716,
|
35
|
-
"priority": 1000
|
16
|
+
"priority": 1000,
|
17
|
+
"country": {
|
18
|
+
"id": 235,
|
19
|
+
"name": "United Arab Emirates",
|
20
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
21
|
+
"dialing_prefix": "971",
|
22
|
+
"priority": 1000
|
23
|
+
},
|
24
|
+
"region": {
|
25
|
+
"id": 14,
|
26
|
+
"name": "Abu Dhabi",
|
27
|
+
"priority": 1000
|
28
|
+
}
|
36
29
|
},
|
37
30
|
.
|
38
31
|
.
|
@@ -40,14 +33,19 @@ api_output = <<-eos
|
|
40
33
|
{
|
41
34
|
"id": 8,
|
42
35
|
"name": "Umm al Qaywayn",
|
43
|
-
"
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
"priority": 1000,
|
37
|
+
"country": {
|
38
|
+
"id": 235,
|
39
|
+
"name": "United Arab Emirates",
|
40
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
41
|
+
"dialing_prefix": "971",
|
42
|
+
"priority": 1000
|
43
|
+
},
|
44
|
+
"region": {
|
45
|
+
"id": 8,
|
46
|
+
"name": "Umm Al Quwain",
|
47
|
+
"priority": 1000
|
48
|
+
}
|
51
49
|
}]
|
52
50
|
}
|
53
51
|
eos
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 2 - should search cities in a country"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{
|
7
|
+
"q": "<Search Query>"
|
8
|
+
}
|
9
|
+
eos
|
10
|
+
|
11
|
+
api_output = <<-eos
|
12
|
+
{
|
13
|
+
"success": true,
|
14
|
+
"data": [
|
15
|
+
{
|
16
|
+
"id": 21,
|
17
|
+
"name": "Abu Dhabi",
|
18
|
+
"priority": 1000,
|
19
|
+
"country": {
|
20
|
+
"id": 235,
|
21
|
+
"name": "United Arab Emirates",
|
22
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
23
|
+
"dialing_prefix": "971",
|
24
|
+
"priority": 1000
|
25
|
+
},
|
26
|
+
"region": {
|
27
|
+
"id": 14,
|
28
|
+
"name": "Abu Dhabi",
|
29
|
+
"priority": 1000
|
30
|
+
}
|
31
|
+
},
|
32
|
+
.
|
33
|
+
.
|
34
|
+
.
|
35
|
+
{
|
36
|
+
"id": 8,
|
37
|
+
"name": "Umm al Qaywayn",
|
38
|
+
"priority": 1000,
|
39
|
+
"country": {
|
40
|
+
"id": 235,
|
41
|
+
"name": "United Arab Emirates",
|
42
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
43
|
+
"dialing_prefix": "971",
|
44
|
+
"priority": 1000
|
45
|
+
},
|
46
|
+
"region": {
|
47
|
+
"id": 8,
|
48
|
+
"name": "Umm Al Quwain",
|
49
|
+
"priority": 1000
|
50
|
+
}
|
51
|
+
}]
|
52
|
+
}
|
53
|
+
eos
|
54
|
+
|
55
|
+
%>
|
56
|
+
|
57
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
58
|
+
negative_case: false,
|
59
|
+
example_id: "pos_case_2",
|
60
|
+
api_title: api_title,
|
61
|
+
api_input: api_input,
|
62
|
+
api_output: api_output
|
63
|
+
} %>
|
@@ -10,8 +10,8 @@ api_output = <<-eos
|
|
10
10
|
{
|
11
11
|
"success": false,
|
12
12
|
"errors": {
|
13
|
-
|
14
|
-
|
13
|
+
"heading": "Invalid Country ID",
|
14
|
+
"message": "Pass a vaild Country ID to get the regions. Get Countries List along with their IDs from Countries API."
|
15
15
|
}
|
16
16
|
}
|
17
17
|
eos
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%
|
2
2
|
|
3
|
-
api_title = "Negative Case - 2 - should show errors if a valid
|
3
|
+
api_title = "Negative Case - 2 - should show errors if a valid region id is not passed"
|
4
4
|
|
5
5
|
api_input = <<-eos
|
6
6
|
{}
|
@@ -20,7 +20,7 @@ eos
|
|
20
20
|
|
21
21
|
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
22
|
negative_case: true,
|
23
|
-
example_id: "
|
23
|
+
example_id: "neg_case_2",
|
24
24
|
api_title: api_title,
|
25
25
|
api_input: api_input,
|
26
26
|
api_output: api_output
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%
|
2
2
|
|
3
|
-
api_title = "Negative Case - 3 - should show errors if
|
3
|
+
api_title = "Negative Case - 3 - should show errors if region id and country id doesn't match"
|
4
4
|
|
5
5
|
api_input = <<-eos
|
6
6
|
{}
|
@@ -20,7 +20,7 @@ eos
|
|
20
20
|
|
21
21
|
<%= render partial: "kuppayam/api/docs/example", locals: {
|
22
22
|
negative_case: true,
|
23
|
-
example_id: "
|
23
|
+
example_id: "neg_case_3",
|
24
24
|
api_title: api_title,
|
25
25
|
api_input: api_input,
|
26
26
|
api_output: api_output
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%
|
2
2
|
|
3
|
-
api_title = "Positive Case - 1 - should return all the cities in a
|
3
|
+
api_title = "Positive Case - 1 - should return all the cities in a region"
|
4
4
|
|
5
5
|
api_input = <<-eos
|
6
6
|
{}
|
@@ -13,26 +13,19 @@ api_output = <<-eos
|
|
13
13
|
{
|
14
14
|
"id": 21,
|
15
15
|
"name": "Abu Dhabi",
|
16
|
-
"
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"iso_code": "",
|
30
|
-
"country_id": 235,
|
31
|
-
"region_id": 11,
|
32
|
-
"latitude": "25.28812",
|
33
|
-
"longitude": "55.88157",
|
34
|
-
"population": 24716,
|
35
|
-
"priority": 1000
|
16
|
+
"priority": 1000,
|
17
|
+
"country": {
|
18
|
+
"id": 235,
|
19
|
+
"name": "United Arab Emirates",
|
20
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
21
|
+
"dialing_prefix": "971",
|
22
|
+
"priority": 1000
|
23
|
+
},
|
24
|
+
"region": {
|
25
|
+
"id": 14,
|
26
|
+
"name": "Abu Dhabi",
|
27
|
+
"priority": 1000
|
28
|
+
}
|
36
29
|
},
|
37
30
|
.
|
38
31
|
.
|
@@ -40,14 +33,19 @@ api_output = <<-eos
|
|
40
33
|
{
|
41
34
|
"id": 8,
|
42
35
|
"name": "Umm al Qaywayn",
|
43
|
-
"
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
"priority": 1000,
|
37
|
+
"country": {
|
38
|
+
"id": 235,
|
39
|
+
"name": "United Arab Emirates",
|
40
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
41
|
+
"dialing_prefix": "971",
|
42
|
+
"priority": 1000
|
43
|
+
},
|
44
|
+
"region": {
|
45
|
+
"id": 8,
|
46
|
+
"name": "Umm Al Quwain",
|
47
|
+
"priority": 1000
|
48
|
+
}
|
51
49
|
}]
|
52
50
|
}
|
53
51
|
eos
|
@@ -1,9 +1,11 @@
|
|
1
1
|
<%
|
2
2
|
|
3
|
-
api_title = "Positive Case -
|
3
|
+
api_title = "Positive Case - 1 - should search cities in a region"
|
4
4
|
|
5
5
|
api_input = <<-eos
|
6
|
-
{
|
6
|
+
{
|
7
|
+
"q": "<Search Query>"
|
8
|
+
}
|
7
9
|
eos
|
8
10
|
|
9
11
|
api_output = <<-eos
|
@@ -13,26 +15,19 @@ api_output = <<-eos
|
|
13
15
|
{
|
14
16
|
"id": 21,
|
15
17
|
"name": "Abu Dhabi",
|
16
|
-
"
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"iso_code": "",
|
30
|
-
"country_id": 235,
|
31
|
-
"region_id": 11,
|
32
|
-
"latitude": "25.28812",
|
33
|
-
"longitude": "55.88157",
|
34
|
-
"population": 24716,
|
35
|
-
"priority": 1000
|
18
|
+
"priority": 1000,
|
19
|
+
"country": {
|
20
|
+
"id": 235,
|
21
|
+
"name": "United Arab Emirates",
|
22
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
23
|
+
"dialing_prefix": "971",
|
24
|
+
"priority": 1000
|
25
|
+
},
|
26
|
+
"region": {
|
27
|
+
"id": 14,
|
28
|
+
"name": "Abu Dhabi",
|
29
|
+
"priority": 1000
|
30
|
+
}
|
36
31
|
},
|
37
32
|
.
|
38
33
|
.
|
@@ -40,14 +35,19 @@ api_output = <<-eos
|
|
40
35
|
{
|
41
36
|
"id": 8,
|
42
37
|
"name": "Umm al Qaywayn",
|
43
|
-
"
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
"priority": 1000,
|
39
|
+
"country": {
|
40
|
+
"id": 235,
|
41
|
+
"name": "United Arab Emirates",
|
42
|
+
"iso_name": "UNITED ARAB EMIRATES",
|
43
|
+
"dialing_prefix": "971",
|
44
|
+
"priority": 1000
|
45
|
+
},
|
46
|
+
"region": {
|
47
|
+
"id": 8,
|
48
|
+
"name": "Umm Al Quwain",
|
49
|
+
"priority": 1000
|
50
|
+
}
|
51
51
|
}]
|
52
52
|
}
|
53
53
|
eos
|
@@ -56,7 +56,7 @@ eos
|
|
56
56
|
|
57
57
|
<%= render partial: "kuppayam/api/docs/example", locals: {
|
58
58
|
negative_case: false,
|
59
|
-
example_id: "
|
59
|
+
example_id: "pos_case_2",
|
60
60
|
api_title: api_title,
|
61
61
|
api_input: api_input,
|
62
62
|
api_output: api_output
|
@@ -11,45 +11,17 @@ api_output = <<-eos
|
|
11
11
|
"success": true,
|
12
12
|
"data": [
|
13
13
|
{
|
14
|
-
"id":
|
15
|
-
"name": "
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"fips": "AF",
|
19
|
-
"iso_alpha_2": "AF",
|
20
|
-
"iso_alpha_3": "AFG",
|
21
|
-
"itu_code": "AFG",
|
22
|
-
"dialing_prefix": "93",
|
23
|
-
"tld": ".af",
|
24
|
-
"latitude": "33.0",
|
25
|
-
"longitude": "65.0",
|
26
|
-
"capital": "Kabul",
|
27
|
-
"continent": "AS",
|
28
|
-
"currency_code": "AFN",
|
29
|
-
"currency_name": "Afghani",
|
30
|
-
"is_independent": "Yes",
|
31
|
-
"languages": "fa-AF,ps,uz-AF,tk",
|
14
|
+
"id": 100,
|
15
|
+
"name": "India",
|
16
|
+
"iso_name": "INDIA",
|
17
|
+
"dialing_prefix": "91",
|
32
18
|
"priority": 1000
|
33
19
|
},
|
34
20
|
{
|
35
21
|
"id": 2,
|
36
22
|
"name": "Albania",
|
37
|
-
"official_name": "Albania",
|
38
23
|
"iso_name": "ALBANIA",
|
39
|
-
"fips": "AL",
|
40
|
-
"iso_alpha_2": "AL",
|
41
|
-
"iso_alpha_3": "ALB",
|
42
|
-
"itu_code": "ALB",
|
43
24
|
"dialing_prefix": "355",
|
44
|
-
"tld": ".al",
|
45
|
-
"latitude": "41.0",
|
46
|
-
"longitude": "20.0",
|
47
|
-
"capital": "Tirana",
|
48
|
-
"continent": "EU",
|
49
|
-
"currency_code": "ALL",
|
50
|
-
"currency_name": "Lek",
|
51
|
-
"is_independent": "Yes",
|
52
|
-
"languages": "sq,el",
|
53
25
|
"priority": 1000
|
54
26
|
},
|
55
27
|
.
|
@@ -58,22 +30,8 @@ api_output = <<-eos
|
|
58
30
|
{
|
59
31
|
"id": 246,
|
60
32
|
"name": "Zimbabwe",
|
61
|
-
"official_name": "Zimbabwe",
|
62
33
|
"iso_name": "ZIMBABWE",
|
63
|
-
"fips": "ZI",
|
64
|
-
"iso_alpha_2": "ZW",
|
65
|
-
"iso_alpha_3": "ZWE",
|
66
|
-
"itu_code": "ZWE",
|
67
34
|
"dialing_prefix": "263",
|
68
|
-
"tld": ".zw",
|
69
|
-
"latitude": "-20.0",
|
70
|
-
"longitude": "30.0",
|
71
|
-
"capital": "Harare",
|
72
|
-
"continent": "AF",
|
73
|
-
"currency_code": "ZWL",
|
74
|
-
"currency_name": "Zimbabwe Dollar",
|
75
|
-
"is_independent": "Yes",
|
76
|
-
"languages": "en-ZW,sn,nr,nd",
|
77
35
|
"priority": 1000
|
78
36
|
}]
|
79
37
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 2 - should search countries"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{
|
7
|
+
"q": "<Search Query>"
|
8
|
+
}
|
9
|
+
eos
|
10
|
+
|
11
|
+
api_output = <<-eos
|
12
|
+
{
|
13
|
+
"success": true,
|
14
|
+
"data": [
|
15
|
+
{
|
16
|
+
"id": 100,
|
17
|
+
"name": "India",
|
18
|
+
"iso_name": "INDIA",
|
19
|
+
"dialing_prefix": "91",
|
20
|
+
"priority": 1000
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": 2,
|
24
|
+
"name": "Albania",
|
25
|
+
"iso_name": "ALBANIA",
|
26
|
+
"dialing_prefix": "355",
|
27
|
+
"priority": 1000
|
28
|
+
},
|
29
|
+
.
|
30
|
+
.
|
31
|
+
.
|
32
|
+
{
|
33
|
+
"id": 246,
|
34
|
+
"name": "Zimbabwe",
|
35
|
+
"iso_name": "ZIMBABWE",
|
36
|
+
"dialing_prefix": "263",
|
37
|
+
"priority": 1000
|
38
|
+
}]
|
39
|
+
}
|
40
|
+
eos
|
41
|
+
|
42
|
+
%>
|
43
|
+
|
44
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
45
|
+
negative_case: false,
|
46
|
+
example_id: "pos_case_2",
|
47
|
+
api_title: api_title,
|
48
|
+
api_input: api_input,
|
49
|
+
api_output: api_output
|
50
|
+
} %>
|
@@ -11,34 +11,43 @@ api_output = <<-eos
|
|
11
11
|
"success": true,
|
12
12
|
"data": [
|
13
13
|
{
|
14
|
-
"id":
|
15
|
-
"name": "
|
16
|
-
"
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
"id": 1329,
|
15
|
+
"name": "Andaman and Nicobar Islands",
|
16
|
+
"priority": 1000,
|
17
|
+
"country": {
|
18
|
+
"id": 100,
|
19
|
+
"name": "India",
|
20
|
+
"iso_name": "INDIA",
|
21
|
+
"dialing_prefix": "91",
|
22
|
+
"priority": 1000
|
23
|
+
}
|
21
24
|
},
|
22
25
|
{
|
23
|
-
"id":
|
24
|
-
"name": "
|
25
|
-
"
|
26
|
-
"
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
"id": 1328,
|
27
|
+
"name": "Andhra Pradesh",
|
28
|
+
"priority": 1000,
|
29
|
+
"country": {
|
30
|
+
"id": 100,
|
31
|
+
"name": "India",
|
32
|
+
"iso_name": "INDIA",
|
33
|
+
"dialing_prefix": "91",
|
34
|
+
"priority": 1000
|
35
|
+
}
|
30
36
|
},
|
31
37
|
.
|
32
38
|
.
|
33
39
|
.
|
34
40
|
{
|
35
|
-
"id":
|
36
|
-
"name": "
|
37
|
-
"
|
38
|
-
"
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
"id": 1332,
|
42
|
+
"name": "Uttaranchal",
|
43
|
+
"priority": 1000,
|
44
|
+
"country": {
|
45
|
+
"id": 100,
|
46
|
+
"name": "India",
|
47
|
+
"iso_name": "INDIA",
|
48
|
+
"dialing_prefix": "91",
|
49
|
+
"priority": 1000
|
50
|
+
}
|
42
51
|
}]
|
43
52
|
}
|
44
53
|
eos
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - should return search regions in a country"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
{
|
7
|
+
"q": "<Search Query>"
|
8
|
+
}
|
9
|
+
eos
|
10
|
+
|
11
|
+
api_output = <<-eos
|
12
|
+
{
|
13
|
+
"success": true,
|
14
|
+
"data": [
|
15
|
+
{
|
16
|
+
"id": 1329,
|
17
|
+
"name": "Andaman and Nicobar Islands",
|
18
|
+
"priority": 1000,
|
19
|
+
"country": {
|
20
|
+
"id": 100,
|
21
|
+
"name": "India",
|
22
|
+
"iso_name": "INDIA",
|
23
|
+
"dialing_prefix": "91",
|
24
|
+
"priority": 1000
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"id": 1328,
|
29
|
+
"name": "Andhra Pradesh",
|
30
|
+
"priority": 1000,
|
31
|
+
"country": {
|
32
|
+
"id": 100,
|
33
|
+
"name": "India",
|
34
|
+
"iso_name": "INDIA",
|
35
|
+
"dialing_prefix": "91",
|
36
|
+
"priority": 1000
|
37
|
+
}
|
38
|
+
},
|
39
|
+
.
|
40
|
+
.
|
41
|
+
.
|
42
|
+
{
|
43
|
+
"id": 1332,
|
44
|
+
"name": "Uttaranchal",
|
45
|
+
"priority": 1000,
|
46
|
+
"country": {
|
47
|
+
"id": 100,
|
48
|
+
"name": "India",
|
49
|
+
"iso_name": "INDIA",
|
50
|
+
"dialing_prefix": "91",
|
51
|
+
"priority": 1000
|
52
|
+
}
|
53
|
+
}]
|
54
|
+
}
|
55
|
+
eos
|
56
|
+
|
57
|
+
%>
|
58
|
+
|
59
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
60
|
+
negative_case: false,
|
61
|
+
example_id: "pos_case_2",
|
62
|
+
api_title: api_title,
|
63
|
+
api_input: api_input,
|
64
|
+
api_output: api_output
|
65
|
+
} %>
|
data/lib/pattana/engine.rb
CHANGED
data/lib/pattana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pattana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -84,20 +84,40 @@ dependencies:
|
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 0.0.5
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: filesize
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.1.1
|
94
|
+
type: :runtime
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.1.1
|
87
101
|
- !ruby/object:Gem::Dependency
|
88
102
|
name: kuppayam
|
89
103
|
requirement: !ruby/object:Gem::Requirement
|
90
104
|
requirements:
|
91
105
|
- - "~>"
|
92
106
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.1
|
107
|
+
version: '0.1'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.13
|
94
111
|
type: :runtime
|
95
112
|
prerelease: false
|
96
113
|
version_requirements: !ruby/object:Gem::Requirement
|
97
114
|
requirements:
|
98
115
|
- - "~>"
|
99
116
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.1
|
117
|
+
version: '0.1'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.1.13
|
101
121
|
- !ruby/object:Gem::Dependency
|
102
122
|
name: bcrypt
|
103
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +146,20 @@ dependencies:
|
|
126
146
|
- - "~>"
|
127
147
|
- !ruby/object:Gem::Version
|
128
148
|
version: '0.8'
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: active_model_serializers
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 0.10.6
|
156
|
+
type: :runtime
|
157
|
+
prerelease: false
|
158
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.10.6
|
129
163
|
- !ruby/object:Gem::Dependency
|
130
164
|
name: pry
|
131
165
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,25 +215,25 @@ dependencies:
|
|
181
215
|
- !ruby/object:Gem::Version
|
182
216
|
version: 0.9.0
|
183
217
|
- !ruby/object:Gem::Dependency
|
184
|
-
name:
|
218
|
+
name: mini_magick
|
185
219
|
requirement: !ruby/object:Gem::Requirement
|
186
220
|
requirements:
|
187
221
|
- - "~>"
|
188
222
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
223
|
+
version: 4.8.0
|
190
224
|
- - ">="
|
191
225
|
- !ruby/object:Gem::Version
|
192
|
-
version:
|
226
|
+
version: 4.8.0
|
193
227
|
type: :development
|
194
228
|
prerelease: false
|
195
229
|
version_requirements: !ruby/object:Gem::Requirement
|
196
230
|
requirements:
|
197
231
|
- - "~>"
|
198
232
|
- !ruby/object:Gem::Version
|
199
|
-
version:
|
233
|
+
version: 4.8.0
|
200
234
|
- - ">="
|
201
235
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
236
|
+
version: 4.8.0
|
203
237
|
- !ruby/object:Gem::Dependency
|
204
238
|
name: rspec-rails
|
205
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +386,9 @@ files:
|
|
352
386
|
- app/models/country.rb
|
353
387
|
- app/models/pattana/application_record.rb
|
354
388
|
- app/models/region.rb
|
389
|
+
- app/serializers/city_preview_serializer.rb
|
390
|
+
- app/serializers/country_preview_serializer.rb
|
391
|
+
- app/serializers/region_preview_serializer.rb
|
355
392
|
- app/views/kuppayam/api/docs/_navigation.html.erb
|
356
393
|
- app/views/layouts/kuppayam/_footer.html.erb
|
357
394
|
- app/views/layouts/kuppayam/_header.html.erb
|
@@ -360,14 +397,17 @@ files:
|
|
360
397
|
- app/views/layouts/pattana/application.html.erb
|
361
398
|
- app/views/pattana/api/v1/docs/cities_in_a_country/_neg_case_1.html.erb
|
362
399
|
- app/views/pattana/api/v1/docs/cities_in_a_country/_pos_case_1.html.erb
|
400
|
+
- app/views/pattana/api/v1/docs/cities_in_a_country/_pos_case_2.html.erb
|
363
401
|
- app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_1.html.erb
|
364
402
|
- app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_2.html.erb
|
365
403
|
- app/views/pattana/api/v1/docs/cities_in_a_region/_neg_case_3.html.erb
|
366
404
|
- app/views/pattana/api/v1/docs/cities_in_a_region/_pos_case_1.html.erb
|
367
405
|
- app/views/pattana/api/v1/docs/cities_in_a_region/_pos_case_2.html.erb
|
368
406
|
- app/views/pattana/api/v1/docs/countries/_pos_case_1.html.erb
|
407
|
+
- app/views/pattana/api/v1/docs/countries/_pos_case_2.html.erb
|
369
408
|
- app/views/pattana/api/v1/docs/regions/_neg_case_1.html.erb
|
370
409
|
- app/views/pattana/api/v1/docs/regions/_pos_case_1.html.erb
|
410
|
+
- app/views/pattana/api/v1/docs/regions/_pos_case_2.html.erb
|
371
411
|
- app/views/pattana/cities/_form.html.erb
|
372
412
|
- app/views/pattana/cities/_index.html.erb
|
373
413
|
- app/views/pattana/cities/_row.html.erb
|