paychex_api 0.0.22 → 0.0.23

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: 838df116216638341ccdafaa866e54db5aac7fac
4
- data.tar.gz: dc778ab8145722c960eb4ac2d32ab946ab8058cc
3
+ metadata.gz: b08cf38b56a279f0e7341aa6dd826cd41deff9b1
4
+ data.tar.gz: 317ee58d2d600c880c6620cf7803519f5ecbe508
5
5
  SHA512:
6
- metadata.gz: b455ac3a06604ac95e18a71d17866727ffd47ec1ce3c9c2b464b40e4861c9e06a8e6fb8bd0765e389dff3e6c28715f7f7f86d91d73ebf3f3d463c72ea5c9fd1c
7
- data.tar.gz: 68d0dacc2db54e0b0746b5c1aec71788a77597e9f7437a7894618b6319de9a638bebd166bd5cbe83e700c131bc1bf4dc1600ec0e8bf690ea782b7134ec9cfb65
6
+ metadata.gz: cac55a46edaa5117c5faa8391b86fb1d0a3ef4d7f9c50312e4b6119363e26d8bd7c1ff1b9d9c2a14b786ad2496692f6c636a7c4649e8d65a7c894c5ed39a4bd9
7
+ data.tar.gz: 50b4c58dd1ebadcd73673979539439be5384201af7ebb01224468a58bca40896d73be5fc05475a06d80c3e02880fd76a08534d9317d2b9d0ddf37382d967be7c
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paychex_api (0.0.19)
4
+ paychex_api (0.0.23)
5
5
  faraday (~> 0.9.2)
6
- faraday_middleware (~> 0.9.2)
6
+ faraday_middleware (>= 0.12.2)
7
7
  footrest (>= 0.5.1)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (5.2.0)
12
+ activesupport (5.2.3)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
@@ -19,15 +19,15 @@ GEM
19
19
  ast (2.4.0)
20
20
  byebug (8.2.5)
21
21
  coderay (1.1.2)
22
- concurrent-ruby (1.0.5)
22
+ concurrent-ruby (1.1.5)
23
23
  crack (0.4.3)
24
24
  safe_yaml (~> 1.0.0)
25
25
  diff-lcs (1.3)
26
26
  docile (1.3.0)
27
27
  faraday (0.9.2)
28
28
  multipart-post (>= 1.2, < 3)
29
- faraday_middleware (0.9.2)
30
- faraday (>= 0.7.4, < 0.10)
29
+ faraday_middleware (0.13.1)
30
+ faraday (>= 0.7.4, < 1.0)
31
31
  footrest (0.5.3)
32
32
  activesupport (>= 3.0.0)
33
33
  faraday (>= 0.9.0, < 1)
@@ -38,14 +38,14 @@ GEM
38
38
  hashdiff (0.3.7)
39
39
  httparty (0.16.2)
40
40
  multi_xml (>= 0.5.2)
41
- i18n (1.0.1)
41
+ i18n (1.6.0)
42
42
  concurrent-ruby (~> 1.0)
43
43
  json (2.1.0)
44
44
  link_header (0.0.8)
45
45
  method_source (0.9.0)
46
46
  minitest (5.11.3)
47
47
  multi_xml (0.6.0)
48
- multipart-post (2.0.0)
48
+ multipart-post (2.1.1)
49
49
  parallel (1.12.1)
50
50
  parser (2.5.1.0)
51
51
  ast (~> 2.4.0)
@@ -94,14 +94,24 @@ module PaychexAPI
94
94
  @members.concat(get_response_content(response))
95
95
  end
96
96
 
97
- def get_page(url, params = {})
97
+ def get_page(url, params = {}, tries=0)
98
98
  query = URI.parse(url).query
99
99
  p = CGI.parse(query).merge(params)
100
100
  u = url.gsub("?#{query}", '')
101
101
  p.each { |k, v| p[k] = v.first if v.is_a?(Array) }
102
- @api_client.connection.send(:get) do |r|
102
+ resp = @api_client.connection.send(:get) do |r|
103
103
  r.url(u, p)
104
104
  end
105
+ tries = 0 if status == 200
106
+ resp
107
+ rescue Footrest::HttpError::Unauthorized => e
108
+ if tries == 0
109
+ # token may have expired for long running pagination requests, refresh and try again
110
+ @api_client.refresh_token!
111
+ get_page(url, params, (tries +1))
112
+ else
113
+ raise e
114
+ end
105
115
  end
106
116
 
107
117
  def load_page(url)
@@ -49,6 +49,12 @@ module PaychexAPI
49
49
  authorize if @authorization.blank? || @authorization['expiration'] <= Time.now - 30.seconds
50
50
  @authorization['access_token']
51
51
  end
52
+
53
+ def refresh_token!
54
+ config.delete(:token)
55
+ authorize
56
+ connection.headers[:authorization] = "Bearer #{token}"
57
+ end
52
58
 
53
59
  def authorize
54
60
  response = faraday_auth.post(
@@ -1,3 +1,3 @@
1
1
  module PaychexAPI
2
- VERSION = '0.0.22'.freeze unless defined?(PaychexAPI::VERSION)
2
+ VERSION = '0.0.23'.freeze unless defined?(PaychexAPI::VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paychex_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-05 00:00:00.000000000 Z
11
+ date: 2019-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  version: '0'
288
288
  requirements: []
289
289
  rubyforge_project:
290
- rubygems_version: 2.5.2.1
290
+ rubygems_version: 2.6.11
291
291
  signing_key:
292
292
  specification_version: 4
293
293
  summary: Paychex API