parcel_api 1.1.1 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33fc1e342902c65e83dd9577c46d3d659cb219a0
4
- data.tar.gz: dd0ba98998fbf3203ce2f414db245272579bc4b1
3
+ metadata.gz: 8a13b9916fa74c4f67fecb998d3e1dea4f2e1a80
4
+ data.tar.gz: 77a34e2f09f3652004658cb8d3d46481711a0804
5
5
  SHA512:
6
- metadata.gz: 6eae4d4ac188da4222b7c92d54b2510a3c61ad0196aca47b328a8089ff60d5129bdb4e0180d9a260a85b5a5e5bba31a02e450f498b8c1ba0e57ec307cb04f9fe
7
- data.tar.gz: f34704c0b9d44288d53e3fd6fefaeeb7070a0cca42183d18788ac0064328844b971d3764514f80eb7da1c3a3a2c9e40e8533de417839f52341c21c157fc14a0f
6
+ metadata.gz: 80523cc33e155600914746946f7f07750785405a9e227d8c5fc47b099b79b7d9b8f7ec955980b4b8587b7c1b0df4fb4aaae02f3d651c507bda748eeb4c9aad60
7
+ data.tar.gz: d67c9e91c76821fcc008876348ab5424affc0e9040c0f37e650a79428836e2277a23f56082c3497cc3696d1c755b57b990e8ec5a186ad05cfd3b05e985247e5c
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parcel_api (1.1.1)
4
+ parcel_api (1.2.0)
5
5
  activesupport (~> 4.2)
6
6
  oauth2 (~> 1.0)
7
7
  recursive-open-struct (~> 0.6)
8
8
  redis (~> 3.2)
9
+ stringex (~> 2.7, >= 2.7.1)
9
10
  thor (~> 0.19)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- activesupport (4.2.7.1)
15
+ activesupport (4.2.9)
15
16
  i18n (~> 0.7)
16
- json (~> 1.7, >= 1.7.7)
17
17
  minitest (~> 5.1)
18
18
  thread_safe (~> 0.3, >= 0.3.4)
19
19
  tzinfo (~> 1.1)
@@ -25,18 +25,17 @@ GEM
25
25
  safe_yaml (~> 1.0.0)
26
26
  diff-lcs (1.2.5)
27
27
  docile (1.1.5)
28
- faraday (0.9.2)
28
+ faraday (0.12.1)
29
29
  multipart-post (>= 1.2, < 3)
30
- i18n (0.7.0)
31
- json (1.8.3)
30
+ i18n (0.8.4)
32
31
  jwt (1.5.6)
33
32
  method_source (0.8.2)
34
- minitest (5.9.1)
33
+ minitest (5.10.2)
35
34
  multi_json (1.11.0)
36
- multi_xml (0.5.5)
35
+ multi_xml (0.6.0)
37
36
  multipart-post (2.0.0)
38
- oauth2 (1.2.0)
39
- faraday (>= 0.8, < 0.10)
37
+ oauth2 (1.4.0)
38
+ faraday (>= 0.8, < 0.13)
40
39
  jwt (~> 1.0)
41
40
  multi_json (~> 1.3)
42
41
  multi_xml (~> 0.5)
@@ -45,10 +44,10 @@ GEM
45
44
  coderay (~> 1.1.0)
46
45
  method_source (~> 0.8.1)
47
46
  slop (~> 3.4)
48
- rack (1.6.4)
47
+ rack (2.0.3)
49
48
  rake (10.4.2)
50
49
  recursive-open-struct (0.6.5)
51
- redis (3.3.1)
50
+ redis (3.3.3)
52
51
  rspec (3.2.0)
53
52
  rspec-core (~> 3.2.0)
54
53
  rspec-expectations (~> 3.2.0)
@@ -69,9 +68,10 @@ GEM
69
68
  simplecov-html (~> 0.9.0)
70
69
  simplecov-html (0.9.0)
71
70
  slop (3.6.0)
72
- thor (0.19.1)
73
- thread_safe (0.3.5)
74
- tzinfo (1.2.2)
71
+ stringex (2.7.1)
72
+ thor (0.19.4)
73
+ thread_safe (0.3.6)
74
+ tzinfo (1.2.3)
75
75
  thread_safe (~> 0.1)
76
76
  vcr (2.9.3)
77
77
  webmock (1.21.0)
@@ -94,4 +94,4 @@ DEPENDENCIES
94
94
  yard (~> 0.8)
95
95
 
96
96
  BUNDLED WITH
97
- 1.12.5
97
+ 1.14.6
@@ -21,7 +21,7 @@ module ParcelApi
21
21
 
22
22
  def search(query, count=10)
23
23
  return [] if query.length < 4
