paychex 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +65 -65
- data/lib/paychex/client/companies.rb +42 -2
- data/lib/paychex/configuration.rb +98 -98
- data/lib/paychex/version.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a0e9b796ff8bbed7975f38538ce1249dba655105902ddb09d040ead0a1a73fb
|
4
|
+
data.tar.gz: 82a381abe282825c4ea363dc529b6cc38d7d948177867acdbc7951cbd1748b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf9c380ba369beff5ad7b654156e1d303ffaa6a11507e869cf6fd0032cd84b0d1ce231415e8910d882c7913c7bc22fee5923bb98ed87be37a15f46950d2ba6b
|
7
|
+
data.tar.gz: f4f8e193fb4ae7aa82a0c36283f3500e13a12f9c654f286f4ad032436915757a6788fa932910f4149fd3866c6532539cef168180f78183fa58f7cff5c00be8d1
|
data/Gemfile.lock
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
paychex (0.3.
|
5
|
-
addressable
|
6
|
-
faraday
|
7
|
-
faraday_middleware
|
8
|
-
rexml
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
addressable (2.7.0)
|
14
|
-
public_suffix (>= 2.0.2, < 5.0)
|
15
|
-
byebug (11.1.3)
|
16
|
-
coderay (1.1.3)
|
17
|
-
crack (0.4.4)
|
18
|
-
diff-lcs (1.4.4)
|
19
|
-
faraday (1.1.0)
|
20
|
-
multipart-post (>= 1.2, < 3)
|
21
|
-
ruby2_keywords
|
22
|
-
faraday_middleware (1.0.0)
|
23
|
-
faraday (~> 1.0)
|
24
|
-
hashdiff (1.0.1)
|
25
|
-
method_source (1.0.0)
|
26
|
-
multipart-post (2.1.1)
|
27
|
-
pry (0.13.1)
|
28
|
-
coderay (~> 1.1)
|
29
|
-
method_source (~> 1.0)
|
30
|
-
public_suffix (4.0.6)
|
31
|
-
rake (13.0.1)
|
32
|
-
rexml (3.2.5)
|
33
|
-
rspec (3.9.0)
|
34
|
-
rspec-core (~> 3.9.0)
|
35
|
-
rspec-expectations (~> 3.9.0)
|
36
|
-
rspec-mocks (~> 3.9.0)
|
37
|
-
rspec-core (3.9.3)
|
38
|
-
rspec-support (~> 3.9.3)
|
39
|
-
rspec-expectations (3.9.3)
|
40
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.9.0)
|
42
|
-
rspec-mocks (3.9.1)
|
43
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.9.0)
|
45
|
-
rspec-support (3.9.4)
|
46
|
-
ruby2_keywords (0.0.4)
|
47
|
-
webmock (3.9.3)
|
48
|
-
addressable (>= 2.3.6)
|
49
|
-
crack (>= 0.3.2)
|
50
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
51
|
-
|
52
|
-
PLATFORMS
|
53
|
-
ruby
|
54
|
-
|
55
|
-
DEPENDENCIES
|
56
|
-
bundler (>= 1.17)
|
57
|
-
byebug
|
58
|
-
paychex!
|
59
|
-
pry
|
60
|
-
rake (>= 12.3.3)
|
61
|
-
rspec (>= 3.9.0)
|
62
|
-
webmock
|
63
|
-
|
64
|
-
BUNDLED WITH
|
65
|
-
2.4.4
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
paychex (0.3.4)
|
5
|
+
addressable
|
6
|
+
faraday
|
7
|
+
faraday_middleware
|
8
|
+
rexml
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.7.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
|
+
byebug (11.1.3)
|
16
|
+
coderay (1.1.3)
|
17
|
+
crack (0.4.4)
|
18
|
+
diff-lcs (1.4.4)
|
19
|
+
faraday (1.1.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
ruby2_keywords
|
22
|
+
faraday_middleware (1.0.0)
|
23
|
+
faraday (~> 1.0)
|
24
|
+
hashdiff (1.0.1)
|
25
|
+
method_source (1.0.0)
|
26
|
+
multipart-post (2.1.1)
|
27
|
+
pry (0.13.1)
|
28
|
+
coderay (~> 1.1)
|
29
|
+
method_source (~> 1.0)
|
30
|
+
public_suffix (4.0.6)
|
31
|
+
rake (13.0.1)
|
32
|
+
rexml (3.2.5)
|
33
|
+
rspec (3.9.0)
|
34
|
+
rspec-core (~> 3.9.0)
|
35
|
+
rspec-expectations (~> 3.9.0)
|
36
|
+
rspec-mocks (~> 3.9.0)
|
37
|
+
rspec-core (3.9.3)
|
38
|
+
rspec-support (~> 3.9.3)
|
39
|
+
rspec-expectations (3.9.3)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-mocks (3.9.1)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.9.0)
|
45
|
+
rspec-support (3.9.4)
|
46
|
+
ruby2_keywords (0.0.4)
|
47
|
+
webmock (3.9.3)
|
48
|
+
addressable (>= 2.3.6)
|
49
|
+
crack (>= 0.3.2)
|
50
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler (>= 1.17)
|
57
|
+
byebug
|
58
|
+
paychex!
|
59
|
+
pry
|
60
|
+
rake (>= 12.3.3)
|
61
|
+
rspec (>= 3.9.0)
|
62
|
+
webmock
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.4.4
|
@@ -2,9 +2,39 @@ module Paychex
|
|
2
2
|
class Client
|
3
3
|
module Companies
|
4
4
|
# Get a list of all the linked companies
|
5
|
-
# This will be unavailable once we have 200+ linked companies
|
6
5
|
def linked_companies
|
7
|
-
|
6
|
+
limit = per_page
|
7
|
+
opts = { limit: limit, offset: 0 }
|
8
|
+
response_content = []
|
9
|
+
current_page = 1
|
10
|
+
|
11
|
+
response = companies(opts)
|
12
|
+
|
13
|
+
begin
|
14
|
+
while response && response.body
|
15
|
+
companies_count = response.body.fetch('metadata').fetch('pagination').fetch('total')
|
16
|
+
|
17
|
+
break unless companies_count
|
18
|
+
|
19
|
+
no_of_pages = (companies_count.to_f / limit).ceil
|
20
|
+
|
21
|
+
companies_content = response.body.fetch('content').to_a
|
22
|
+
companies_content = companies_content.select { |c| c['hasPermission'] } if companies_content
|
23
|
+
response_content += companies_content
|
24
|
+
|
25
|
+
current_page += 1
|
26
|
+
if current_page <= no_of_pages
|
27
|
+
opts = { limit: limit, offset: (current_page - 1) * limit }
|
28
|
+
response = companies(opts)
|
29
|
+
else
|
30
|
+
break
|
31
|
+
end
|
32
|
+
end
|
33
|
+
rescue StandardError => e
|
34
|
+
return response_content
|
35
|
+
end
|
36
|
+
|
37
|
+
response_content
|
8
38
|
end
|
9
39
|
|
10
40
|
# Get profile of a linked company
|
@@ -85,5 +115,15 @@ module Paychex
|
|
85
115
|
ret
|
86
116
|
end
|
87
117
|
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def companies(options)
|
122
|
+
begin
|
123
|
+
get('companies', options)
|
124
|
+
rescue => e
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
end
|
88
128
|
end
|
89
129
|
end
|
@@ -1,98 +1,98 @@
|
|
1
|
-
require "paychex/version"
|
2
|
-
|
3
|
-
module Paychex
|
4
|
-
# Defines constants and methods related to configuration
|
5
|
-
module Configuration
|
6
|
-
# An array of valid keys in the options hash when configuring a {Paychex::API}
|
7
|
-
VALID_OPTIONS_KEYS = [
|
8
|
-
:access_token,
|
9
|
-
:host,
|
10
|
-
:endpoint,
|
11
|
-
:format,
|
12
|
-
:connection_options,
|
13
|
-
:proxy,
|
14
|
-
:environment,
|
15
|
-
:user_agent,
|
16
|
-
:per_page,
|
17
|
-
:timeout,
|
18
|
-
:open_timeout,
|
19
|
-
:token_timeout,
|
20
|
-
].freeze
|
21
|
-
|
22
|
-
# By default, don't set an access_token
|
23
|
-
DEFAULT_ACCESS_TOKEN = nil
|
24
|
-
|
25
|
-
# By default, return 20 resources per page when there is an pagination.
|
26
|
-
DEFAULT_PER_PAGE =
|
27
|
-
|
28
|
-
# By default, don't set connection options.
|
29
|
-
DEFAULT_CONNECTION_OPTIONS = {}
|
30
|
-
|
31
|
-
# Default timeout time is 60 seconds
|
32
|
-
DEFAULT_TIMEOUT = 60
|
33
|
-
|
34
|
-
# By default, the open timeout is 60 seconds.
|
35
|
-
DEFAULT_OPEN_TIMEOUT = 60
|
36
|
-
|
37
|
-
DEFAULT_TOKEN_TIMEOUT = Time.new
|
38
|
-
|
39
|
-
# By default, use sandbox environment
|
40
|
-
DEFAULT_HOST = "https://sandbox.api.paychex.com".freeze
|
41
|
-
|
42
|
-
# The endpoint that will be used to connect if none is set
|
43
|
-
DEFAULT_ENDPOINT = "https://sandbox.api.paychex.com/".freeze
|
44
|
-
|
45
|
-
# The response format appended to the path and sent in the 'Accept' header if none is set
|
46
|
-
#
|
47
|
-
# @note JSON is the only available format at this time
|
48
|
-
DEFAULT_FORMAT = :json
|
49
|
-
|
50
|
-
# By default, don't use a proxy server
|
51
|
-
DEFAULT_PROXY = nil
|
52
|
-
|
53
|
-
# By default, environment will be sandbox
|
54
|
-
DEFAULT_ENVIRONMENT = "sandbox"
|
55
|
-
|
56
|
-
# The user agent that will be sent to the API endpoint if none is set
|
57
|
-
DEFAULT_USER_AGENT = "Paychex Ruby Gem #{Paychex::VERSION}".freeze
|
58
|
-
|
59
|
-
# An array of valid request/response formats
|
60
|
-
VALID_FORMATS = [:json].freeze
|
61
|
-
|
62
|
-
# @private
|
63
|
-
attr_accessor *VALID_OPTIONS_KEYS
|
64
|
-
|
65
|
-
# When this module is extended, set all configuration options to their default values
|
66
|
-
def self.extended(base)
|
67
|
-
base.reset
|
68
|
-
end
|
69
|
-
|
70
|
-
# Convenience method to allow configuration options to be set in a block
|
71
|
-
def configure
|
72
|
-
yield self
|
73
|
-
end
|
74
|
-
|
75
|
-
# Create a hash of options and their values
|
76
|
-
def options
|
77
|
-
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
78
|
-
option.merge!(key => send(key))
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Reset all configuration options to defaults
|
83
|
-
def reset
|
84
|
-
self.access_token = DEFAULT_ACCESS_TOKEN
|
85
|
-
self.host = DEFAULT_HOST
|
86
|
-
self.endpoint = DEFAULT_ENDPOINT
|
87
|
-
self.connection_options = DEFAULT_CONNECTION_OPTIONS
|
88
|
-
self.format = DEFAULT_FORMAT
|
89
|
-
self.proxy = DEFAULT_PROXY
|
90
|
-
self.environment = DEFAULT_ENVIRONMENT
|
91
|
-
self.user_agent = DEFAULT_USER_AGENT
|
92
|
-
self.per_page = DEFAULT_PER_PAGE
|
93
|
-
self.timeout = DEFAULT_TIMEOUT
|
94
|
-
self.open_timeout = DEFAULT_OPEN_TIMEOUT
|
95
|
-
self.token_timeout = DEFAULT_TOKEN_TIMEOUT
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
1
|
+
require "paychex/version"
|
2
|
+
|
3
|
+
module Paychex
|
4
|
+
# Defines constants and methods related to configuration
|
5
|
+
module Configuration
|
6
|
+
# An array of valid keys in the options hash when configuring a {Paychex::API}
|
7
|
+
VALID_OPTIONS_KEYS = [
|
8
|
+
:access_token,
|
9
|
+
:host,
|
10
|
+
:endpoint,
|
11
|
+
:format,
|
12
|
+
:connection_options,
|
13
|
+
:proxy,
|
14
|
+
:environment,
|
15
|
+
:user_agent,
|
16
|
+
:per_page,
|
17
|
+
:timeout,
|
18
|
+
:open_timeout,
|
19
|
+
:token_timeout,
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
# By default, don't set an access_token
|
23
|
+
DEFAULT_ACCESS_TOKEN = nil
|
24
|
+
|
25
|
+
# By default, return 20 resources per page when there is an pagination.
|
26
|
+
DEFAULT_PER_PAGE = 100
|
27
|
+
|
28
|
+
# By default, don't set connection options.
|
29
|
+
DEFAULT_CONNECTION_OPTIONS = {}
|
30
|
+
|
31
|
+
# Default timeout time is 60 seconds
|
32
|
+
DEFAULT_TIMEOUT = 60
|
33
|
+
|
34
|
+
# By default, the open timeout is 60 seconds.
|
35
|
+
DEFAULT_OPEN_TIMEOUT = 60
|
36
|
+
|
37
|
+
DEFAULT_TOKEN_TIMEOUT = Time.new
|
38
|
+
|
39
|
+
# By default, use sandbox environment
|
40
|
+
DEFAULT_HOST = "https://sandbox.api.paychex.com".freeze
|
41
|
+
|
42
|
+
# The endpoint that will be used to connect if none is set
|
43
|
+
DEFAULT_ENDPOINT = "https://sandbox.api.paychex.com/".freeze
|
44
|
+
|
45
|
+
# The response format appended to the path and sent in the 'Accept' header if none is set
|
46
|
+
#
|
47
|
+
# @note JSON is the only available format at this time
|
48
|
+
DEFAULT_FORMAT = :json
|
49
|
+
|
50
|
+
# By default, don't use a proxy server
|
51
|
+
DEFAULT_PROXY = nil
|
52
|
+
|
53
|
+
# By default, environment will be sandbox
|
54
|
+
DEFAULT_ENVIRONMENT = "sandbox"
|
55
|
+
|
56
|
+
# The user agent that will be sent to the API endpoint if none is set
|
57
|
+
DEFAULT_USER_AGENT = "Paychex Ruby Gem #{Paychex::VERSION}".freeze
|
58
|
+
|
59
|
+
# An array of valid request/response formats
|
60
|
+
VALID_FORMATS = [:json].freeze
|
61
|
+
|
62
|
+
# @private
|
63
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
64
|
+
|
65
|
+
# When this module is extended, set all configuration options to their default values
|
66
|
+
def self.extended(base)
|
67
|
+
base.reset
|
68
|
+
end
|
69
|
+
|
70
|
+
# Convenience method to allow configuration options to be set in a block
|
71
|
+
def configure
|
72
|
+
yield self
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create a hash of options and their values
|
76
|
+
def options
|
77
|
+
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
78
|
+
option.merge!(key => send(key))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Reset all configuration options to defaults
|
83
|
+
def reset
|
84
|
+
self.access_token = DEFAULT_ACCESS_TOKEN
|
85
|
+
self.host = DEFAULT_HOST
|
86
|
+
self.endpoint = DEFAULT_ENDPOINT
|
87
|
+
self.connection_options = DEFAULT_CONNECTION_OPTIONS
|
88
|
+
self.format = DEFAULT_FORMAT
|
89
|
+
self.proxy = DEFAULT_PROXY
|
90
|
+
self.environment = DEFAULT_ENVIRONMENT
|
91
|
+
self.user_agent = DEFAULT_USER_AGENT
|
92
|
+
self.per_page = DEFAULT_PER_PAGE
|
93
|
+
self.timeout = DEFAULT_TIMEOUT
|
94
|
+
self.open_timeout = DEFAULT_OPEN_TIMEOUT
|
95
|
+
self.token_timeout = DEFAULT_TOKEN_TIMEOUT
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/paychex/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Paychex
|
2
|
-
VERSION = '0.3.
|
3
|
-
end
|
1
|
+
module Paychex
|
2
|
+
VERSION = '0.3.4'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paychex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mayank Dedhia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.0.3.1
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Ruby wrapper for paychex.com APIs.
|