paychex_api 0.0.10 → 0.0.11

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: 420e55a9662715817b68cb45e13eb6daa52f915653b3d47b5e38997220e227cc
4
- data.tar.gz: 50ca1ff1e7630e04407f36207f791fea82eabf733a24f838a5a6a9277564d9e2
3
+ metadata.gz: 9f237f7ebc68a81bea7f1fc2d5492aa1c20bf1b7d277b1d321b7f5908e17fac9
4
+ data.tar.gz: 737c9b2a6d7ce215e4288402fd8f9a1a4bf2006402c122b5e06f31edfe7e96f9
5
5
  SHA512:
6
- metadata.gz: ba20485999f91b3ce4f4e7df8ce5e642ec38e584af67cd4db5a101b817fd7498b65988bbe87ec4180945bedde432019cb5e5063b09ae3074a90f11ea3dfe7c94
7
- data.tar.gz: 583bba223519cfd5b319fc50e8ed0469a7c8ae78d9f85195b7af7f09ec8709dc45adad6b79b67c9c58900e1f8fa2d32d7c80a1620183b94517a10099bea2d7f1
6
+ metadata.gz: a534e51810f080408d3bae4ef1a091543065f0bc8ee0a21b0e15ddad49778ba715ffafceee50961954cb1c84f5fd846cd72e375e913efaabaaa25ef2ff4270ec
7
+ data.tar.gz: '09bc8fdb11f0ab95c73a9b8f951406f403bb872674f2bd3f3ca1674027f7b614dfe69de12f915bcb172d48b097fece7d89ad042c210b1d63f1f2f06d30703d02'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paychex_api (0.0.10)
4
+ paychex_api (0.0.11)
5
5
  faraday (~> 0.9.2)
6
6
  faraday_middleware (~> 0.9.2)
7
7
  footrest (>= 0.5.1)
@@ -10,16 +10,10 @@ module PaychexAPI
10
10
  get("#{API_PATH}#{COMPANIES_PATH}/#{company_id}", params)
11
11
  end
12
12
 
13
- def get_company_associations_by_types(company_id, types, params = {})
13
+ def get_company_associations_by_regex_type(company_id, regex, params = {})
14
14
  connection.headers[:accept] = "application/json;profile='http://api.paychex.com/profiles/company_associations/v1'"
15
15
  results = get("#{API_PATH}#{COMPANIES_PATH}/#{company_id}", params)
16
- results.members.map! do |member|
17
- member['associations'] = member['associations'].select do |association|
18
- types.include?(association['associationType'])
19
- end if member['associations'].present?
20
- member
21
- end
22
- results
16
+ filter_associations(results, regex)
23
17
  end
24
18
 
25
19
  def get_company_workers(company_id, params = {})
@@ -39,6 +33,20 @@ module PaychexAPI
39
33
  def get_organization(company_id, organization_id, params = {})
40
34
  get("#{API_PATH}#{COMPANIES_PATH}/#{company_id}#{ORGANIZATIONS_PATH}/#{organization_id}", params)
41
35
  end
36
+
37
+ private
38
+
39
+ def filter_associations(results, regex)
40
+ results.members.map! do |member|
41
+ if member['associations'].present?
42
+ member['associations'] = member['associations'].select do |association|
43
+ regex.match?(association['associationType'])
44
+ end
45
+ end
46
+ member
47
+ end
48
+ results
49
+ end
42
50
  end
43
51
  end
44
52
  end
@@ -1,3 +1,3 @@
1
1
  module PaychexAPI
2
- VERSION = '0.0.10'.freeze unless defined?(PaychexAPI::VERSION)
2
+ VERSION = '0.0.11'.freeze unless defined?(PaychexAPI::VERSION)
3
3
  end
@@ -30,14 +30,14 @@ describe PaychexAPI::Client::Companies do
30
30
  response = @client.get_company_workers(1)
31
31
  expect(response.first['workerId']).to(eq('00Z5V9BTIHRQF2CF7BTH'))
32
32
  end
33
-
33
+
34
34
  it 'should get company associations with association type' do
35
- response = @client.get_company_associations_by_types(1, ['LMS_ES_BPR'])
35
+ response = @client.get_company_associations_by_regex_type(1, /LMS.*/)
36
36
  expect(response.first['associations'].length).to(eq(1))
37
37
  end
38
38
 
39
39
  it 'should get company associations filtered to empty' do
40
- response = @client.get_company_associations_by_types(1, ['BLAH'])
41
- expect(response.first['associations'].length).to(eq(0))
42
- end
40
+ response = @client.get_company_associations_by_regex_type(1, /BLAH.*/)
41
+ expect(response.first['associations'].length).to(eq(0))
42
+ end
43
43
  end
@@ -13,13 +13,13 @@ describe PaychexAPI::Client::Users do
13
13
  end
14
14
 
15
15
  it 'should get users' do
16
- response = @client.get_user_access(1)
16
+ response = @client.get_user(1)
17
17
  expect(response.size).to eq(1)
18
18
  expect(response.first.key?('access')).to eq(true)
19
19
  end
20
20
 
21
21
  it 'should get users workers' do
22
- response = @client.get_user_access(1)
22
+ response = @client.get_user_workers(1)
23
23
  expect(response.size).to eq(1)
24
24
  expect(response.first.key?('access')).to eq(true)
25
25
  end
@@ -22,8 +22,8 @@ class FakePaychex < Sinatra::Base
22
22
  end
23
23
 
24
24
  get %r{/workers/\d+/users$} do
25
- case request.env['HTTP_ACCEPT']
26
- when "application/json;profile='http://api.paychex.com/profiles/users/v1'"
25
+ case request.env['HTTP_ACCEPT']
26
+ when "application/json;profile='http://api.paychex.com/profiles/users/v1'"
27
27
  get_json_data 200, 'users.json'
28
28
  else
29
29
  get_json_data 200, 'workers.json'
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.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler