bamboozled 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/LICENSE +22 -0
- data/Readme.md +7 -0
- data/examples/employees_over_time.rb +53 -0
- data/lib/bamboozled.rb +5 -5
- data/lib/bamboozled/errors.rb +1 -0
- data/lib/bamboozled/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 668dff469da070d2244365922ea2b08b672950a5
|
4
|
+
data.tar.gz: 65187b5ad022be606cb96e3937271dca98791f2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ae98a06e25bcdcf96afd5ec831eba302bf310dbbbeb70ff053a34de8b424aba6b9d764a271b4ba0841fce535dc8528e734750ce4bcc6575ea4fd0a3fe4e16bf
|
7
|
+
data.tar.gz: 876e2b38e4ca11d4bf4ecaae42afdf0e60f6692cc645b6bcd0f119043d6d3dc3b61064f580c80c8627f7d4e7105c7dfe004294ac31c4db579827993c69c42148
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bamboozled (0.0.
|
4
|
+
bamboozled (0.0.6)
|
5
5
|
httparty
|
6
6
|
json
|
7
7
|
|
@@ -12,18 +12,18 @@ GEM
|
|
12
12
|
ansi (1.4.3)
|
13
13
|
crack (0.4.2)
|
14
14
|
safe_yaml (~> 1.0.0)
|
15
|
-
httparty (0.13.
|
15
|
+
httparty (0.13.3)
|
16
16
|
json (~> 1.8)
|
17
17
|
multi_xml (>= 0.5.2)
|
18
18
|
json (1.8.1)
|
19
19
|
minitest (4.7.5)
|
20
20
|
multi_xml (0.5.5)
|
21
21
|
rake (10.3.2)
|
22
|
-
safe_yaml (1.0.
|
22
|
+
safe_yaml (1.0.4)
|
23
23
|
turn (0.9.7)
|
24
24
|
ansi
|
25
25
|
minitest (~> 4)
|
26
|
-
webmock (1.
|
26
|
+
webmock (1.20.4)
|
27
27
|
addressable (>= 2.3.6)
|
28
28
|
crack (>= 0.3.2)
|
29
29
|
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mark Rickert & Skookum Digital Works
|
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
CHANGED
@@ -6,11 +6,15 @@ Bamboozled wraps the BambooHR API without the use of Rails dependencies. Current
|
|
6
6
|
|
7
7
|
# Usage:
|
8
8
|
|
9
|
+
Install the gem with `gem install bamboozled` or add this to your `Gemfile`: `gem 'bamboozled'`
|
10
|
+
|
9
11
|
```ruby
|
10
12
|
# Create the client:
|
11
13
|
client = Bamboozled.client(subdomain: 'your_subdomain', api_key: 'your_api_key')
|
12
14
|
```
|
13
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
|
+
|
14
18
|
### Employee related data:
|
15
19
|
|
16
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.
|
@@ -96,3 +100,6 @@ client.meta.users
|
|
96
100
|
5. Push to the branch (`git push origin my-new-feature`)
|
97
101
|
6. Create new Pull Request
|
98
102
|
|
103
|
+
## License
|
104
|
+
|
105
|
+
MIT. See the [LICENSE](/LICENSE) file.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# File: employees_over_time.rb
|
2
|
+
# Date Created: 2014-08-07
|
3
|
+
# Author(s): Mark Rickert (mjar81@gmail.com) / Skookum Digital Works (http://skookum.com)
|
4
|
+
#
|
5
|
+
# Description: This example script grabs all the historical users in BambooHR
|
6
|
+
# and determines how many employees there were at the end of each of the
|
7
|
+
# previous 12 months.
|
8
|
+
#
|
9
|
+
# Run this script with: ruby employees_over_time.rb
|
10
|
+
|
11
|
+
require '../lib/bamboozled/'
|
12
|
+
require 'active_support'
|
13
|
+
require 'active_support/core_ext/integer'
|
14
|
+
require 'active_support/core_ext/date'
|
15
|
+
|
16
|
+
@subdomain = 'your_subdomain'
|
17
|
+
@api_key = 'your_api_key'
|
18
|
+
|
19
|
+
def main
|
20
|
+
client = Bamboozled.client(subdomain:@subdomain, api_key:@api_key)
|
21
|
+
|
22
|
+
# Get all users in the system. Even terminated employees.
|
23
|
+
# Calling client.employee.all only gets active users.
|
24
|
+
employee_data = client.meta.users.map do |e|
|
25
|
+
# Sometimes employees are in the system but don't have an emaployee ID.
|
26
|
+
# This makes them unqueryable and they're usually a duplicate or admin user.
|
27
|
+
next unless e[:employeeId]
|
28
|
+
|
29
|
+
# Get each employee's start_date and termination date
|
30
|
+
client.employee.find(e[:employeeId], %w(displayName department hireDate terminationDate))
|
31
|
+
end.compact.reject{|e| e['hireDate'] == '0000-00-00'}
|
32
|
+
|
33
|
+
# Start from today and go back 12 months and print out how many employees were
|
34
|
+
# at the company on that date.
|
35
|
+
d = (Date.today - 1.month).end_of_month
|
36
|
+
12.times do
|
37
|
+
d = (d - 1.month).end_of_month
|
38
|
+
puts "#{d},#{employees_on_date(employee_data, d)}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# Simple method to compare hire and termination dates and get the count of employees
|
44
|
+
# who were with the company on that day.
|
45
|
+
def employees_on_date(employees, date)
|
46
|
+
employees.map do |e|
|
47
|
+
hire_date = Date.parse(e["hireDate"]) rescue nil
|
48
|
+
termination_date = Date.parse(e["terminationDate"]) rescue nil
|
49
|
+
(hire_date <= date && (termination_date.nil? || termination_date >= date)) ? 1 : 0
|
50
|
+
end.inject(:+)
|
51
|
+
end
|
52
|
+
|
53
|
+
main
|
data/lib/bamboozled.rb
CHANGED
@@ -2,13 +2,13 @@ require 'httparty'
|
|
2
2
|
require 'json'
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
|
5
|
+
require_relative './bamboozled/ext/yesno'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
require_relative './bamboozled/version'
|
8
|
+
require_relative './bamboozled/errors'
|
9
|
+
require_relative './bamboozled/base'
|
10
10
|
|
11
|
-
%w(base employee report time_off meta).each {|a|
|
11
|
+
%w(base employee report time_off meta).each {|a| require_relative "./bamboozled/api/#{a}"}
|
12
12
|
|
13
13
|
module Bamboozled
|
14
14
|
class << self
|
data/lib/bamboozled/errors.rb
CHANGED
@@ -18,6 +18,7 @@ module Bamboozled
|
|
18
18
|
|
19
19
|
class BadRequest < HTTPError; end #400
|
20
20
|
class Unauthorized < HTTPError ; end #
|
21
|
+
class AuthenticationFailed < HTTPError ; end #
|
21
22
|
class Forbidden < HTTPError ; end # 403
|
22
23
|
class NotFound < HTTPError; end # 404
|
23
24
|
class NotAcceptable < HTTPError; end # 406
|
data/lib/bamboozled/version.rb
CHANGED
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.6
|
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-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -49,9 +49,11 @@ files:
|
|
49
49
|
- ".travis.yml"
|
50
50
|
- Gemfile
|
51
51
|
- Gemfile.lock
|
52
|
+
- LICENSE
|
52
53
|
- Rakefile
|
53
54
|
- Readme.md
|
54
55
|
- bamboozled.gemspec
|
56
|
+
- examples/employees_over_time.rb
|
55
57
|
- lib/bamboozled.rb
|
56
58
|
- lib/bamboozled/api/base.rb
|
57
59
|
- lib/bamboozled/api/employee.rb
|
@@ -89,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
91
|
version: '0'
|
90
92
|
requirements: []
|
91
93
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.2.0
|
93
95
|
signing_key:
|
94
96
|
specification_version: 4
|
95
97
|
summary: A Ruby Wrapper for the BambooHR API http://www.bamboohr.com/
|