ucb-hcm 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +9 -0
- data/lib/ucb/hcm.rb +10 -0
- data/lib/ucb/hcm/api.rb +27 -0
- data/lib/ucb/hcm/api/department.rb +12 -0
- data/lib/ucb/hcm/api/employee.rb +14 -0
- data/lib/ucb/hcm/api/job.rb +14 -0
- data/lib/ucb/hcm/client.rb +11 -0
- data/lib/ucb/hcm/configuration.rb +45 -0
- data/lib/ucb/hcm/request.rb +56 -0
- data/lib/ucb/hcm/resource.rb +93 -0
- data/lib/ucb/hcm/response.rb +31 -0
- data/lib/ucb/hcm/version.rb +5 -0
- data/test/helper.rb +5 -0
- data/test/support/shared_examples.rb +17 -0
- data/test/support/test_credentials.rb +4 -0
- data/test/ucb/hcm/api_test.rb +144 -0
- data/test/ucb/hcm/client_test.rb +33 -0
- data/test/ucb/hcm/configuration_test.rb +33 -0
- data/test/ucb/hcm/hcm_test.rb +7 -0
- data/test/ucb/hcm/request_test.rb +35 -0
- data/ucb-hcm.gemspec +27 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7039282f5894d83da4f79d4d61d0048bb9cefc4
|
4
|
+
data.tar.gz: 7d508d08984f8953525c8cb70b1a24dc6a7f9485
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef2b5b292b61354435946187c5e37997eef61ed6bea7f30d4a97205c948e9d572287a833cda07d8ef2b941108e5f037f67e2cdfb0b8e9a9460a786293cf5b713
|
7
|
+
data.tar.gz: a25d39b46efb3d77cddb13f081dc385152e7cd84f948e5c02e873a4a4db4488e78d273384195e9203686133f5165bcdbd1dba34c08348789f50e5451897cb482
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Peter Philips
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ucb::Hcm
|
2
|
+
|
3
|
+
Ucb::Hcm is a lightweight ruby wrapper around UC Berkeley's Human Capital Management API.
|
4
|
+
https://developer.berkeley.edu/apidocs/employee
|
5
|
+
|
6
|
+
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
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'ucb-hcm'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ucb-hcm
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Ucb::Hcm.configure do |hcm|
|
25
|
+
hcm.app_id = "APP_ID"
|
26
|
+
hcm.app_key = "APP_KEY"
|
27
|
+
hcm.endpoint = "https://endpoint/"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
client = Ucb::Hcm::Client.new
|
32
|
+
client.get("/employees/12345")
|
33
|
+
client.employees.find(12345) # Coming soon!
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( https://github.com/[my-github-username]/ucb-hcm/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/ucb/hcm.rb
ADDED
data/lib/ucb/hcm/api.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'ucb/hcm/configuration'
|
2
|
+
require "ucb/hcm/request"
|
3
|
+
require "ucb/hcm/response"
|
4
|
+
require "ucb/hcm/resource"
|
5
|
+
|
6
|
+
module Ucb
|
7
|
+
module Hcm
|
8
|
+
class Api
|
9
|
+
include Ucb::Hcm::Request
|
10
|
+
|
11
|
+
# Define the same set of accessors as the Ucb::Hcm::Configuration module
|
12
|
+
attr_accessor(*Ucb::Hcm::Configuration::VALID_CONFIG_KEYS)
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
# Merge the config values from the module and those passed
|
16
|
+
# to the client.
|
17
|
+
merged_options = Ucb::Hcm.options.merge(options)
|
18
|
+
|
19
|
+
# Copy the merged values to this client and ignore those
|
20
|
+
# not part of our configuration
|
21
|
+
Configuration::VALID_CONFIG_KEYS.each do |key|
|
22
|
+
send("#{key}=", merged_options[key])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ucb
|
2
|
+
module Hcm
|
3
|
+
module Configuration
|
4
|
+
VALID_CONNECTION_KEYS = [:endpoint, :user_agent, :method].freeze
|
5
|
+
VALID_OPTIONS_KEYS = [:app_id, :app_key, :format].freeze
|
6
|
+
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
7
|
+
|
8
|
+
DEFAULT_ENDPOINT = 'https://apis.berkeley.edu/uat/hcm/v2'
|
9
|
+
DEFAULT_METHOD = :get
|
10
|
+
DEFAULT_USER_AGENT = "Ucb::Hcm API Ruby Gem #{Ucb::Hcm::VERSION}".freeze
|
11
|
+
|
12
|
+
DEFAULT_APP_ID = nil
|
13
|
+
DEFAULT_APP_KEY = nil
|
14
|
+
DEFAULT_FORMAT = :json
|
15
|
+
|
16
|
+
# Build accessor methods for every config options so we can do this, for example:
|
17
|
+
# Awesome.format = :xml
|
18
|
+
attr_accessor(*VALID_CONFIG_KEYS)
|
19
|
+
|
20
|
+
# Make sure we have the default values set when we get 'extended'
|
21
|
+
def self.extended(base)
|
22
|
+
base.reset
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset
|
26
|
+
self.endpoint = DEFAULT_ENDPOINT
|
27
|
+
self.method = DEFAULT_METHOD
|
28
|
+
self.user_agent = DEFAULT_USER_AGENT
|
29
|
+
|
30
|
+
self.app_id = DEFAULT_APP_ID
|
31
|
+
self.app_key = DEFAULT_APP_KEY
|
32
|
+
self.format = DEFAULT_FORMAT
|
33
|
+
end
|
34
|
+
|
35
|
+
def options
|
36
|
+
Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
|
37
|
+
end
|
38
|
+
|
39
|
+
def configure
|
40
|
+
yield self
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Ucb
|
4
|
+
module Hcm
|
5
|
+
module Request
|
6
|
+
|
7
|
+
def client
|
8
|
+
HTTParty
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(*args)
|
12
|
+
resource = format_resource(args.shift)
|
13
|
+
resource += "?#{format_get_params(*args)}" if !args.empty?
|
14
|
+
params = default_options
|
15
|
+
respond client.get(resource, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(*args)
|
19
|
+
resource = format_resource(args.shift)
|
20
|
+
params = format_post_params(*args)
|
21
|
+
respond client.post(resource, params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond( response )
|
25
|
+
Response.new response
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def format_resource(resource)
|
31
|
+
base_endpoint + resource
|
32
|
+
end
|
33
|
+
|
34
|
+
def format_post_params(request_params={}, opts={})
|
35
|
+
params = default_options
|
36
|
+
params[:parameters] = request_params.to_json if !request_params.empty?
|
37
|
+
params.merge(opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
def format_get_params(request_params={})
|
41
|
+
URI.encode_www_form(request_params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_options
|
45
|
+
{
|
46
|
+
headers: {'accept' => 'application/json', 'app_id' => app_id, 'app_key' => app_key},
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def base_endpoint
|
51
|
+
endpoint
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ucb
|
2
|
+
module Hcm
|
3
|
+
class Response
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
attr_reader :raw_response, :data_fetcher
|
7
|
+
|
8
|
+
def_delegators :response, :code
|
9
|
+
|
10
|
+
def initialize(raw_response)
|
11
|
+
@raw_response = raw_response
|
12
|
+
end
|
13
|
+
|
14
|
+
def response
|
15
|
+
raw_response
|
16
|
+
end
|
17
|
+
|
18
|
+
def success?
|
19
|
+
code == 200
|
20
|
+
end
|
21
|
+
|
22
|
+
def data
|
23
|
+
defined?(@data_fetcher) ? instance_eval(&@data_fetcher) : response
|
24
|
+
end
|
25
|
+
|
26
|
+
def data_fetcher=(block)
|
27
|
+
@data_fetcher = block
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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) }
|
@@ -0,0 +1,144 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe 'request' 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
|
+
describe 'client' do
|
11
|
+
it 'has a HTTParty client interface' do
|
12
|
+
@client.client.must_be_same_as HTTParty
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'base endpoint' do
|
17
|
+
it 'has a base endpoint the same as the configuration endpoint' do
|
18
|
+
@client.send(:base_endpoint).must_be_same_as Ucb::Hcm::Configuration::DEFAULT_ENDPOINT
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'can change the base end point' do
|
22
|
+
new_endpoint = "hello"
|
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).must_be_same_as new_endpoint
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'get' do
|
29
|
+
it 'performs a get request' do
|
30
|
+
response = @client.get("/employees/010789601")
|
31
|
+
response.must_be_instance_of Ucb::Hcm::Response
|
32
|
+
response.success?.must_equal true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/ucb-hcm.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ucb/hcm/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ucb-hcm"
|
8
|
+
spec.version = Ucb::Hcm::VERSION
|
9
|
+
spec.authors = ["Peter Philips"]
|
10
|
+
spec.email = ["peter@planet.io"]
|
11
|
+
spec.summary = %q{Ucb HCM - Human Capital Management API gem}
|
12
|
+
spec.description = %q{Lightweight wrapper for the UCB HCM Api - https://developer.berkeley.edu/apidocs/employee}
|
13
|
+
spec.homepage = "http://planet.io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "activesupport"
|
22
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.1"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'byebug'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ucb-hcm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Philips
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.13.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.13.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Lightweight wrapper for the UCB HCM Api - https://developer.berkeley.edu/apidocs/employee
|
98
|
+
email:
|
99
|
+
- peter@planet.io
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/ucb/hcm.rb
|
110
|
+
- 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
|
+
- lib/ucb/hcm/client.rb
|
115
|
+
- lib/ucb/hcm/configuration.rb
|
116
|
+
- lib/ucb/hcm/request.rb
|
117
|
+
- lib/ucb/hcm/resource.rb
|
118
|
+
- lib/ucb/hcm/response.rb
|
119
|
+
- lib/ucb/hcm/version.rb
|
120
|
+
- test/helper.rb
|
121
|
+
- test/support/shared_examples.rb
|
122
|
+
- test/support/test_credentials.rb
|
123
|
+
- test/ucb/hcm/api_test.rb
|
124
|
+
- test/ucb/hcm/client_test.rb
|
125
|
+
- test/ucb/hcm/configuration_test.rb
|
126
|
+
- test/ucb/hcm/hcm_test.rb
|
127
|
+
- test/ucb/hcm/request_test.rb
|
128
|
+
- ucb-hcm.gemspec
|
129
|
+
homepage: http://planet.io
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.6.13
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Ucb HCM - Human Capital Management API gem
|
153
|
+
test_files:
|
154
|
+
- test/helper.rb
|
155
|
+
- test/support/shared_examples.rb
|
156
|
+
- test/support/test_credentials.rb
|
157
|
+
- test/ucb/hcm/api_test.rb
|
158
|
+
- test/ucb/hcm/client_test.rb
|
159
|
+
- test/ucb/hcm/configuration_test.rb
|
160
|
+
- test/ucb/hcm/hcm_test.rb
|
161
|
+
- test/ucb/hcm/request_test.rb
|