bamboozled 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -0
- data/Rakefile +8 -0
- data/Readme.md +14 -8
- data/lib/bamboozled/api/base.rb +1 -1
- data/lib/bamboozled/api/employee.rb +12 -10
- data/lib/bamboozled/errors.rb +0 -1
- data/lib/bamboozled/version.rb +1 -1
- data/spec/fixtures/all_employees.json +58 -0
- data/spec/fixtures/job_info.xml +22 -0
- data/spec/fixtures/one_employee.json +9 -0
- data/spec/fixtures/time_off_estimate.json +23 -0
- data/spec/lib/bamboozled/employee_spec.rb +70 -0
- data/spec/spec_helper.rb +16 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddafc1d234e711cb5b4d541c04aa244e1b3dd77c
|
4
|
+
data.tar.gz: 7a0e3308d1c4d1e7c9f4a76ace3d4a51c5eb11ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa12f8cb8b8418f8a3326fb4060c526da85a2321992c0c7daf72d8bbec504b97d70e8db909a6d00e6e8803216615ff047ddc1d949f95929db363d380f76c17ab
|
7
|
+
data.tar.gz: 68a54ef43b03808b854c268e786e96aaa8b812aafa57b1be7a64d83ea6bfb8d4740bbda62d9558fa8315d2547572cefca4cd38c52410b4b1ac6b96c6b5a389f9
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,12 +8,24 @@ PATH
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
ansi (1.4.3)
|
13
|
+
crack (0.4.2)
|
14
|
+
safe_yaml (~> 1.0.0)
|
11
15
|
httparty (0.13.1)
|
12
16
|
json (~> 1.8)
|
13
17
|
multi_xml (>= 0.5.2)
|
14
18
|
json (1.8.1)
|
19
|
+
minitest (4.7.5)
|
15
20
|
multi_xml (0.5.5)
|
16
21
|
rake (10.3.2)
|
22
|
+
safe_yaml (1.0.3)
|
23
|
+
turn (0.9.7)
|
24
|
+
ansi
|
25
|
+
minitest (~> 4)
|
26
|
+
webmock (1.18.0)
|
27
|
+
addressable (>= 2.3.6)
|
28
|
+
crack (>= 0.3.2)
|
17
29
|
|
18
30
|
PLATFORMS
|
19
31
|
ruby
|
@@ -22,3 +34,5 @@ DEPENDENCIES
|
|
22
34
|
bamboozled!
|
23
35
|
bundler (>= 1.6.2)
|
24
36
|
rake
|
37
|
+
turn
|
38
|
+
webmock
|
data/Rakefile
ADDED
data/Readme.md
CHANGED
@@ -1,22 +1,27 @@
|
|
1
1
|
# Bamboozled
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/bamboozled.svg)](http://badge.fury.io/rb/bamboozled) [![Code Climate](https://codeclimate.com/github/Skookum/bamboozled.png)](https://codeclimate.com/github/Skookum/bamboozled)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bamboozled.svg)](http://badge.fury.io/rb/bamboozled) [![Code Climate](https://codeclimate.com/github/Skookum/bamboozled.png)](https://codeclimate.com/github/Skookum/bamboozled) [![Build Status](https://travis-ci.org/Skookum/bamboozled.svg?branch=master)](https://travis-ci.org/Skookum/bamboozled)
|
4
4
|
|
5
|
-
Bamboozled wraps the BambooHR API without the use of Rails dependencies.
|
5
|
+
Bamboozled wraps the BambooHR API without the use of Rails dependencies. Currently, this gem is **READ-ONLY**.
|
6
6
|
|
7
7
|
# Usage:
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
# Create the client:
|
11
|
-
client = Bamboozled.client('your_subdomain', 'your_api_key')
|
11
|
+
client = Bamboozled.client(subdomain: 'your_subdomain', api_key: 'your_api_key')
|
12
12
|
```
|
13
13
|
|
14
14
|
### Employee related data:
|
15
15
|
|
16
|
+
You can pass an array of fields to `all` or `:all` to get all fields your user is allowed to access. Because BambooHR's API doesn't allow for specifying fields on the `/employees/directory` API endpoint, passing a list of fields to retrieve will be signifigantly slower than getting just the default fields since the gem will get the directory of employees, then request the data for each individual employee resulting in `employees.count + 1` API calls.
|
17
|
+
|
16
18
|
```ruby
|
17
19
|
# Returns an array of all employees
|
18
|
-
client.employee.all
|
19
|
-
|
20
|
+
client.employee.all # Gets all employees with default fields
|
21
|
+
client.employee.all(:all) # Gets all fields for all employees
|
22
|
+
client.employee.all(['hireDate', 'displayName'])
|
23
|
+
client.employee.all('hireDate,displayName')
|
24
|
+
```
|
20
25
|
# Returns a hash of a single employee
|
21
26
|
client.employee.find(employee_id, fields = nil)
|
22
27
|
|
@@ -58,9 +63,10 @@ client.report.find(report_number, format = 'JSON', fd = true)
|
|
58
63
|
## Todo:
|
59
64
|
|
60
65
|
1. Write tests!
|
61
|
-
2. Implement
|
62
|
-
|
63
|
-
|
66
|
+
2. Implement CRUD so the gem is not read-only any more.
|
67
|
+
2. Implement photos endpoints.
|
68
|
+
3. Implement metadata endpoints.
|
69
|
+
4. Implement last change information endpoints.
|
64
70
|
|
65
71
|
## Contributing
|
66
72
|
|
data/lib/bamboozled/api/base.rb
CHANGED
@@ -3,15 +3,21 @@ module Bamboozled
|
|
3
3
|
class Employee < Base
|
4
4
|
|
5
5
|
def all(fields = nil)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
response = request(:get, "employees/directory")
|
7
|
+
|
8
|
+
if fields.nil? || fields == :default
|
9
|
+
Array(response['employees'])
|
10
|
+
else
|
11
|
+
employees = []
|
12
|
+
response['employees'].map{|e| e['id']}.each do |id|
|
13
|
+
employees << find(id, fields)
|
14
|
+
end
|
15
|
+
employees
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def find(id, fields = nil)
|
14
|
-
fields = all_fields if fields
|
20
|
+
fields = all_fields if fields == :all
|
15
21
|
fields = fields.join(',') if fields.is_a?(Array)
|
16
22
|
|
17
23
|
request(:get, "employees/#{id}?fields=#{fields}")
|
@@ -29,10 +35,6 @@ module Bamboozled
|
|
29
35
|
request(:get, "employees/#{id}/time_off/calculator?end=#{end_date}")
|
30
36
|
end
|
31
37
|
|
32
|
-
def default_fields
|
33
|
-
%w(displayName firstName lastName jobTitle workPhone mobilePhone workEmail department location photoUploaded photoUrl canUploadPhoto).join(',')
|
34
|
-
end
|
35
|
-
|
36
38
|
def all_fields
|
37
39
|
%w(address1 address2 age bestEmail birthday city country dateOfBirth department division eeo employeeNumber employmentHistoryStatus ethnicity exempt firstName flsaCode fullName1 fullName2 fullName3 fullName4 fullName5 displayName gender hireDate homeEmail homePhone id jobTitle lastChanged lastName location maritalStatus middleName mobilePhone nickname payChangeReason payGroup payGroupId payRate payRateEffectiveDate payType ssn sin state stateCode status supervisor supervisorId supervisorEId terminationDate workEmail workPhone workPhonePlusExtension workPhoneExtension zipcode photoUploaded rehireDate standardHoursPerWeek bonusDate bonusAmount bonusReason bonusComment commissionDate commisionDate commissionAmount commissionComment).join(',')
|
38
40
|
end
|
data/lib/bamboozled/errors.rb
CHANGED
data/lib/bamboozled/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
content-type: application/json; charset=utf-8
|
3
|
+
date: Tue, 17 Jun 2014 19:25:35 UTC
|
4
|
+
|
5
|
+
{
|
6
|
+
"fields": [
|
7
|
+
{
|
8
|
+
"id": "displayName",
|
9
|
+
"type": "text",
|
10
|
+
"name": "Display Name"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"id": "firstName",
|
14
|
+
"type": "text",
|
15
|
+
"name": "First Name"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"id": "lastName",
|
19
|
+
"type": "text",
|
20
|
+
"name": "Last Name"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": "jobTitle",
|
24
|
+
"type": "list",
|
25
|
+
"name": "Job Title"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"id": "workPhone",
|
29
|
+
"type": "text",
|
30
|
+
"name": "Work Phone"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"id": "workPhoneExtension",
|
34
|
+
"type": "text",
|
35
|
+
"name": "Work Extension"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"employees": [
|
39
|
+
{
|
40
|
+
"id":123,
|
41
|
+
"displayName":"John Doe",
|
42
|
+
"firstName":"John",
|
43
|
+
"lastName":"Doe",
|
44
|
+
"jobTitle":"Customer Service Representative",
|
45
|
+
"workPhone":"555-555-5555",
|
46
|
+
"workPhoneExtension":null
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"id":124,
|
50
|
+
"displayName":"John Doe",
|
51
|
+
"firstName":"John",
|
52
|
+
"lastName":"Doe",
|
53
|
+
"jobTitle":"Customer Service Representative",
|
54
|
+
"workPhone":"555-555-5555",
|
55
|
+
"workPhoneExtension":null
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
content-type: application/xml; charset=utf-8
|
3
|
+
date: Tue, 17 Jun 2014 19:25:35 UTC
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<row id="1" employeeId="100">
|
7
|
+
<field id="date">2010-06-01</field>
|
8
|
+
<field id="location">New York Office</field>
|
9
|
+
<field id="division">Sprockets</field>
|
10
|
+
<field id="department">Research and Development</field>
|
11
|
+
<field id="jobTitle">Machinist</field>
|
12
|
+
<field id="reportsTo">John Smith</field>
|
13
|
+
</row>
|
14
|
+
<row id="2" employeeId="100">
|
15
|
+
<field id="date">2009-03-01</field>
|
16
|
+
<field id="location">New York Office</field>
|
17
|
+
<field id="division">Sprockets</field>
|
18
|
+
<field id="department">Sales</field>
|
19
|
+
<field id="jobTitle">Salesman</field>
|
20
|
+
<field id="reportsTo">Jane Doe</field>
|
21
|
+
</row>
|
22
|
+
</table>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
content-type: application/json; charset=utf-8
|
3
|
+
date: Tue, 17 Jun 2014 19:25:35 UTC
|
4
|
+
|
5
|
+
{
|
6
|
+
"estimates": {
|
7
|
+
"end": "2014-08-31",
|
8
|
+
"estimate": [
|
9
|
+
{
|
10
|
+
"timeOffType" : "64",
|
11
|
+
"name" : "Conference Time Off",
|
12
|
+
"units" : "days",
|
13
|
+
"balance" : "5.0"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"timeOffType" : "65",
|
17
|
+
"name" : "PTO-Standard",
|
18
|
+
"units" : "hours",
|
19
|
+
"balance" : "85.0"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe "Employees" do
|
4
|
+
|
5
|
+
it "Gets all employees" do
|
6
|
+
response = File.new('spec/fixtures/all_employees.json')
|
7
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
8
|
+
|
9
|
+
client = Bamboozled.client(subdomain:'x', api_key:'x')
|
10
|
+
employees = client.employee.all
|
11
|
+
|
12
|
+
employees.is_a?(Array).must_equal true
|
13
|
+
employees.first.count.must_equal 7
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Gets one employee" do
|
17
|
+
response = File.new('spec/fixtures/one_employee.json')
|
18
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
19
|
+
|
20
|
+
client = Bamboozled.client(subdomain:'x', api_key:'x')
|
21
|
+
employee = client.employee.find(1234)
|
22
|
+
|
23
|
+
employee.is_a?(Hash).must_equal true
|
24
|
+
employee.count.must_equal 3
|
25
|
+
employee['firstName'].must_equal "John"
|
26
|
+
employee['lastName'].must_equal "Doe"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "Gets employee job info" do
|
30
|
+
response = File.new('spec/fixtures/job_info.xml')
|
31
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
32
|
+
|
33
|
+
client = Bamboozled.client(subdomain:'x', api_key:'x')
|
34
|
+
info = client.employee.job_info(1234)
|
35
|
+
|
36
|
+
info.is_a?(Hash).must_equal true
|
37
|
+
info[:table][:row].first[:employeeId].must_equal "100"
|
38
|
+
info[:table][:row].first[:field].each do |f|
|
39
|
+
case f[:id]
|
40
|
+
when 'location'
|
41
|
+
f[:__content__].must_equal "New York Office"
|
42
|
+
when 'division'
|
43
|
+
f[:__content__].must_equal "Sprockets"
|
44
|
+
when 'department'
|
45
|
+
f[:__content__].must_equal "Research and Development"
|
46
|
+
when 'jobTitle'
|
47
|
+
f[:__content__].must_equal "Machinist"
|
48
|
+
when 'reportsTo'
|
49
|
+
f[:__content__].must_equal "John Smith"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Gets an employee's time off estimate" do
|
55
|
+
response = File.new('spec/fixtures/time_off_estimate.json')
|
56
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
57
|
+
|
58
|
+
client = Bamboozled.client(subdomain:'x', api_key:'x')
|
59
|
+
future = Time.now + (60 * 60 * 24 * 180)
|
60
|
+
estimate = client.employee.time_off_estimate(1234, future)
|
61
|
+
|
62
|
+
puts estimate
|
63
|
+
|
64
|
+
estimate.is_a?(Hash).must_equal true
|
65
|
+
estimate['estimates'].keys.must_equal ['end', 'estimate']
|
66
|
+
estimate['estimates']['estimate'].count.must_equal 2
|
67
|
+
estimate['estimates']['estimate'].first.keys.must_equal ['timeOffType', 'name', 'units', 'balance']
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../lib/bamboozled'
|
2
|
+
|
3
|
+
#dependencies
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'webmock/minitest'
|
6
|
+
|
7
|
+
require 'turn'
|
8
|
+
|
9
|
+
Turn.config do |c|
|
10
|
+
# :outline - turn's original case/test outline mode [default]
|
11
|
+
c.format = :outline
|
12
|
+
# turn on invoke/execute tracing, enable full backtrace
|
13
|
+
c.trace = true
|
14
|
+
# use humanized test names (works only with :outline format)
|
15
|
+
c.natural = true
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboozled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -46,8 +46,10 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
49
50
|
- Gemfile
|
50
51
|
- Gemfile.lock
|
52
|
+
- Rakefile
|
51
53
|
- Readme.md
|
52
54
|
- bamboozled.gemspec
|
53
55
|
- lib/bamboozled.rb
|
@@ -59,6 +61,12 @@ files:
|
|
59
61
|
- lib/bamboozled/errors.rb
|
60
62
|
- lib/bamboozled/ext/yesno.rb
|
61
63
|
- lib/bamboozled/version.rb
|
64
|
+
- spec/fixtures/all_employees.json
|
65
|
+
- spec/fixtures/job_info.xml
|
66
|
+
- spec/fixtures/one_employee.json
|
67
|
+
- spec/fixtures/time_off_estimate.json
|
68
|
+
- spec/lib/bamboozled/employee_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
62
70
|
homepage: http://github.com/Skookum/bamboozled
|
63
71
|
licenses:
|
64
72
|
- MIT
|
@@ -83,5 +91,10 @@ rubygems_version: 2.3.0
|
|
83
91
|
signing_key:
|
84
92
|
specification_version: 4
|
85
93
|
summary: A Ruby Wrapper for the BambooHR API http://www.bamboohr.com/
|
86
|
-
test_files:
|
87
|
-
|
94
|
+
test_files:
|
95
|
+
- spec/fixtures/all_employees.json
|
96
|
+
- spec/fixtures/job_info.xml
|
97
|
+
- spec/fixtures/one_employee.json
|
98
|
+
- spec/fixtures/time_off_estimate.json
|
99
|
+
- spec/lib/bamboozled/employee_spec.rb
|
100
|
+
- spec/spec_helper.rb
|