parcel_api 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/parcel_api/address.rb +21 -1
- data/lib/parcel_api/client.rb +1 -1
- data/lib/parcel_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccdca5cd657ddcfb47012dc2c74f75093f77584c
|
4
|
+
data.tar.gz: 70cfd65377e6a41742aeec933cc3e7a123d2c732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37606c5c842c634eba7139fcc7447c855ca82981c4ad611a81dfe22dee7ac7333dbdb815b9902c27dcf757a6ed57d3c43fc9608f0525ff03d14abbe5435b328
|
7
|
+
data.tar.gz: 2393821656fd4c4de1672526f95f9290d97151bec8672e61400ba6f1b9340220c849aa7818016e399f0e8ba557bb892b8c1cf289c9397c22299c3d7abfd8da3b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
parcel_api (0.
|
4
|
+
parcel_api (0.4.1)
|
5
5
|
faraday (~> 0.9)
|
6
6
|
faraday_middleware (~> 0.9)
|
7
7
|
oauth2 (~> 1.0)
|
@@ -23,14 +23,14 @@ GEM
|
|
23
23
|
multipart-post (>= 1.2, < 3)
|
24
24
|
faraday_middleware (0.10.0)
|
25
25
|
faraday (>= 0.7.4, < 0.10)
|
26
|
-
jwt (1.5.
|
26
|
+
jwt (1.5.6)
|
27
27
|
method_source (0.8.2)
|
28
28
|
multi_json (1.11.0)
|
29
29
|
multi_xml (0.5.5)
|
30
30
|
multipart-post (2.0.0)
|
31
|
-
oauth2 (1.
|
31
|
+
oauth2 (1.2.0)
|
32
32
|
faraday (>= 0.8, < 0.10)
|
33
|
-
jwt (~> 1.0
|
33
|
+
jwt (~> 1.0)
|
34
34
|
multi_json (~> 1.3)
|
35
35
|
multi_xml (~> 0.5)
|
36
36
|
rack (>= 1.2, < 3)
|
@@ -83,4 +83,4 @@ DEPENDENCIES
|
|
83
83
|
yard (~> 0.8)
|
84
84
|
|
85
85
|
BUNDLED WITH
|
86
|
-
1.
|
86
|
+
1.12.5
|
data/lib/parcel_api/address.rb
CHANGED
@@ -4,6 +4,7 @@ module ParcelApi
|
|
4
4
|
# Search International Addresses and Get Specifc International Address Detail.
|
5
5
|
|
6
6
|
class Address
|
7
|
+
AUSTRALIAN_URL = '/ParcelAddress/2.0/australia/addresses'
|
7
8
|
DOMESTIC_URL = '/ParcelAddress/2.0/domestic/addresses'
|
8
9
|
INTERNATIONAL_URL = '/ParcelAddress/2.0/international/addresses'
|
9
10
|
|
@@ -24,7 +25,7 @@ module ParcelApi
|
|
24
25
|
response = @connection.get DOMESTIC_URL, { q: query, count: count }
|
25
26
|
addresses = response.body['addresses'].each do |a|
|
26
27
|
a['address_id'] = Integer(a['address_id'])
|
27
|
-
a['dpid'] = Integer(a['dpid'])
|
28
|
+
a['dpid'] = Integer(a['dpid']) if a['dpid']
|
28
29
|
end
|
29
30
|
addresses.map {|address| OpenStruct.new(address)}
|
30
31
|
end
|
@@ -39,6 +40,25 @@ module ParcelApi
|
|
39
40
|
OpenStruct.new(response.body['address'])
|
40
41
|
end
|
41
42
|
|
43
|
+
# Search for an Australian Address
|
44
|
+
# @param [String] characters to search for
|
45
|
+
# @param [Integer] number of search results to return (max 10)
|
46
|
+
# @return [Array] array of australian addresses
|
47
|
+
|
48
|
+
def australian_search(query, count=5)
|
49
|
+
international_search(query, count, 'AU')
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return australian address details for a specific international address id
|
53
|
+
# @param address_id [String]
|
54
|
+
# @return australian address detail
|
55
|
+
|
56
|
+
def australian_details(address_id)
|
57
|
+
details_url = File.join(AUSTRALIAN_URL, address_id.to_s)
|
58
|
+
response = @connection.get details_url
|
59
|
+
RecursiveOpenStruct.new(response.body['address'], recurse_over_arrays: true)
|
60
|
+
end
|
61
|
+
|
42
62
|
# Search for an International Address
|
43
63
|
# @param [String] characters to search for
|
44
64
|
# @param [Integer] number of search results to return (max 10)
|
data/lib/parcel_api/client.rb
CHANGED
@@ -26,7 +26,7 @@ module ParcelApi
|
|
26
26
|
conn.authorization 'Bearer', token
|
27
27
|
conn.headers['client_id'] = @client_id
|
28
28
|
conn.request :json
|
29
|
-
conn.response :json,
|
29
|
+
conn.response :json, :content_type => /\bjson$/
|
30
30
|
conn.use FaradayMiddleware::RaiseHttpException
|
31
31
|
conn.adapter Faraday.default_adapter
|
32
32
|
end
|
data/lib/parcel_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parcel_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Coleman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|