paychex_api 0.0.25 → 0.0.26

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
  SHA256:
3
- metadata.gz: 28e5713e53b656a1ea003fffa4ea22e249beed79b88b65efebe0c63365c0e36c
4
- data.tar.gz: 77b3c66897ee0b9dab9661aa0d7d3505198d585f05ba8394f36d2af121dbdae1
3
+ metadata.gz: 2f72a02ebb9077fda3a04a01702c7cc0cb6b2f935922a96f792285456f0c2309
4
+ data.tar.gz: 6332d3d87f09fd1e0eaf556ac5571cbbcffa32a8cea53cc1d48ebfd967f95a0a
5
5
  SHA512:
6
- metadata.gz: 40ae78528ac7ef837ca25006124397dd99dd5bfda4d4f765d7a39c75e5b8c1dda6a0216ece16c203101a01153836601842290b8054f909fc71d242d40fcc3c07
7
- data.tar.gz: 2dcead30a08cfb0e4d445b9b467154473bdb0d0dec41ac857253ab1bc89a4c74863938dc91ab389404383e60c5739f0913b5bd6e6ce3cec2674abe22c697a67d
6
+ metadata.gz: cf887d44b56107c7d554322c9d0c6f5333dbc0b56414f237fb051a5d3fd198320d08f656ebe6b45c9b5e5143d3d6a83515ab3c4ea51fb8c5a0608df0ff2d96e1
7
+ data.tar.gz: 898d26059ce7b3068d330b51ef822865c390e52ffbd95bbefee8e95603d17bf399f03c3e332bb52cf57e76c9f495de2b1805ab6b952aefad1c844aa6c272f502
@@ -0,0 +1,34 @@
1
+ # Virtual environments with possible versions infos: https://github.com/actions/virtual-environments
2
+
3
+ name: CI
4
+ on: [push]
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2 # Step 1: github action that clones the repository
10
+ - name: Setup Ruby # Step 2 (we gave the name 'Setup Ruby' to this step)
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.5.0
14
+ - name: Install bundle and gems # Step 4
15
+ run: |
16
+ gem install bundler
17
+ bundle install --jobs 4 --retry 3
18
+ - if: ${{ failure() }}
19
+ run: echo "Something went wrong on the previous steps"
20
+ - if: ${{ success() }}
21
+ name: Run Rubocop # Step 7
22
+ run: bundle exec rubocop
23
+ brakeman:
24
+ name: runner / brakeman # Step 8
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Check out code
28
+ uses: actions/checkout@v1
29
+ - name: brakeman
30
+ uses: reviewdog/action-brakeman@v1
31
+ with:
32
+ brakeman_version: 4.8.2
33
+ github_token: ${{ secrets.github_token }}
34
+ reporter: github-pr-review # Default is github-pr-check
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ bridge_api.iml
6
6
  .byebug_history
7
7
  *.gem
8
8
  coverage
