paylocity_web_service 0.2.1 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33f09a98ae188a34663ec0cebb9f794cf7047fd30450554c96e9bc96aa4f878b
4
- data.tar.gz: 1463dad0fec22d676864f791b4526ea2e696d1741d462435a1b3648525243dbf
3
+ metadata.gz: 8ed38f1a130e21d527fa2f42777314ecf3a200eeceb28cd1c1d6d6bebf13d5c5
4
+ data.tar.gz: 67d80bab97b9568534e1c031683267cdbaf503caabd4264d58d98e287be60104
5
5
  SHA512:
6
- metadata.gz: b1e62adc3cf74ac566588e02874a2ca991a204266fbedaa2c4cf20d5098ac653c40ee66b2af1eecd1849db2b07ba324d57a58d0a38d1ff9bf8ad732d6c5aa27e
7
- data.tar.gz: 1f14ab469633028556a3c58714c15acf4c64d6e7e63b91d5479e11a8421d496cf4dee75d98a0a5c881e359b14d1d2ae5844b76f053b01dd869b48df86fbc3ee7
6
+ metadata.gz: ff5f640ac32954fbbbd6641d2b6c709d65b91ff4dc88844f6fbaf8525af539d69340afaf21114b82eff2020c986842a09bd2d54744068afcf3cd51a86fd94f37
7
+ data.tar.gz: dd71548e6420fb38bebbd99848d5f960f1d1d51fd79230379a8853f0686fb2c5e90dd7227e975fdafa3cbecae0eec14d95ed2dd9462fc204cd76032b07e82a66
@@ -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
@@ -11,3 +11,4 @@ Gemfile.lock
11
11
 
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
+ .env.test
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 'webmock', '~> 3.8', '>= 3.8.2'
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 = PaylocityWebService::Cache.read(access_token_cache_key)
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
- PaylocityWebService::Cache.write(access_token_cache_key, token, expires_in)
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
- 'access_token_cache_key'
36
+ raise 'company_id is required' if company_id.nil?
37
+ "PaylocityCompany/#{company_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, expires_in = 3600 )
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.flush!
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$/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaylocityWebService
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
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.1
4
+ version: 0.2.3
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-06-08 00:00:00.000000000 Z
11
+ date: 2022-07-11 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.0.8
98
+ rubygems_version: 3.2.3
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Ruby wrapper for the API of Paylocity Web Service
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.6
6
- before_install: gem install bundler -v 2.2.15