24
- response = @connection.get DOMESTIC_URL, params: { q: query, count: count }
24
+ response = @connection.get DOMESTIC_URL, params: { q: query.to_ascii, count: count }
25
25
  addresses = response.parsed['addresses'].each do |a|
26
26
  a['address_id'] = Integer(a['address_id'])
27
27
  a['dpid'] = Integer(a['dpid']) if a['dpid']
@@ -67,7 +67,7 @@ module ParcelApi
67
67
  def international_search(query, count=5, country_code=nil)
68
68
  return [] if query.length < 4
69
69
 
70
- response = @connection.get INTERNATIONAL_URL, params: { q: query, count: count, country_code: country_code }
70
+ response = @connection.get INTERNATIONAL_URL, params: { q: query.to_ascii, count: count, country_code: country_code }
71
71
  response.parsed['addresses'].map {|address| OpenStruct.new(address)}
72
72
  end
73
73
 
@@ -35,7 +35,7 @@ module ParcelApi
35
35
  access_token = OAuth2::AccessToken.from_hash client, JSON.parse(json)
36
36
  else
37
37
  access_token = client.password.get_token @username, @password
38
- @redis.set(:parcel_api_access_token, access_token.to_hash.to_json, ex: access_token.expires_in.seconds - 6.hours)
38
+ @redis.set(:parcel_api_access_token, access_token.to_hash.to_json, ex: (access_token.expires_in.seconds - 1.hour))
39
39
  access_token
40
40
  end
41
41
  end
@@ -18,7 +18,7 @@ module ParcelApi
18
18
 
19
19
  def create(label_options)
20
20
  domestic_url = File.join(LABEL_URL, 'domestic')
21
- response = @connection.post domestic_url, body: label_options.to_json, headers: { 'Content-Type' => 'application/json' }
21
+ response = @connection.post domestic_url, body: label_options.to_json.to_ascii, headers: { 'Content-Type' => 'application/json' }
22
22
  labels = response.parsed['labels'].map {|label| OpenStruct.new(label)}
23
23
  labels.first if labels.count == 1
24
24
  end
@@ -29,7 +29,7 @@ module ParcelApi
29
29
 
30
30
  def international_create(label_options)
31
31
  international_url = File.join(LABEL_URL, 'international')
32
- response = @connection.post international_url, body: label_options.to_json, headers: { 'Content-Type' => 'application/json' }
32
+ response = @connection.post international_url, body: label_options.to_json.to_ascii, headers: { 'Content-Type' => 'application/json' }
33
33
  labels = response.parsed['labels'].map {|label| OpenStruct.new(label)}
34
34
  labels.first if labels.count == 1
35
35
  end
@@ -18,7 +18,7 @@ module ParcelApi
18
18
  # @return Object of notification details
19
19
 
20
20
  def create(notification_options)
21
- response = @connection.post PARCELNOTIFICATION_URL, body: notification_options.to_json, headers: { 'Content-Type' => 'application/json' }
21
+ response = @connection.post PARCELNOTIFICATION_URL, body: notification_options.to_json.to_ascii, headers: { 'Content-Type' => 'application/json' }
22
22
  RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
23
23
  end
24
24
 
@@ -17,7 +17,7 @@ module ParcelApi
17
17
  # @return Object of pickup details
18
18
 
19
19
  def create(pickup_options)
20
- response = @connection.post PARCELPICKUP_URL, body: pickup_options.to_json, headers: { 'Content-Type' => 'application/json' }
20
+ response = @connection.post PARCELPICKUP_URL, body: pickup_options.to_json.to_ascii, headers: { 'Content-Type' => 'application/json' }
21
21
  RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module ParcelApi
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/parcel_api.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'recursive-open-struct'
2
+ require 'stringex_lite'
2
3
 
3
4
  require 'parcel_api/version'
4
5
  require 'parcel_api/address'
data/parcel_api.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'redis', '~> 3.2'
24
24
  spec.add_dependency 'activesupport', '~> 4.2'
25
25
  spec.add_dependency 'recursive-open-struct', '~> 0.6'
26
+ spec.add_dependency 'stringex', '~> 2.7', '>= 2.7.1'
26
27
 
27
28
  spec.add_development_dependency 'bundler', '~> 1.8'
28
29
  spec.add_development_dependency 'rake', '~> 10.0'
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: 1.1.1
4
+ version: 1.2.0
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-10-10 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,26 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: stringex
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.7'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 2.7.1
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '2.7'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.7.1
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: bundler
85
105
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
249
  version: '0'
230
250
  requirements: []
231
251
  rubyforge_project:
232
- rubygems_version: 2.5.1
252
+ rubygems_version: 2.5.2
233
253
  signing_key:
234
254
  specification_version: 4
235
255
  summary: Ruby client for NZ Post's Parcel APIs