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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8886894ef43031aeafa7be11485949babafb4223
4
- data.tar.gz: 23d57ce931ecfc5ceb8003616fcea3086c2de173
3
+ metadata.gz: ccdca5cd657ddcfb47012dc2c74f75093f77584c
4
+ data.tar.gz: 70cfd65377e6a41742aeec933cc3e7a123d2c732
5
5
  SHA512:
6
- metadata.gz: 286890d8608d3ad0405434d5ebbe77db99b28af210aa4d022ae3ee1118a89e829aa04256a2abc4f50e965f7fa1ec22a43ebea2c7690a0d5c213eecc2330c55e3
7
- data.tar.gz: b4c4d96bd37dd8e4e97d03bd7d872c58c126dd90e8bf46d8ecd4b406e87a123cc80112471467d304bdc42456c00f171e52d432a40b633320be0b7716fd5e8108
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.3.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.1)
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.1.0)
31
+ oauth2 (1.2.0)
32
32
  faraday (>= 0.8, < 0.10)
33
- jwt (~> 1.0, < 1.5.2)
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.11.2
86
+ 1.12.5
@@ -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)
@@ -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, :content_type => /\bjson$/
29
+ conn.response :json, :content_type => /\bjson$/
30
30
  conn.use FaradayMiddleware::RaiseHttpException
31
31
  conn.adapter Faraday.default_adapter
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module ParcelApi
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.1'
3
3
  end
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.3.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-04-13 00:00:00.000000000 Z
11
+ date: 2016-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor