ucb-hcm 1.0 → 3.0
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 -0
- data/.ruby-version +1 -0
- data/.travis.yml +16 -0
- data/README.md +82 -12
- data/bin/setup +38 -0
- data/lib/ucb/hcm/api.rb +0 -1
- data/lib/ucb/hcm/client.rb +0 -3
- data/lib/ucb/hcm/configuration.rb +1 -1
- data/lib/ucb/hcm/request.rb +2 -3
- data/lib/ucb/hcm/response.rb +5 -1
- data/lib/ucb/hcm/version.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/support/test_credentials.rb +4 -0
- data/spec/ucb/hcm/api_spec.rb +71 -0
- data/spec/ucb/hcm/configuration_spec.rb +31 -0
- data/spec/ucb/hcm/hcm_spec.rb +8 -0
- data/{test/ucb/hcm/request_test.rb → spec/ucb/hcm/request_spec.rb} +7 -7
- data/ucb-hcm.gemspec +5 -3
- metadata +52 -27
- data/Rakefile +0 -9
- data/lib/ucb/hcm/api/department.rb +0 -12
- data/lib/ucb/hcm/api/employee.rb +0 -14
- data/lib/ucb/hcm/api/job.rb +0 -14
- data/lib/ucb/hcm/resource.rb +0 -93
- data/test/helper.rb +0 -5
- data/test/support/shared_examples.rb +0 -17
- data/test/support/test_credentials.rb +0 -4
- data/test/ucb/hcm/api_test.rb +0 -144
- data/test/ucb/hcm/client_test.rb +0 -33
- data/test/ucb/hcm/configuration_test.rb +0 -33
- data/test/ucb/hcm/hcm_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62c9ba3f962308201cf3d2668c222e3b74615d7a5ae111335d09ab6c7334d181
|
4
|
+
data.tar.gz: a2cde1633debc69794e4d5ad4acc4755f258bb26da31ccf701623fbed0a09774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bef13a7e84c972a74b126b32544cf15eeb77ba79d32fcba3e4c543a1f1e8d159e42bb17f9daa1ac44aadcd84ee7a0e2017aa4efceedbf8e3043815f98f09c91
|
7
|
+
data.tar.gz: 3a9feb88955fae6f323ca4cb10a6095a19b9e8ffe38da05686f15bc17eb8f82e670e8bce70bde31b8c7042c51fa7078da399addf24d02f0ee9c9190d6ded9b90
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
branches:
|
2
|
+
except:
|
3
|
+
- /^.*\/.*+$/
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
- 2.5.1
|
7
|
+
install: true
|
8
|
+
script:
|
9
|
+
- bin/setup
|
10
|
+
before_deploy:
|
11
|
+
- git tag $TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER
|
12
|
+
cache:
|
13
|
+
directories:
|
14
|
+
- vendor/bundle
|
15
|
+
notifications:
|
16
|
+
slack: infinitered:4s2uT0dj614H6BUJteVhFGqo
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Ucb::Hcm
|
2
2
|
|
3
|
-
Ucb::Hcm is a lightweight ruby wrapper around UC Berkeley's Human Capital Management API.
|
4
|
-
https://developer.berkeley.edu/apidocs/employee
|
3
|
+
Ucb::Hcm is a lightweight ruby wrapper around [UC Berkeley's Human Capital Management API](https://api-central.berkeley.edu/api/14/interactive-docs).
|
5
4
|
|
6
5
|
Version 1.0 of this gem supports the v2 API, documented in the link above. UCB now has v3 of the API - we'll skip version 2.0 of the gem and make version 3.0 support the v3 API.
|
7
6
|
|
@@ -9,33 +8,104 @@ Version 1.0 of this gem supports the v2 API, documented in the link above. UCB n
|
|
9
8
|
|
10
9
|
Add this line to your application's Gemfile:
|
11
10
|
|
12
|
-
gem 'ucb-hcm'
|
11
|
+
gem 'ucb-hcm', "~> 3"
|
13
12
|
|
14
13
|
And then execute:
|
15
14
|
|
16
15
|
$ bundle
|
17
16
|
|
18
|
-
Or install it yourself
|
17
|
+
Or install it by yourself:
|
19
18
|
|
20
19
|
$ gem install ucb-hcm
|
21
20
|
|
22
|
-
##
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
Configure your app with your API credentials from [UCB's API Central](https://api-central.berkeley.edu/api/14/credentials).
|
23
24
|
|
24
25
|
Ucb::Hcm.configure do |hcm|
|
25
26
|
hcm.app_id = "APP_ID"
|
26
27
|
hcm.app_key = "APP_KEY"
|
27
|
-
hcm.endpoint = "https://
|
28
|
+
hcm.endpoint = "https://apis.berkeley.edu/dev/hr/v3"
|
28
29
|
end
|
29
30
|
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
:rotating_light: Note: Version 3.x of this gem only supports v3 of the API. :rotating_light:
|
30
34
|
|
35
|
+
### Fetch Employees
|
36
|
+
|
37
|
+
```ruby
|
31
38
|
client = Ucb::Hcm::Client.new
|
32
|
-
client.get("/employees
|
33
|
-
|
39
|
+
response = client.get("/employees", { limit: 20, previous: 0, next: 20 })
|
40
|
+
|
41
|
+
>> response.data
|
42
|
+
=> [
|
43
|
+
{
|
44
|
+
"identifiers"=> [
|
45
|
+
{"type"=>"hr-employee-id", "id"=>"10141478"}
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"identifiers"=>[
|
50
|
+
{"type"=>"hr-employee-id", "id"=>"10272831"},
|
51
|
+
{"type"=>"legacy-hr-employee-id", "id"=>"12521372"}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
...
|
55
|
+
]
|
56
|
+
```
|
57
|
+
|
58
|
+
### Fetch specific Employee
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
client = Ucb::Hcm::Client.new
|
62
|
+
response = client.get("/employees/10272831", {"id-type" => "hr-employee-id"})
|
63
|
+
|
64
|
+
>> response.data
|
65
|
+
=> {
|
66
|
+
"identifiers" => [
|
67
|
+
{"type" => "campus-uid", "id" => "20108691"}, {"type" => "campus-solutions-id"}, {"type" => "student-id"}, {"type" => "hr-employee-id", "id" => "10272831"}, {"type" => "legacy-hr-employee-id"}, {"type" => "calnet-id"}
|
68
|
+
],
|
69
|
+
"names" => [{
|
70
|
+
"type "= >{"code" => "PRI", "description" => "Primary"},
|
71
|
+
"familyName" => "Kumar",
|
72
|
+
"givenName" => "Siri",
|
73
|
+
"lastChangedBy" => {"id" => "10000499"},
|
74
|
+
"fromDate" => "2018-10-01"
|
75
|
+
}],
|
76
|
+
...
|
77
|
+
}
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
### Fetch an Employee's jobs
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
client = Ucb::Hcm::Client.new
|
85
|
+
response = client.get("/employees/10272831/jobs", {"id-type" => "hr-employee-id"})
|
86
|
+
|
87
|
+
# The jobs api sometimes returns an array with the first element
|
88
|
+
# containing the real job data and the second an empty hash :(.
|
89
|
+
# For example: [{<real_data>}, {}]
|
90
|
+
>> response.data.first["jobs"]
|
91
|
+
=> [
|
92
|
+
{
|
93
|
+
"number" => 0,
|
94
|
+
"sequence" => 0,
|
95
|
+
"type" => {
|
96
|
+
"code" => "2",
|
97
|
+
"description" => "Staff: Career"
|
98
|
+
},
|
99
|
+
...
|
100
|
+
}
|
101
|
+
]
|
102
|
+
```
|
34
103
|
|
35
104
|
## Contributing
|
36
105
|
|
37
106
|
1. Fork it ( https://github.com/[my-github-username]/ucb-hcm/fork )
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
107
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
108
|
+
1. Ask for `.env` file from previous developer and run `source .env`
|
109
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
110
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
111
|
+
1. Create a new Pull Request
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
def banner(msg, suppress_newline=false)
|
13
|
+
puts "#{suppress_newline ? "" : "\n"}== #{msg} =="
|
14
|
+
end
|
15
|
+
|
16
|
+
def ci?
|
17
|
+
ENV["TRAVIS"] == "true"
|
18
|
+
end
|
19
|
+
|
20
|
+
chdir APP_ROOT do
|
21
|
+
banner "Checking Ruby version"
|
22
|
+
required_version = `cat .ruby-version`.gsub(/[a-zA-Z]|-/, "").strip
|
23
|
+
if RUBY_VERSION != required_version
|
24
|
+
puts "Wrong Ruby version - please use #{required_version} (found: #{RUBY_VERSION})"
|
25
|
+
exit -1
|
26
|
+
end
|
27
|
+
|
28
|
+
banner "Installing dependencies"
|
29
|
+
system! 'gem install bundler --conservative'
|
30
|
+
system('bundle check') || system!('bundle install')
|
31
|
+
|
32
|
+
banner "Running test suite to confirm setup"
|
33
|
+
system! "bundle exec rspec"
|
34
|
+
|
35
|
+
unless ci?
|
36
|
+
puts " =========== SETUP COMPLETE ==============="
|
37
|
+
end
|
38
|
+
end
|
data/lib/ucb/hcm/api.rb
CHANGED
data/lib/ucb/hcm/client.rb
CHANGED
@@ -5,7 +5,7 @@ module Ucb
|
|
5
5
|
VALID_OPTIONS_KEYS = [:app_id, :app_key, :format].freeze
|
6
6
|
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
7
7
|
|
8
|
-
DEFAULT_ENDPOINT = 'https://apis.berkeley.edu/
|
8
|
+
DEFAULT_ENDPOINT = 'https://apis.berkeley.edu/test/hr/v3'
|
9
9
|
DEFAULT_METHOD = :get
|
10
10
|
DEFAULT_USER_AGENT = "Ucb::Hcm API Ruby Gem #{Ucb::Hcm::VERSION}".freeze
|
11
11
|
|
data/lib/ucb/hcm/request.rb
CHANGED
@@ -21,8 +21,8 @@ module Ucb
|
|
21
21
|
respond client.post(resource, params)
|
22
22
|
end
|
23
23
|
|
24
|
-
def respond(
|
25
|
-
Response.new
|
24
|
+
def respond(response)
|
25
|
+
Response.new(response)
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -50,7 +50,6 @@ module Ucb
|
|
50
50
|
def base_endpoint
|
51
51
|
endpoint
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
data/lib/ucb/hcm/response.rb
CHANGED
@@ -20,7 +20,11 @@ module Ucb
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def data
|
23
|
-
|
23
|
+
if raw_response["response"]&.count == 1
|
24
|
+
raw_response["response"]&.first
|
25
|
+
else
|
26
|
+
raw_response["response"]
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def data_fetcher=(block)
|
data/lib/ucb/hcm/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
RSpec.describe 'api' do
|
5
|
+
before do
|
6
|
+
@client = Ucb::Hcm::Client.new(app_id: TestCredentials::TEST_APP_ID, app_key: TestCredentials::TEST_APP_KEY)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#get" do
|
10
|
+
describe "GET /employees/:id" do
|
11
|
+
it "returns employee data w/ valid id & legacy-hr-employee-type" do
|
12
|
+
response = @client.get("/employees/10135532", {"id-type" => "hr-employee-id"})
|
13
|
+
|
14
|
+
expect(response.success?).to eq true
|
15
|
+
expect(response.data["identifiers"].first.has_key?("type")).to eq true
|
16
|
+
|
17
|
+
names = response.data["names"]
|
18
|
+
expect(names.empty? || names.first.has_key?("familyName")).to eq true
|
19
|
+
|
20
|
+
addresses = response.data["addresses"]
|
21
|
+
expect(addresses.empty? || addresses.first.has_key?("address1")).to eq true
|
22
|
+
|
23
|
+
emails = response.data["emails"]
|
24
|
+
expect(emails.empty? || emails.first.has_key?("emailAddress")).to eq true
|
25
|
+
|
26
|
+
phones = response.data["phones"]
|
27
|
+
expect(phones.empty? || phones.first.has_key?("number")).to eq true
|
28
|
+
end
|
29
|
+
|
30
|
+
# this used to return 404 - now it just seems to default to hr-employee-id
|
31
|
+
it "succeeds with invalid id-type" do
|
32
|
+
response = @client.get("/employees/10135532", {"id-type" => "invalid-type"})
|
33
|
+
|
34
|
+
expect(response.success?).to be true
|
35
|
+
end
|
36
|
+
|
37
|
+
# this used to return 500 - now it returns 200 with an empty response
|
38
|
+
it "returns empty response if id is invalid" do
|
39
|
+
response = @client.get("/employees/invalidId", {"id-type" => "legacy-hr-employee-id"})
|
40
|
+
|
41
|
+
expect(response.success?).to be true
|
42
|
+
expect(response.data).to be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "fetch employee jobs" do
|
47
|
+
it "returns all an employees jobs" do
|
48
|
+
response = @client.get("/employees/010789601/jobs", {"id-type" => "legacy-hr-employee-id"})
|
49
|
+
|
50
|
+
expect(response.success?).to eq true
|
51
|
+
|
52
|
+
job = response.data["jobs"].first
|
53
|
+
expect(job.has_key?("compensation")).to eq true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "GET /employees" do
|
58
|
+
it "supports pagination" do
|
59
|
+
params = {
|
60
|
+
limit: 5,
|
61
|
+
previous: 0,
|
62
|
+
next: 5
|
63
|
+
}
|
64
|
+
|
65
|
+
response = @client.get("/employees", params)
|
66
|
+
|
67
|
+
expect(response.data.count).to eq 5
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
RSpec.describe 'configuration' do
|
5
|
+
after do
|
6
|
+
Ucb::Hcm.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '.configure' do
|
10
|
+
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
11
|
+
it "should set the #{key}" do
|
12
|
+
Ucb::Hcm.configure do |config|
|
13
|
+
config.send("#{key}=", key)
|
14
|
+
expect(Ucb::Hcm.send(key)).to eq key
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
20
|
+
describe ".#{key}" do
|
21
|
+
it 'should return the default value' do
|
22
|
+
if [:app_id, :app_key].include?(key)
|
23
|
+
expect(Ucb::Hcm.send(key)).to be_nil
|
24
|
+
else
|
25
|
+
expect(Ucb::Hcm.send(key)).to eq Ucb::Hcm::Configuration.const_get("DEFAULT_#{key.upcase}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pry'
|
3
3
|
|
4
4
|
describe 'request' do
|
@@ -9,27 +9,27 @@ describe 'request' do
|
|
9
9
|
|
10
10
|
describe 'client' do
|
11
11
|
it 'has a HTTParty client interface' do
|
12
|
-
@client.client.
|
12
|
+
expect(@client.client).to eq HTTParty
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'base endpoint' do
|
17
17
|
it 'has a base endpoint the same as the configuration endpoint' do
|
18
|
-
@client.send(:base_endpoint).
|
18
|
+
expect(@client.send(:base_endpoint)).to eq Ucb::Hcm::Configuration::DEFAULT_ENDPOINT
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'can change the base end point' do
|
22
22
|
new_endpoint = "hello"
|
23
23
|
client = Ucb::Hcm::Client.new(app_id: TestCredentials::TEST_APP_ID, app_key: TestCredentials::TEST_APP_KEY, endpoint: new_endpoint)
|
24
|
-
client.send(:base_endpoint).
|
24
|
+
expect(client.send(:base_endpoint)).to eq new_endpoint
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'get' do
|
29
29
|
it 'performs a get request' do
|
30
|
-
response = @client.get("/employees/010789601")
|
31
|
-
response.
|
32
|
-
response.success
|
30
|
+
response = @client.get("/employees/010789601", {"id-type" => "legacy-hr-employee-id"})
|
31
|
+
expect(response).to be_an_instance_of Ucb::Hcm::Response
|
32
|
+
expect(response.success?).to eq true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/ucb-hcm.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'ucb/hcm/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "ucb-hcm"
|
8
8
|
spec.version = Ucb::Hcm::VERSION
|
9
|
-
spec.authors = ["Peter Philips"]
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Peter Philips", "Darin Wilson", "Zachary Berkompas"]
|
10
|
+
spec.email = ["hello@infinite.red"]
|
11
11
|
spec.summary = %q{Ucb HCM - Human Capital Management API gem}
|
12
12
|
spec.description = %q{Lightweight wrapper for the UCB HCM Api - https://developer.berkeley.edu/apidocs/employee}
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://infinite.red"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency 'pry'
|
26
26
|
spec.add_development_dependency 'byebug'
|
27
|
+
spec.add_development_dependency 'rspec-core'
|
28
|
+
spec.add_development_dependency 'rspec-expectations'
|
27
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucb-hcm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '3.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Philips
|
8
|
+
- Darin Wilson
|
9
|
+
- Zachary Berkompas
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2019-02-07 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: activesupport
|
@@ -94,39 +96,64 @@ dependencies:
|
|
94
96
|
- - ">="
|
95
97
|
- !ruby/object:Gem::Version
|
96
98
|
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rspec-core
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rspec-expectations
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
97
127
|
description: Lightweight wrapper for the UCB HCM Api - https://developer.berkeley.edu/apidocs/employee
|
98
128
|
email:
|
99
|
-
-
|
100
|
-
executables:
|
129
|
+
- hello@infinite.red
|
130
|
+
executables:
|
131
|
+
- setup
|
101
132
|
extensions: []
|
102
133
|
extra_rdoc_files: []
|
103
134
|
files:
|
104
135
|
- ".gitignore"
|
136
|
+
- ".ruby-version"
|
137
|
+
- ".travis.yml"
|
105
138
|
- Gemfile
|
106
139
|
- LICENSE.txt
|
107
140
|
- README.md
|
108
|
-
-
|
141
|
+
- bin/setup
|
109
142
|
- lib/ucb/hcm.rb
|
110
143
|
- lib/ucb/hcm/api.rb
|
111
|
-
- lib/ucb/hcm/api/department.rb
|
112
|
-
- lib/ucb/hcm/api/employee.rb
|
113
|
-
- lib/ucb/hcm/api/job.rb
|
114
144
|
- lib/ucb/hcm/client.rb
|
115
145
|
- lib/ucb/hcm/configuration.rb
|
116
146
|
- lib/ucb/hcm/request.rb
|
117
|
-
- lib/ucb/hcm/resource.rb
|
118
147
|
- lib/ucb/hcm/response.rb
|
119
148
|
- lib/ucb/hcm/version.rb
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
- test/ucb/hcm/hcm_test.rb
|
127
|
-
- test/ucb/hcm/request_test.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/support/test_credentials.rb
|
151
|
+
- spec/ucb/hcm/api_spec.rb
|
152
|
+
- spec/ucb/hcm/configuration_spec.rb
|
153
|
+
- spec/ucb/hcm/hcm_spec.rb
|
154
|
+
- spec/ucb/hcm/request_spec.rb
|
128
155
|
- ucb-hcm.gemspec
|
129
|
-
homepage:
|
156
|
+
homepage: https://infinite.red
|
130
157
|
licenses:
|
131
158
|
- MIT
|
132
159
|
metadata: {}
|
@@ -146,16 +173,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
173
|
version: '0'
|
147
174
|
requirements: []
|
148
175
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.7.7
|
150
177
|
signing_key:
|
151
178
|
specification_version: 4
|
152
179
|
summary: Ucb HCM - Human Capital Management API gem
|
153
180
|
test_files:
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
158
|
-
-
|
159
|
-
-
|
160
|
-
- test/ucb/hcm/hcm_test.rb
|
161
|
-
- test/ucb/hcm/request_test.rb
|
181
|
+
- spec/spec_helper.rb
|
182
|
+
- spec/support/test_credentials.rb
|
183
|
+
- spec/ucb/hcm/api_spec.rb
|
184
|
+
- spec/ucb/hcm/configuration_spec.rb
|
185
|
+
- spec/ucb/hcm/hcm_spec.rb
|
186
|
+
- spec/ucb/hcm/request_spec.rb
|
data/Rakefile
DELETED
data/lib/ucb/hcm/api/employee.rb
DELETED
data/lib/ucb/hcm/api/job.rb
DELETED
data/lib/ucb/hcm/resource.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
module Ucb
|
2
|
-
module Hcm
|
3
|
-
class Resource
|
4
|
-
attr_reader :client, :id
|
5
|
-
|
6
|
-
def initialize(client, id)
|
7
|
-
@client = client
|
8
|
-
@id = id
|
9
|
-
end
|
10
|
-
|
11
|
-
def get(request_path, params={})
|
12
|
-
respond client.get(resource_path(request_path), params)
|
13
|
-
end
|
14
|
-
|
15
|
-
def post(request_path, params={})
|
16
|
-
respond client.post(resource_path(request_path), params)
|
17
|
-
end
|
18
|
-
|
19
|
-
def find
|
20
|
-
get("/")
|
21
|
-
end
|
22
|
-
|
23
|
-
# this can be overridden by subclasses
|
24
|
-
# to key in on exactly what they want minus the fluff
|
25
|
-
def respond(response)
|
26
|
-
response.data_fetcher = self.class.data
|
27
|
-
response
|
28
|
-
end
|
29
|
-
|
30
|
-
class << self
|
31
|
-
attr_reader :api_methods
|
32
|
-
|
33
|
-
def scope(name=nil)
|
34
|
-
name.blank? ? @scope : set_scope(name)
|
35
|
-
end
|
36
|
-
|
37
|
-
# called in the context of a Response object
|
38
|
-
def data(&block)
|
39
|
-
block_given? ? set_data(block) : @data
|
40
|
-
end
|
41
|
-
|
42
|
-
def api(*attributes)
|
43
|
-
@api_methods = attributes
|
44
|
-
generate_api("/", @api_methods)
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
def set_scope(name)
|
49
|
-
@scope = name.to_s
|
50
|
-
|
51
|
-
Ucb::Hcm::Api.class_eval do
|
52
|
-
define_method name do |id|
|
53
|
-
"Ucb::Hcm::#{name.to_s.classify}".constantize.new(self, id)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def set_data(block)
|
59
|
-
@data = block
|
60
|
-
end
|
61
|
-
|
62
|
-
def generate_api(scope, methods)
|
63
|
-
Array(methods).each do |method|
|
64
|
-
if method.kind_of?(Hash)
|
65
|
-
method.each do |parent_method, child_method|
|
66
|
-
generate_api(scope, parent_method)
|
67
|
-
generate_api("#{scope}/#{parent_method}/:id", child_method)
|
68
|
-
end
|
69
|
-
elsif method.kind_of?(Symbol)
|
70
|
-
define_method(method) do |*args|
|
71
|
-
get("#{scope}/#{method}")
|
72
|
-
end
|
73
|
-
else
|
74
|
-
raise "Unsupported type for api method: #{method.class}. Must be Symbol or Hash"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
def resource_path(request_path)
|
82
|
-
resource_scope = "/#{self.class.scope}/#{id}"
|
83
|
-
if request_path == "/"
|
84
|
-
resource_scope
|
85
|
-
else
|
86
|
-
resource_scope + request_path
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
data/test/helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
MiniTest::Spec.class_eval do
|
2
|
-
def self.shared_examples
|
3
|
-
@shared_examples ||= {}
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module MiniTest::Spec::SharedExamples
|
8
|
-
def shared_examples_for(desc, &block)
|
9
|
-
MiniTest::Spec.shared_examples[desc] = block
|
10
|
-
end
|
11
|
-
|
12
|
-
def it_behaves_like(desc)
|
13
|
-
self.instance_eval(&MiniTest::Spec.shared_examples[desc])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Object.class_eval { include(MiniTest::Spec::SharedExamples) }
|
data/test/ucb/hcm/api_test.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'pry'
|
3
|
-
|
4
|
-
describe 'api' do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@client = Ucb::Hcm::Client.new(app_id: TestCredentials::TEST_APP_ID, app_key: TestCredentials::TEST_APP_KEY)
|
8
|
-
end
|
9
|
-
|
10
|
-
shared_examples_for "successful response" do
|
11
|
-
it "responds successfully" do
|
12
|
-
response.must_be_instance_of Ucb::Hcm::Response
|
13
|
-
response.success?.must_equal true
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'employee' do
|
18
|
-
describe "#find" do
|
19
|
-
let(:response) { @client.employees("010789601").find }
|
20
|
-
|
21
|
-
it_behaves_like "successful response"
|
22
|
-
|
23
|
-
it 'has home dept' do
|
24
|
-
response.data.first.has_key?("HomeDept").must_equal true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#names" do
|
29
|
-
let(:response) { @client.employees("010789601").names }
|
30
|
-
|
31
|
-
it_behaves_like "successful response"
|
32
|
-
|
33
|
-
it 'has last name' do
|
34
|
-
data = response.data.first
|
35
|
-
data.has_key?("Names").must_equal true
|
36
|
-
data["Names"].has_key?("Name").must_equal true
|
37
|
-
data["Names"]["Name"].first.has_key?("familyName").must_equal true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#addresses" do
|
42
|
-
let(:response) { @client.employees("010789601").addresses }
|
43
|
-
|
44
|
-
it_behaves_like "successful response"
|
45
|
-
|
46
|
-
it 'has address' do
|
47
|
-
data = response.data.first
|
48
|
-
data.has_key?("Addresses").must_equal true
|
49
|
-
data["Addresses"].has_key?("Address").must_equal true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#jobs" do
|
54
|
-
let(:response) { @client.employees("010789601").jobs }
|
55
|
-
|
56
|
-
it_behaves_like "successful response"
|
57
|
-
|
58
|
-
it 'has jobs' do
|
59
|
-
data = response.data.first
|
60
|
-
data.has_key?("Job").must_equal true
|
61
|
-
data["Job"].has_key?("Compensation").must_equal true
|
62
|
-
data["Job"]["Compensation"].has_key?("Pay").must_equal true
|
63
|
-
data["Job"]["Compensation"]["Pay"].has_key?("EmplRecord").must_equal true
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#emails" do
|
68
|
-
let(:response) { @client.employees("010789601").emails }
|
69
|
-
|
70
|
-
it_behaves_like "successful response"
|
71
|
-
|
72
|
-
it 'has emails' do
|
73
|
-
data = response.data.first
|
74
|
-
data.has_key?("Emails").must_equal true
|
75
|
-
data["Emails"].has_key?("Email").must_equal true
|
76
|
-
data["Emails"]["Email"].first.has_key?("emailAddress").must_equal true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#phones" do
|
81
|
-
let(:response) { @client.employees("010789601").phones }
|
82
|
-
|
83
|
-
it_behaves_like "successful response"
|
84
|
-
|
85
|
-
it 'has phones' do
|
86
|
-
data = response.data.first
|
87
|
-
data.has_key?("Phones").must_equal true
|
88
|
-
data["Phones"].has_key?("Phone").must_equal true
|
89
|
-
data["Phones"]["Phone"].first.has_key?("number").must_equal true
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#departments" do
|
94
|
-
let(:response) { @client.employees("010789601").departments }
|
95
|
-
|
96
|
-
it_behaves_like "successful response"
|
97
|
-
|
98
|
-
it 'has department' do
|
99
|
-
data = response.data.first
|
100
|
-
data.has_key?("Departments").must_equal true
|
101
|
-
data["Departments"].has_key?("Department").must_equal true
|
102
|
-
data["Departments"]["Department"].has_key?("DeptID").must_equal true
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#identifiers" do
|
107
|
-
let(:response) { @client.employees("010789601").identifiers }
|
108
|
-
|
109
|
-
it_behaves_like "successful response"
|
110
|
-
|
111
|
-
it 'has identifiers' do
|
112
|
-
data = response.data.first
|
113
|
-
data.has_key?("Identifiers").must_equal true
|
114
|
-
data["Identifiers"].has_key?("Identifier").must_equal true
|
115
|
-
data["Identifiers"]["Identifier"].first.has_key?("type").must_equal true
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
describe 'job' do
|
122
|
-
describe "#find" do
|
123
|
-
let(:response) { @client.jobs("9634C").find }
|
124
|
-
|
125
|
-
it_behaves_like "successful response"
|
126
|
-
|
127
|
-
it 'finds employee name by id' do
|
128
|
-
response.data["JobCodeDescr"].must_equal "Museum Preparator"
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#steps" do
|
134
|
-
let(:response) { @client.jobs("9634C").steps }
|
135
|
-
|
136
|
-
it_behaves_like "successful response"
|
137
|
-
|
138
|
-
it 'has steps' do
|
139
|
-
response.data.has_key?("Grade").must_equal true
|
140
|
-
response.data["Grade"].has_key?("Step").must_equal true
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
data/test/ucb/hcm/client_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe 'configuration' do
|
4
|
-
|
5
|
-
after do
|
6
|
-
Ucb::Hcm.reset
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.configure' do
|
10
|
-
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
11
|
-
it "should set the #{key}" do
|
12
|
-
Ucb::Hcm.configure do |config|
|
13
|
-
config.send("#{key}=", key)
|
14
|
-
Ucb::Hcm.send(key).must_equal key
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
21
|
-
describe ".#{key}" do
|
22
|
-
it 'should return the default value' do
|
23
|
-
if [:app_id, :app_key].include?(key)
|
24
|
-
# MiniTest 6 will require must_be_nil when comparing nil values
|
25
|
-
Ucb::Hcm.send(key).must_be_nil
|
26
|
-
else
|
27
|
-
Ucb::Hcm.send(key).must_equal Ucb::Hcm::Configuration.const_get("DEFAULT_#{key.upcase}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe 'configuration' do
|
4
|
-
|
5
|
-
after do
|
6
|
-
Ucb::Hcm.reset
|
7
|
-
end
|
8
|
-
|
9
|
-
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
10
|
-
describe ".#{key}" do
|
11
|
-
it 'should return the default value' do
|
12
|
-
if [:app_id, :app_key].include?(key)
|
13
|
-
# MiniTest 6 will require must_be_nil when comparing nil values
|
14
|
-
Ucb::Hcm.send(key).must_be_nil
|
15
|
-
else
|
16
|
-
Ucb::Hcm.send(key).must_equal Ucb::Hcm::Configuration.const_get("DEFAULT_#{key.upcase}")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '.configure' do
|
23
|
-
Ucb::Hcm::Configuration::VALID_CONFIG_KEYS.each do |key|
|
24
|
-
it "should set the #{key}" do
|
25
|
-
Ucb::Hcm.configure do |config|
|
26
|
-
config.send("#{key}=", key)
|
27
|
-
Ucb::Hcm.send(key).must_equal key
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|