paylocity_web_service 0.2.1 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +38 -0
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/lib/paylocity_web_service/authentication.rb +13 -4
- data/lib/paylocity_web_service/cache.rb +3 -2
- data/lib/paylocity_web_service/connection.rb +1 -0
- data/lib/paylocity_web_service/version.rb +1 -1
- metadata +4 -4
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2bf38b743b850dd1f4cbf6ca44c3952962a3583ad09fef82b5dc5144fb9b254
|
4
|
+
data.tar.gz: a9eec52d42d4d941fa1a78d52fc006a30267259618826217bd6654993205e47f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28171fc6a94a2a9af8e9ad2bbfca5306cd814ce498bd28be8043af3e72e7f47491f823ad1092c378c859fa7d16e2b02b10b14ed9daa54ca36de708558b1e67b2
|
7
|
+
data.tar.gz: 07d6f029610cbd1a1b6930b8f9496f7bd588f58aa0b8ee9c63a85bd23b23eeed3398cf96af5e3f4eecabac962da3e5c4b7a2789f195f03dcd42046e6b237f2ea
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "master" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "master" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
environment: test
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: SANDBOX_PAYLOCITY_CLIENT_ID=${{ secrets.SANDBOX_PAYLOCITY_CLIENT_ID }} SANDBOX_PAYLOCITY_CLIENT_SECRET=${{ secrets.SANDBOX_PAYLOCITY_CLIENT_SECRET }} SANDBOX_PAYLOCITY_DEMO_COMPANY_ID=${{ secrets.SANDBOX_PAYLOCITY_DEMO_COMPANY_ID }} SANDBOX_PAYLOCITY_ENDPOINT=${{ secrets.SANDBOX_PAYLOCITY_ENDPOINT }} SANDBOX_PAYLOCITY_PUBLIC_KEY="${{ secrets.SANDBOX_PAYLOCITY_PUBLIC_KEY }}" bundle exec rspec
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -8,10 +8,11 @@ gemspec
|
|
8
8
|
# The following gems are required for local development and will not be included by `gem install mygem` or `bundle add mygem`.
|
9
9
|
group :development, :test do
|
10
10
|
gem 'awesome_print', require: 'ap'
|
11
|
+
gem 'rails'
|
11
12
|
gem 'pry'
|
12
13
|
gem 'rubocop'
|
13
14
|
gem 'rake'
|
14
15
|
gem 'bundler'
|
15
16
|
gem "rspec", "~> 3.0"
|
16
|
-
gem '
|
17
|
+
gem 'dotenv'
|
17
18
|
end
|
@@ -5,7 +5,7 @@ require 'paylocity_web_service/cache'
|
|
5
5
|
module PaylocityWebService
|
6
6
|
module Authentication
|
7
7
|
def access_token
|
8
|
-
token =
|
8
|
+
token = cache_store.read(access_token_cache_key)
|
9
9
|
|
10
10
|
if token.nil?
|
11
11
|
refresh_token
|
@@ -26,15 +26,24 @@ module PaylocityWebService
|
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
29
|
body = JSON.parse(resp.body)
|
31
30
|
token, expires_in = body['access_token'], body['expires_in']
|
32
|
-
|
31
|
+
cache_store.write(access_token_cache_key, token, expires_in: expires_in)
|
33
32
|
token
|
34
33
|
end
|
35
34
|
|
36
35
|
def access_token_cache_key
|
37
|
-
'
|
36
|
+
raise 'client_id is required' if client_id.nil?
|
37
|
+
"PaylocityClientID/#{client_id}/AccessToken/#{endpoint}"
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def cache_store
|
42
|
+
if defined?(Rails)
|
43
|
+
Rails.cache
|
44
|
+
else
|
45
|
+
PaylocityWebService::Cache
|
46
|
+
end
|
38
47
|
end
|
39
48
|
|
40
49
|
def basic_auth_token
|
@@ -9,7 +9,8 @@ module PaylocityWebService
|
|
9
9
|
store[key][:value]
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.write(key, value,
|
12
|
+
def self.write(key, value, options = {} )
|
13
|
+
expires_in = options[:expires_in] || 3600
|
13
14
|
expires_at = (Time.now.to_i + expires_in.to_i) - 60
|
14
15
|
store[key] = { value: value, expires_at: expires_at}
|
15
16
|
end
|
@@ -18,7 +19,7 @@ module PaylocityWebService
|
|
18
19
|
@cache_store ||= {}
|
19
20
|
end
|
20
21
|
|
21
|
-
def self.
|
22
|
+
def self.clear
|
22
23
|
@cache_store = {}
|
23
24
|
end
|
24
25
|
end
|
@@ -95,6 +95,7 @@ module PaylocityWebService
|
|
95
95
|
conn.use Faraday::Request::Authorization, :Bearer, access_token
|
96
96
|
conn.request :retry, max: 2
|
97
97
|
conn.request :json
|
98
|
+
conn.request :instrumentation, name: 'request.paylocity'
|
98
99
|
|
99
100
|
# conn.use PaylocityWebService::Middleware::Response::RaiseError
|
100
101
|
conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paylocity_web_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Lv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -45,10 +45,10 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/rspec.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
51
|
- ".rubocop.yml"
|
51
|
-
- ".travis.yml"
|
52
52
|
- CHANGELOG.md
|
53
53
|
- CODE_OF_CONDUCT.md
|
54
54
|
- Gemfile
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
98
|
+
rubygems_version: 3.1.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Ruby wrapper for the API of Paylocity Web Service
|