ruby-postcodeanywhere 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/lib/ruby-postcodeanywhere.rb +28 -7
- data/ruby-postcodeanywhere.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -4,6 +4,8 @@ module PostcodeAnywhere
|
|
4
4
|
|
5
5
|
ADDRESS_LOOKUP = "http://services.postcodeanywhere.co.uk/xml.aspx"
|
6
6
|
ADDRESS_FETCH = "http://services.postcodeanywhere.co.uk/dataset.aspx?action=fetch"
|
7
|
+
|
8
|
+
RETRIEVE_BY_PARTS_URL = "http://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/RetrieveByParts/v1.00/xmla.ws?"
|
7
9
|
|
8
10
|
# Account codes to access the PostcodeAnywhere Service
|
9
11
|
mattr_accessor :account_code
|
@@ -11,8 +13,6 @@ module PostcodeAnywhere
|
|
11
13
|
mattr_accessor :license_code
|
12
14
|
@@license_code = "TEST"
|
13
15
|
|
14
|
-
# Default way to setup Devise. Run rails generate devise_install to create
|
15
|
-
# a fresh initializer with all configuration values.
|
16
16
|
def self.setup
|
17
17
|
yield self
|
18
18
|
end
|
@@ -22,7 +22,7 @@ module PostcodeAnywhere
|
|
22
22
|
include HTTParty
|
23
23
|
format :xml
|
24
24
|
|
25
|
-
attr_accessor :postcode, :country_code, :fetch_id
|
25
|
+
attr_accessor :postcode, :country_code, :fetch_id, :building
|
26
26
|
|
27
27
|
def initialize(args={})
|
28
28
|
self.postcode = args[:postcode]
|
@@ -38,7 +38,24 @@ module PostcodeAnywhere
|
|
38
38
|
end
|
39
39
|
formatted_data
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
|
+
def fetch_by_parts
|
43
|
+
data = PostcodeSearch.get self.fetch_by_parts_url
|
44
|
+
formatted_data = data["NewDataSet"]["Data"]
|
45
|
+
@address_lookup = AddressLookup.new
|
46
|
+
|
47
|
+
if self.country_code == 'GB'
|
48
|
+
@address_lookup.postcode = formatted_data["postcode"]
|
49
|
+
@address_lookup.address_line_1 = formatted_data["line1"]
|
50
|
+
@address_lookup.address_line_2 = formatted_data["line2"]
|
51
|
+
@address_lookup.address_line_3 = formatted_data["line3"]
|
52
|
+
@address_lookup.post_town = formatted_data["post_town"]
|
53
|
+
@address_lookup.county = formatted_data["county"].blank? ? formatted_data["post_town"] : formatted_data["county"]
|
54
|
+
end
|
55
|
+
|
56
|
+
@address_lookup
|
57
|
+
end
|
58
|
+
|
42
59
|
def fetch
|
43
60
|
data = PostcodeSearch.get self.fetch_url
|
44
61
|
formatted_data = data["NewDataSet"]["Data"]
|
@@ -58,7 +75,7 @@ module PostcodeAnywhere
|
|
58
75
|
@address_lookup.post_town = formatted_data["city"]
|
59
76
|
@address_lookup.county = formatted_data["county_name"]+", "+formatted_data["state"]
|
60
77
|
else
|
61
|
-
|
78
|
+
|
62
79
|
end
|
63
80
|
@address_lookup
|
64
81
|
end
|
@@ -67,8 +84,8 @@ module PostcodeAnywhere
|
|
67
84
|
ADDRESS_LOOKUP+"?"+self.lookup_type+"&"+self.postcode_with_no_spaces+self.selected_country+"&"+self.license_information
|
68
85
|
end
|
69
86
|
|
70
|
-
def
|
71
|
-
|
87
|
+
def fetch_by_parts_url
|
88
|
+
RETRIEVE_BY_PARTS_URL+"&"+self.address_building+"&"+self.address_fetch_id+self.selected_country+"&"+self.license_information
|
72
89
|
end
|
73
90
|
|
74
91
|
def selected_country
|
@@ -83,6 +100,10 @@ module PostcodeAnywhere
|
|
83
100
|
"id="+self.fetch_id
|
84
101
|
end
|
85
102
|
|
103
|
+
def address_building
|
104
|
+
"building="+self.building
|
105
|
+
end
|
106
|
+
|
86
107
|
def lookup_type
|
87
108
|
if self.country_code == "GB"
|
88
109
|
"action=lookup&type=by_postcode"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ruby-postcodeanywhere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris Norman
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
hash:
|
106
|
+
hash: 46236617627018293
|
107
107
|
segments:
|
108
108
|
- 0
|
109
109
|
version: "0"
|