paylocity_web_service 0.1.5 → 0.2.3

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: b13bc282646a644fa31a73793b130888d3835a1a2cfb4680503a984692dff8a7
4
- data.tar.gz: 79f972097465eb78320d651dcf4de69176c2ced85dc49add173b42fc00cc2514
3
+ metadata.gz: 8ed38f1a130e21d527fa2f42777314ecf3a200eeceb28cd1c1d6d6bebf13d5c5
4
+ data.tar.gz: 67d80bab97b9568534e1c031683267cdbaf503caabd4264d58d98e287be60104
5
5
  SHA512:
6
- metadata.gz: f1019e51d9a9c4c4c8191fd02fd01c999a7af501f3d03ef64ee446e314028f22b5c23b924f53508ce9194db5e98e0da4fb2ef510783a53c6d843364faa5ac7d4
7
- data.tar.gz: 0ae1f759d98638bbafeabbdc4373c4ff3c68364f53f06a6447f59c74a3e26f93ff10c1302f10978d192aa175818b50dff0462d68f9d0a09f27894f9035163478
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 'pry-byebug'
11
+ gem 'rails'
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,8 +9,9 @@ module PaylocityWebService
9
9
  store[key][:value]
10
10
  end
11
11
 
12
- def self.write(key, value, expires_in = 3600 )
13
- expires_at = (Time.now.to_i + expires_in) - 60
12
+ def self.write(key, value, options = {} )
13
+ expires_in = options[:expires_in] || 3600
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
16
17
 
@@ -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
@@ -1,16 +1,16 @@
1
1
  module PaylocityWebService
2
2
  class Client
3
3
  module Companies
4
- CodeResources = %W(costcenter1 costcenter2 costcenter3 deductions earnings taxes paygrade positions)
4
+ CodeResources = %W(costCenter1 costCenter2 costCenter3 deductions earnings taxes paygrade positions)
5
5
 
6
6
  def company_schema
7
7
  get("/api/v2/companies/#{company_id}/openapi")
8
8
  end
9
9
 
10
10
  # Available Code Resources:
11
- # - costcenter1
12
- # - costcenter2
13
- # - costcenter3
11
+ # - costCenter1
12
+ # - costCenter2
13
+ # - costCenter3
14
14
  # - deductions
15
15
  # - earnings
16
16
  # - taxes
@@ -23,6 +23,15 @@ module PaylocityWebService
23
23
  def code_resources
24
24
  CodeResources
25
25
  end
26
+
27
+ # Paylocity hasn't provide a way to check the connectivity of the API, we have to fire a request to check it.
28
+ def company_connected?
29
+ return true if company_codes('costCenter1').status == 200
30
+ return true if company_schema.code == 200
31
+ false
32
+ rescue => e
33
+ false
34
+ end
26
35
  end
27
36
  end
28
37
  end
@@ -1,8 +1,8 @@
1
1
  module PaylocityWebService
2
2
  class Client
3
3
  module Credentials
4
- def create_client_credential
5
- post("/api/v2/credentials/secrets")
4
+ def create_client_credential(options={})
5
+ post("/api/v2/credentials/secrets", options)
6
6
  end
7
7
  end
8
8
  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.1.5"
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.1.5
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: 2021-11-18 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