9
+ .history
@@ -1,31 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paychex_api (0.0.25)
5
- faraday (~> 0.9)
4
+ paychex_api (0.0.26)
5
+ faraday (~> 0.9.0)
6
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 (6.0.3.2)
12
+ activesupport (6.1.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
18
  addressable (2.7.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
20
  ast (2.4.1)
21
21
  byebug (11.1.3)
22
22
  coderay (1.1.3)
23
- concurrent-ruby (1.1.6)
23
+ concurrent-ruby (1.1.7)
24
24
  crack (0.4.3)
25
25
  safe_yaml (~> 1.0.0)
26
26
  diff-lcs (1.4.4)
27
27
  docile (1.3.2)
28
- faraday (0.17.3)
28
+ faraday (0.9.2)
29
29
  multipart-post (>= 1.2, < 3)
30
30
  faraday_middleware (0.14.0)
31
31
  faraday (>= 0.7.4, < 1.0)
@@ -40,14 +40,14 @@ GEM
40
40
  httparty (0.18.1)
41
41
  mime-types (~> 3.0)
42
42
  multi_xml (>= 0.5.2)
43
- i18n (1.8.5)
43
+ i18n (1.8.7)
44
44
  concurrent-ruby (~> 1.0)
45
45
  link_header (0.0.8)
46
46
  method_source (1.0.0)
47
47
  mime-types (3.3.1)
48
48
  mime-types-data (~> 3.2015)
49
49
  mime-types-data (3.2020.0512)
50
- minitest (5.14.1)
50
+ minitest (5.14.3)
51
51
  multi_xml (0.6.0)
52
52
  multipart-post (2.1.1)
53
53
  mustermann (1.1.1)
@@ -98,16 +98,15 @@ GEM
98
98
  rack-protection (= 2.0.8.1)
99
99
  tilt (~> 2.0)
100
100
  sqlite3 (1.4.2)
101
- thread_safe (0.3.6)
102
101
  tilt (2.0.10)
103
- tzinfo (1.2.7)
104
- thread_safe (~> 0.1)
102
+ tzinfo (2.0.4)
103
+ concurrent-ruby (~> 1.0)
105
104
  unicode-display_width (1.7.0)
106
105
  webmock (3.8.3)
107
106
  addressable (>= 2.3.6)
108
107
  crack (>= 0.3.2)
109
108
  hashdiff (>= 0.4.0, < 2.0.0)
110
- zeitwerk (2.4.0)
109
+ zeitwerk (2.4.2)
111
110
 
112
111
  PLATFORMS
113
112
  ruby
@@ -1,4 +1,4 @@
1
-
1
+ # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
2
2
  module PaychexAPI
3
3
  class ApiArray
4
4
  include Enumerable
@@ -63,7 +63,7 @@ module PaychexAPI
63
63
  def each_page
64
64
  yield(members, @linked, @meta)
65
65
  while @next_page
66
- response = get_page(@next_page)
66
+ response = page(@next_page)
67
67
  apply_response_metadata(response, false)
68
68
  @members = get_response_content(response)
69
69
  yield(members, @linked, @meta)
@@ -73,6 +73,7 @@ module PaychexAPI
73
73
 
74
74
  def all_pages!
75
75
  return self unless pages?
76
+
76
77
  combine_page
77
78
  combine_pages
78
79
  self
@@ -89,39 +90,42 @@ module PaychexAPI
89
90
  end
90
91
 
91
92
  def combine_page
92
- response = get_page(@next_page)
93
+ response = page(@next_page)
93
94
  apply_response_metadata(response)
94
95
  @members.concat(get_response_content(response))
95
96
  end
96
97
 
97
- def get_page(url, params = {}, tries=0)
98
+ def page(url, params = {}, tries = 0)
98
99
  query = URI.parse(url).query
99
100
  p = CGI.parse(query).merge(params)
100
101
  u = url.gsub("?#{query}", '')
102
+
101
103
  p.each { |k, v| p[k] = v.first if v.is_a?(Array) }
104
+
102
105
  resp = @api_client.connection.send(:get) do |r|
103
106
  r.url(u, p)
104
107
  end
108
+
105
109
  tries = 0 if status == 200
106
110
  resp
107
111
  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
112
+ raise e unless tries.zero?
113
+
114
+ # token may have expired for long running pagination requests, refresh and try again
115
+ @api_client.refresh_token!
116
+ page(url, params, (tries + 1))
115
117
  end
116
118
 
117
119
  def load_page(url)
118
- response = get_page(url)
120
+ response = page(url)
119
121
  ApiArray.process_response(response, @api_client)
120
122
  end
121
123
 
122
124
  def get_response_content(response)
123
125
  body = response.body
126
+
124
127
  return [] unless body.is_a?(Hash)
128
+
125
129
  if body.key?('content')
126
130
  body['content'] || []
127
131
  else
@@ -134,9 +138,11 @@ module PaychexAPI
134
138
  @links = []
135
139
  @metadata = {}
136
140
  end
141
+
137
142
  @status = response.status
138
143
  @headers = response.headers
139
144
  @method = response.env[:method]
145
+
140
146
  init_pages(response)
141
147
  init_linked(response)
142
148
  init_meta(response)
@@ -144,16 +150,19 @@ module PaychexAPI
144
150
 
145
151
  def init_linked(response)
146
152
  return nil unless response.body.is_a?(Hash) && response.body.key?('links')
153
+
147
154
  @links = @links.concat(response.body['links'])
148
155
  end
149
156
 
150
157
  def init_meta(response)
151
158
  return nil unless response.body.is_a?(Hash) && response.body.key?('metadata')
159
+
152
160
  @metadata = response.body['metadata']
153
161
  end
154
162
 
155
163
  def init_pages(response)
156
164
  return nil unless response.body.is_a?(Hash) && response.body.key?('links')
165
+
157
166
  @next_page, @prev_page = nil
158
167
  response.body['links'].each do |link|
159
168
  case link['rel']
@@ -166,3 +175,4 @@ module PaychexAPI
166
175
  end
167
176
  end
168
177
  end
178
+ # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
@@ -10,6 +10,7 @@ require 'base64'
10
10
  require 'active_support/time'
11
11
  require 'paychex_api/api_array'
12
12
 
13
+ # rubocop:disable Lint/NonDeterministicRequireOrder
13
14
  module PaychexAPI
14
15
  class Client < Footrest::Client
15
16
  API_PATH = ''.freeze
@@ -47,10 +48,11 @@ module PaychexAPI
47
48
 
48
49
  def token
49
50
  return config[:token] if config[:token].present?
51
+
50
52
  authorize if @authorization.blank? || @authorization['expiration'] <= Time.now - 30.seconds
51
53
  @authorization['access_token']
52
54
  end
53
-
55
+
54
56
  def refresh_token!
55
57
  config.delete(:token)
56
58
  authorize
@@ -113,7 +115,7 @@ module PaychexAPI
113
115
  end
114
116
 
115
117
  def faraday_proxy(faraday)
116
- faraday.proxy = PaychexAPI.proxy if PaychexAPI.proxy
118
+ faraday.proxy PaychexAPI.proxy if PaychexAPI.proxy
117
119
  faraday
118
120
  end
119
121
 
@@ -150,3 +152,4 @@ module PaychexAPI
150
152
  end
151
153
  end
152
154
  end
155
+ # rubocop:enable Lint/NonDeterministicRequireOrder
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Lint/UriEscapeUnescape
1
2
  module PaychexAPI
2
3
  class Client
3
4
  module Notifications
@@ -7,3 +8,4 @@ module PaychexAPI
7
8
  end
8
9
  end
9
10
  end
11
+ # rubocop:enable Lint/UriEscapeUnescape
@@ -1,15 +1,15 @@
1
1
  module PaychexAPI
2
2
  class Client
3
3
  module Statuses
4
- def company_status(params={})
4
+ def company_status(params = {})
5
5
  get("#{API_PATH}#{STATUS_PATH}/company", params)
6
6
  end
7
7
 
8
- def user_status(params={})
8
+ def user_status(params = {})
9
9
  get("#{API_PATH}#{STATUS_PATH}/user", params)
10
10
  end
11
11
 
12
- def worker_status(params={})
12
+ def worker_status(params = {})
13
13
  get("#{API_PATH}#{STATUS_PATH}/worker", params)
14
14
  end
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module PaychexAPI
2
- VERSION = '0.0.25'.freeze unless defined?(PaychexAPI::VERSION)
2
+ VERSION = '0.0.26'.freeze unless defined?(PaychexAPI::VERSION)
3
3
  end
@@ -1,5 +1,5 @@
1
-
2
1
  $LOAD_PATH.push File.expand_path('lib', __dir__)
2
+
3
3
  require 'paychex_api/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.add_development_dependency 'sinatra', '>= 1.0', '< 3'
30
30
  gem.add_development_dependency 'webmock', '>= 1.22'
31
31
 
32
- gem.add_dependency 'faraday', '~> 0.9'
32
+ gem.add_dependency 'faraday', '~> 0.9.0'
33
33
  gem.add_dependency 'faraday_middleware', '>= 0.12.2'
34
34
  gem.add_dependency 'footrest', '>= 0.5.1'
35
35
  end
@@ -1,10 +1,11 @@
1
1
  require 'test_helper'
2
+
2
3
  describe PaychexAPI::Client::Notifications do
3
4
  let!(:body) do
4
5
  {
5
6
  'companyId' => '00Z5V9BTI687WL8V60GT',
6
7
  'asOfDate' => '2018-01-12T00:00:00Z',
7
- 'domains' => ['CLT_PROD'],
8
+ 'domains' => ['CLT_PROD'],
8
9
  'action' => 'ADD',
9
10
  'productCode' => 'LMS_ENH'
10
11
  }
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+
2
3
  describe PaychexAPI::Client::Notifications do
3
4
  before do
4
5
  @client = PaychexAPI::Client.new(
@@ -8,13 +9,15 @@ describe PaychexAPI::Client::Notifications do
8
9
 
9
10
  it 'should send a notification' do
10
11
  response = @client.send_notification('f7f9c815-0d4c-46e5-9434-5cc19470d1ed-3520000031155394')
12
+
11
13
  expect(response.status).to(eq(200))
12
14
  end
13
15
 
14
16
  it 'should URI escape a notification id' do
15
17
  expect_any_instance_of(PaychexAPI::Client::Notifications)
16
18
  .to receive(:post)
17
- .with("/notifications/f7f9c815-0d4c-46e5-9434-5cc1%209470d1ed-3520000031155394", {})
19
+ .with('/notifications/f7f9c815-0d4c-46e5-9434-5cc1%209470d1ed-3520000031155394', {})
20
+
18
21
  @client.send_notification('f7f9c815-0d4c-46e5-9434-5cc1 9470d1ed-3520000031155394')
19
22
  end
20
23
  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.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-02 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -162,14 +162,14 @@ dependencies:
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '0.9'
165
+ version: 0.9.0
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '0.9'
172
+ version: 0.9.0
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: faraday_middleware
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +205,7 @@ executables: []
205
205
  extensions: []
206
206
  extra_rdoc_files: []
207
207
  files:
208
+ - ".github/workflows/ci.yml"
208
209
  - ".gitignore"
209
210
  - ".rubocop.yml"
210
211
  - ".simplecov"