paychex_api 0.0.3 → 0.0.4
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 +5 -5
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/lib/paychex_api/api_array.rb +2 -1
- data/lib/paychex_api/client.rb +32 -4
- data/lib/paychex_api/client/notifications.rb +9 -0
- data/lib/paychex_api/version.rb +1 -1
- data/spec/paychex_api/client/notifications_spec.rb +13 -0
- data/spec/support/fake_paychex.rb +6 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7251288b681c23b4098ba4bca7f19f0bd41bb734b393aeaf14248dc125bb8858
|
4
|
+
data.tar.gz: 9c0ebd502d7bc21e7787f08e850fcd17565171ab36f254b8bde9f8067de54d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e4f6648e59b1b540043aee20953417e80abad7a50a81517413ab1eb42b77b4e9a424edd1679c7f140e4f77d4f37b8bcd6f6cc1aa0292c3b176b920bd9e4a16
|
7
|
+
data.tar.gz: c20be9e0f548f6a9c7ad88404493c26afb077e4b6bae82839696668e51f065c20dc4473b4bf1d65b3067c3247fcf1deeb559236273df49ba28c0b17dee0d140b
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ module PaychexAPI
|
|
8
8
|
@next_page = nil
|
9
9
|
@prev_page = nil
|
10
10
|
|
11
|
-
attr_reader :status, :headers, :members, :links, :metadata
|
11
|
+
attr_reader :status, :headers, :members, :links, :metadata, :errors
|
12
12
|
attr_writer :next_page
|
13
13
|
|
14
14
|
def self.process_response(response, api_client)
|
@@ -20,6 +20,7 @@ module PaychexAPI
|
|
20
20
|
@api_client = api_client
|
21
21
|
@links = []
|
22
22
|
@metadata = {}
|
23
|
+
@errors = response.body['errors']
|
23
24
|
case response.status
|
24
25
|
when *((200..206).to_a + [302])
|
25
26
|
apply_response_metadata(response)
|
data/lib/paychex_api/client.rb
CHANGED
@@ -3,6 +3,7 @@ require 'faraday'
|
|
3
3
|
require 'footrest'
|
4
4
|
require 'footrest/http_error'
|
5
5
|
require 'footrest/pagination'
|
6
|
+
require 'faraday_middleware'
|
6
7
|
require 'footrest/follow_redirects'
|
7
8
|
require 'footrest/parse_json'
|
8
9
|
require 'base64'
|
@@ -17,6 +18,7 @@ module PaychexAPI
|
|
17
18
|
ORGANIZATIONS_PATH = '/organizations'.freeze
|
18
19
|
JOB_TITLES_PATH = '/jobtitles'.freeze
|
19
20
|
WORKER_STATUSES_PATH = '/workerstatuses'.freeze
|
21
|
+
NOTIFICATIONS_PATH = '/notifications'.freeze
|
20
22
|
WORKERS_PATH = '/workers'.freeze
|
21
23
|
COMMUNICATIONS_PATH = '/communications'.freeze
|
22
24
|
COMPENSATION_PATH = '/compensation'.freeze
|
@@ -41,7 +43,7 @@ module PaychexAPI
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def authorize
|
44
|
-
response =
|
46
|
+
response = faraday_auth.post(
|
45
47
|
OAUTH_TOKEN_PATH,
|
46
48
|
client_id: config[:client_id],
|
47
49
|
client_secret: config[:client_secret],
|
@@ -64,15 +66,25 @@ module PaychexAPI
|
|
64
66
|
faraday
|
65
67
|
end
|
66
68
|
|
67
|
-
def
|
69
|
+
def faraday_auth_request(faraday)
|
70
|
+
faraday.request :multipart
|
71
|
+
faraday.request :url_encoded
|
72
|
+
faraday
|
73
|
+
end
|
74
|
+
|
75
|
+
def faraday_auth_headers(faraday)
|
68
76
|
faraday.headers[:accept] = 'application/json'
|
69
77
|
faraday.headers[:user_agent] = 'Footrest'
|
70
78
|
faraday
|
71
79
|
end
|
72
80
|
|
81
|
+
def faraday_default_headers(faraday)
|
82
|
+
faraday.headers['Content-Type'] = 'application/json'
|
83
|
+
faraday
|
84
|
+
end
|
85
|
+
|
73
86
|
def faraday_default_request(faraday)
|
74
|
-
faraday.request :
|
75
|
-
faraday.request :url_encoded
|
87
|
+
faraday.request :json
|
76
88
|
faraday
|
77
89
|
end
|
78
90
|
|
@@ -100,6 +112,22 @@ module PaychexAPI
|
|
100
112
|
faraday
|
101
113
|
end
|
102
114
|
|
115
|
+
def faraday_auth_config(faraday)
|
116
|
+
faraday = faraday_logger(faraday)
|
117
|
+
faraday = faraday_auth_request(faraday)
|
118
|
+
faraday = faraday_default_use(faraday)
|
119
|
+
faraday = faraday_auth_headers(faraday)
|
120
|
+
faraday = faraday_proxy(faraday)
|
121
|
+
faraday.adapter Faraday.default_adapter
|
122
|
+
faraday
|
123
|
+
end
|
124
|
+
|
125
|
+
def faraday_auth
|
126
|
+
Faraday.new(url: config[:prefix]) do |faraday|
|
127
|
+
faraday_auth_config(faraday)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
103
131
|
def default_faraday
|
104
132
|
Faraday.new(url: config[:prefix]) do |faraday|
|
105
133
|
faraday_config(faraday)
|
data/lib/paychex_api/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
describe PaychexAPI::Client::Notifications do
|
3
|
+
before do
|
4
|
+
@client = PaychexAPI::Client.new(
|
5
|
+
prefix: 'http://test.paychex.com', client_id: 'client_id', client_secret: 'client_secret'
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should send a notification' do
|
10
|
+
response = @client.send_notification('f7f9c815-0d4c-46e5-9434-5cc19470d1ed-3520000031155394')
|
11
|
+
expect(response.status).to(eq(200))
|
12
|
+
end
|
13
|
+
end
|
@@ -54,6 +54,12 @@ class FakePaychex < Sinatra::Base
|
|
54
54
|
get_json_data 200, 'organizations.json'
|
55
55
|
end
|
56
56
|
|
57
|
+
# Notifications
|
58
|
+
|
59
|
+
post %r{/notifications/\S+$} do
|
60
|
+
get_json_data 200, 'communications.json'
|
61
|
+
end
|
62
|
+
|
57
63
|
private
|
58
64
|
|
59
65
|
def get_json_data(response_code, file_name)
|
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.
|
4
|
+
version: 0.0.4
|
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-05-
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- lib/paychex_api/client.rb
|
240
240
|
- lib/paychex_api/client/associations.rb
|
241
241
|
- lib/paychex_api/client/companies.rb
|
242
|
+
- lib/paychex_api/client/notifications.rb
|
242
243
|
- lib/paychex_api/client/workers.rb
|
243
244
|
- lib/paychex_api/version.rb
|
244
245
|
- paychex_api.gemspec
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- spec/paychex_api/api_array_spec.rb
|
251
252
|
- spec/paychex_api/client/associations_spec.rb
|
252
253
|
- spec/paychex_api/client/companies_spec.rb
|
254
|
+
- spec/paychex_api/client/notifications_spec.rb
|
253
255
|
- spec/paychex_api/client/workers_spec.rb
|
254
256
|
- spec/paychex_api/client_spec.rb
|
255
257
|
- spec/paychex_api/paychex_api_spec.rb
|
@@ -275,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
277
|
version: '0'
|
276
278
|
requirements: []
|
277
279
|
rubyforge_project:
|
278
|
-
rubygems_version: 2.
|
280
|
+
rubygems_version: 2.7.3
|
279
281
|
signing_key:
|
280
282
|
specification_version: 4
|
281
283
|
summary: Paychex API
|
@@ -288,9 +290,9 @@ test_files:
|
|
288
290
|
- spec/paychex_api/api_array_spec.rb
|
289
291
|
- spec/paychex_api/client/associations_spec.rb
|
290
292
|
- spec/paychex_api/client/companies_spec.rb
|
293
|
+
- spec/paychex_api/client/notifications_spec.rb
|
291
294
|
- spec/paychex_api/client/workers_spec.rb
|
292
295
|
- spec/paychex_api/client_spec.rb
|
293
296
|
- spec/paychex_api/paychex_api_spec.rb
|
294
297
|
- spec/support/fake_paychex.rb
|
295
298
|
- spec/test_helper.rb
|
296
|
-
has_rdoc:
|