bamboozled 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +32 -10
- data/.hound.yml +2 -0
- data/.rubocop.yml +37 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +27 -0
- data/CONTRIBUTING.md +91 -0
- data/Gemfile +10 -5
- data/Guardfile +21 -0
- data/README.md +160 -0
- data/Rakefile +5 -7
- data/bamboozled.gemspec +14 -8
- data/lib/bamboozled.rb +12 -10
- data/lib/bamboozled/api/base.rb +6 -1
- data/lib/bamboozled/api/employee.rb +32 -0
- data/lib/bamboozled/api/time_off.rb +4 -3
- data/lib/bamboozled/errors.rb +14 -12
- data/lib/bamboozled/version.rb +1 -1
- data/logos/bamboozled_logo_black.png +0 -0
- data/logos/bamboozled_logo_green.png +0 -0
- data/logos/skookum_mark_black.png +0 -0
- data/logos/skookum_mark_black.svg +175 -0
- data/relnotes/v0.1.0.md +13 -0
- data/spec/fixtures/add_employee_details.json +7 -0
- data/spec/fixtures/add_employee_response.json +4 -0
- data/spec/fixtures/add_employee_xml.yml +8 -0
- data/spec/fixtures/last_changed.json +28 -0
- data/spec/fixtures/update_employee_details.json +7 -0
- data/spec/fixtures/update_employee_response.json +3 -0
- data/spec/fixtures/update_employee_xml.yml +8 -0
- data/spec/lib/bamboozled/api/employee_spec.rb +154 -0
- data/spec/spec_helper.rb +28 -12
- metadata +95 -18
- data/Gemfile.lock +0 -44
- data/Readme.md +0 -105
- data/spec/lib/bamboozled/employee_spec.rb +0 -107
- data/spec/lib/bamboozled/hash_spec.rb +0 -24
data/Readme.md
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
# Bamboozled
|
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) [![Build Status](https://travis-ci.org/Skookum/bamboozled.svg?branch=master)](https://travis-ci.org/Skookum/bamboozled)
|
4
|
-
|
5
|
-
Bamboozled wraps the BambooHR API without the use of Rails dependencies. Currently, this gem is **READ-ONLY**.
|
6
|
-
|
7
|
-
# Usage:
|
8
|
-
|
9
|
-
Install the gem with `gem install bamboozled` or add this to your `Gemfile`: `gem 'bamboozled'`
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
# Create the client:
|
13
|
-
client = Bamboozled.client(subdomain: 'your_subdomain', api_key: 'your_api_key')
|
14
|
-
```
|
15
|
-
|
16
|
-
> TIP! Create an API key by logging into your BambooHR account, then click your image in the upper right corner and select "API Keys". Then click "Add A New Key".
|
17
|
-
|
18
|
-
### Employee related data:
|
19
|
-
|
20
|
-
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.
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
# Returns an array of all employees
|
24
|
-
client.employee.all # Gets all employees with default fields
|
25
|
-
client.employee.all(:all) # Gets all fields for all employees
|
26
|
-
client.employee.all(['hireDate', 'displayName'])
|
27
|
-
client.employee.all('hireDate,displayName')
|
28
|
-
|
29
|
-
# Returns a hash of a single employee
|
30
|
-
client.employee.find(employee_id, fields = nil)
|
31
|
-
|
32
|
-
# Tabular employee data
|
33
|
-
client.employee.job_info(employee_id)
|
34
|
-
client.employee.employment_status(employee_id)
|
35
|
-
client.employee.compensation(employee_id)
|
36
|
-
client.employee.dependents(employee_id)
|
37
|
-
client.employee.contacts(employee_id)
|
38
|
-
|
39
|
-
# Time off estimate for employee. Requires end date in Date or Time format or YY-MM-DD string.
|
40
|
-
client.employee.time_off_estimate(employee_id, end_date)
|
41
|
-
|
42
|
-
# Photos for an employee
|
43
|
-
client.employee.photo_url(employee_work_email)
|
44
|
-
client.employee.photo_url(employee_id)
|
45
|
-
client.employee.photo_binary(employee_id)
|
46
|
-
```
|
47
|
-
|
48
|
-
### Time off data
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
# Get time off requests filtered by a number of parameters
|
52
|
-
# :id - the ID of the time off request
|
53
|
-
# :action -
|
54
|
-
# :employeeId - the ID of the employee you're looking for
|
55
|
-
# :start - filter start date
|
56
|
-
# :end - filter end date
|
57
|
-
# :type - type of time off request
|
58
|
-
# :status - must be one or more of the following: approved denied superceded requested canceled
|
59
|
-
client.time_off.requests(:employeeId: employee_id, start: Time.now)
|
60
|
-
|
61
|
-
# See who is out when.
|
62
|
-
client.time_off.whos_out(Time.now, '2014-12-31')
|
63
|
-
```
|
64
|
-
|
65
|
-
# Reports
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
# Find a report by its number
|
69
|
-
client.report.find(report_number, format = 'JSON', fd = true)
|
70
|
-
```
|
71
|
-
|
72
|
-
# Metadata
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
# Get fields
|
76
|
-
client.meta.fields
|
77
|
-
# Get lists
|
78
|
-
client.meta.lists
|
79
|
-
# Get tables
|
80
|
-
client.meta.tables
|
81
|
-
# Get users
|
82
|
-
# Note: this is all uses in the system, whereas client.employee.all only gets active employees
|
83
|
-
client.meta.users
|
84
|
-
```
|
85
|
-
|
86
|
-
## Todo:
|
87
|
-
|
88
|
-
1. Write more tests!
|
89
|
-
2. Implement CRUD so the gem is not read-only any more.
|
90
|
-
2. ~~Implement photos endpoints.~~
|
91
|
-
3. ~~Implement metadata endpoints.~~
|
92
|
-
4. Implement last change information endpoints.
|
93
|
-
|
94
|
-
## Contributing
|
95
|
-
|
96
|
-
1. Fork it
|
97
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
98
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
99
|
-
4. Make some specs pass
|
100
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
101
|
-
6. Create new Pull Request
|
102
|
-
|
103
|
-
## License
|
104
|
-
|
105
|
-
MIT. See the [LICENSE](/LICENSE) file.
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
|
3
|
-
describe "Employees" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Bamboozled.client(subdomain:'x', api_key:'x')
|
7
|
-
end
|
8
|
-
|
9
|
-
it "Gets all employees" do
|
10
|
-
response = File.new('spec/fixtures/all_employees.json')
|
11
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
12
|
-
|
13
|
-
employees = @client.employee.all
|
14
|
-
|
15
|
-
employees.is_a?(Array).must_equal true
|
16
|
-
employees.first.count.must_equal 7
|
17
|
-
end
|
18
|
-
|
19
|
-
it "Gets one employee" do
|
20
|
-
response = File.new('spec/fixtures/one_employee.json')
|
21
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
22
|
-
|
23
|
-
employee = @client.employee.find(1234)
|
24
|
-
|
25
|
-
employee.is_a?(Hash).must_equal true
|
26
|
-
employee.count.must_equal 3
|
27
|
-
employee['firstName'].must_equal "John"
|
28
|
-
employee['lastName'].must_equal "Doe"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "Gets employee job info" do
|
32
|
-
response = File.new('spec/fixtures/job_info.xml')
|
33
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
34
|
-
|
35
|
-
info = @client.employee.job_info(1234)
|
36
|
-
|
37
|
-
info.is_a?(Hash).must_equal true
|
38
|
-
info[:table][:row].first[:employeeId].must_equal "100"
|
39
|
-
info[:table][:row].first[:field].each do |f|
|
40
|
-
case f[:id]
|
41
|
-
when 'location'
|
42
|
-
f[:__content__].must_equal "New York Office"
|
43
|
-
when 'division'
|
44
|
-
f[:__content__].must_equal "Sprockets"
|
45
|
-
when 'department'
|
46
|
-
f[:__content__].must_equal "Research and Development"
|
47
|
-
when 'jobTitle'
|
48
|
-
f[:__content__].must_equal "Machinist"
|
49
|
-
when 'reportsTo'
|
50
|
-
f[:__content__].must_equal "John Smith"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it "Gets an employee's time off estimate" do
|
56
|
-
response = File.new('spec/fixtures/time_off_estimate.json')
|
57
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
58
|
-
|
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
|
-
it 'returns binary data for an employee email' do
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'returns the proper url using employee email address' do
|
75
|
-
|
76
|
-
hashed = '4fdce145bab6d27d69e34403f99fd11c' # Hash of me@here.com
|
77
|
-
required_url = "http://x.bamboohr.com/employees/photos/?h=#{hashed}"
|
78
|
-
|
79
|
-
# Normal
|
80
|
-
url = @client.employee.photo_url('me@here.com')
|
81
|
-
url.must_equal required_url
|
82
|
-
|
83
|
-
# Email with spaces
|
84
|
-
url = @client.employee.photo_url(' me@here.com ')
|
85
|
-
url.must_equal required_url
|
86
|
-
|
87
|
-
# Uppercase emails
|
88
|
-
url = @client.employee.photo_url('ME@HERE.COM')
|
89
|
-
url.must_equal required_url
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'returns the proper url using employee id' do
|
93
|
-
response = File.new('spec/fixtures/employee_emails.json')
|
94
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
95
|
-
|
96
|
-
hashed = '4fdce145bab6d27d69e34403f99fd11c'
|
97
|
-
required_url = "http://x.bamboohr.com/employees/photos/?h=#{hashed}"
|
98
|
-
|
99
|
-
url = @client.employee.photo_url(123)
|
100
|
-
url.must_equal required_url
|
101
|
-
end
|
102
|
-
|
103
|
-
# TODO - Figure out how to test this with webmock
|
104
|
-
# it 'returns binary data for an employee photo' do
|
105
|
-
# end
|
106
|
-
|
107
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
|
3
|
-
describe "HashWithIndifferentAccess" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Bamboozled.client(subdomain:'x', api_key:'x')
|
7
|
-
end
|
8
|
-
|
9
|
-
it "Gets data in a hash with indifferent access" do
|
10
|
-
response = File.new('spec/fixtures/one_employee.json')
|
11
|
-
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
12
|
-
|
13
|
-
employee = @client.employee.find(1234)
|
14
|
-
|
15
|
-
employee.is_a?(Hash).must_equal true
|
16
|
-
employee.count.must_equal 3
|
17
|
-
employee['firstName'].must_equal "John"
|
18
|
-
employee['lastName'].must_equal "Doe"
|
19
|
-
|
20
|
-
employee[:firstName].must_equal "John"
|
21
|
-
employee[:lastName].must_equal "Doe"
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|