bamboozled 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -0
- data/Readme.md +9 -4
- data/lib/bamboozled/api/employee.rb +20 -4
- data/lib/bamboozled/version.rb +1 -1
- data/spec/fixtures/employee_emails.json +9 -0
- data/spec/lib/bamboozled/employee_spec.rb +45 -8
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 333a236b91544f4f2156c2ea5ec3c794e7663917
|
4
|
+
data.tar.gz: c1ce8926265f3759330b4d8748160310b5a926de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd3b75c4297435a56f2fe43cc1093a218adb97841d03b0ba3dd152c006eb6285e92e029e18e32676913ef614d1fddcd1e99c98f2911a90cd6f69d5d12119344
|
7
|
+
data.tar.gz: efa608beb9591e5fc316d4449bb138862b884e890783592458bf0c1bc4c50707fdd2ed3af623b7c9cefb684f85fc3f830650785adda7f77f29d578865f3dbe65
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/Readme.md
CHANGED
@@ -21,7 +21,7 @@ client.employee.all # Gets all employees with default fields
|
|
21
21
|
client.employee.all(:all) # Gets all fields for all employees
|
22
22
|
client.employee.all(['hireDate', 'displayName'])
|
23
23
|
client.employee.all('hireDate,displayName')
|
24
|
-
|
24
|
+
|
25
25
|
# Returns a hash of a single employee
|
26
26
|
client.employee.find(employee_id, fields = nil)
|
27
27
|
|
@@ -34,6 +34,11 @@ client.employee.contacts(employee_id)
|
|
34
34
|
|
35
35
|
# Time off estimate for employee. Requires end date in Date or Time format or YY-MM-DD string.
|
36
36
|
client.employee.time_off_estimate(employee_id, end_date)
|
37
|
+
|
38
|
+
# Photos for an employee
|
39
|
+
client.employee.photo_url(employee_work_email)
|
40
|
+
client.employee.photo_url(employee_id)
|
41
|
+
client.employee.photo_binary(employee_id)
|
37
42
|
```
|
38
43
|
|
39
44
|
### Time off data
|
@@ -76,10 +81,10 @@ client.meta.users
|
|
76
81
|
|
77
82
|
## Todo:
|
78
83
|
|
79
|
-
1. Write tests!
|
84
|
+
1. Write more tests!
|
80
85
|
2. Implement CRUD so the gem is not read-only any more.
|
81
|
-
2. Implement photos endpoints
|
82
|
-
3. Implement metadata endpoints
|
86
|
+
2. ~~Implement photos endpoints.~~
|
87
|
+
3. ~~Implement metadata endpoints.~~
|
83
88
|
4. Implement last change information endpoints.
|
84
89
|
|
85
90
|
## Contributing
|
@@ -16,11 +16,11 @@ module Bamboozled
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def find(
|
19
|
+
def find(employee_id, fields = nil)
|
20
20
|
fields = all_fields if fields == :all
|
21
21
|
fields = fields.join(',') if fields.is_a?(Array)
|
22
22
|
|
23
|
-
request(:get, "employees/#{
|
23
|
+
request(:get, "employees/#{employee_id}?fields=#{fields}")
|
24
24
|
end
|
25
25
|
|
26
26
|
# Tabular data
|
@@ -30,14 +30,30 @@ module Bamboozled
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def time_off_estimate(
|
33
|
+
def time_off_estimate(employee_id, end_date)
|
34
34
|
end_date = end_date.strftime("%F") unless end_date.is_a?(String)
|
35
|
-
request(:get, "employees/#{
|
35
|
+
request(:get, "employees/#{employee_id}/time_off/calculator?end=#{end_date}")
|
36
36
|
end
|
37
37
|
|
38
38
|
def all_fields
|
39
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(',')
|
40
40
|
end
|
41
|
+
|
42
|
+
def photo_binary(employee_id)
|
43
|
+
request(:get, "employees/#{employee_id}/photo/small")
|
44
|
+
end
|
45
|
+
|
46
|
+
def photo_url(employee)
|
47
|
+
if (Float(employee) rescue false)
|
48
|
+
e = find(employee, ['workEmail', 'homeEmail'])
|
49
|
+
employee = e['workEmail'].nil? ? e['homeEmail'] : e['workEmail']
|
50
|
+
end
|
51
|
+
|
52
|
+
digest = Digest::MD5.new
|
53
|
+
digest.update(employee.strip.downcase)
|
54
|
+
"http://#{@subdomain}.bamboohr.com/employees/photos/?h=#{digest}"
|
55
|
+
end
|
56
|
+
|
41
57
|
end
|
42
58
|
end
|
43
59
|
end
|
data/lib/bamboozled/version.rb
CHANGED
@@ -2,12 +2,15 @@ require_relative '../../spec_helper'
|
|
2
2
|
|
3
3
|
describe "Employees" do
|
4
4
|
|
5
|
+
before do
|
6
|
+
@client = Bamboozled.client(subdomain:'x', api_key:'x')
|
7
|
+
end
|
8
|
+
|
5
9
|
it "Gets all employees" do
|
6
10
|
response = File.new('spec/fixtures/all_employees.json')
|
7
11
|
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
8
12
|
|
9
|
-
|
10
|
-
employees = client.employee.all
|
13
|
+
employees = @client.employee.all
|
11
14
|
|
12
15
|
employees.is_a?(Array).must_equal true
|
13
16
|
employees.first.count.must_equal 7
|
@@ -17,8 +20,7 @@ describe "Employees" do
|
|
17
20
|
response = File.new('spec/fixtures/one_employee.json')
|
18
21
|
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
19
22
|
|
20
|
-
|
21
|
-
employee = client.employee.find(1234)
|
23
|
+
employee = @client.employee.find(1234)
|
22
24
|
|
23
25
|
employee.is_a?(Hash).must_equal true
|
24
26
|
employee.count.must_equal 3
|
@@ -30,8 +32,7 @@ describe "Employees" do
|
|
30
32
|
response = File.new('spec/fixtures/job_info.xml')
|
31
33
|
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
32
34
|
|
33
|
-
|
34
|
-
info = client.employee.job_info(1234)
|
35
|
+
info = @client.employee.job_info(1234)
|
35
36
|
|
36
37
|
info.is_a?(Hash).must_equal true
|
37
38
|
info[:table][:row].first[:employeeId].must_equal "100"
|
@@ -55,9 +56,8 @@ describe "Employees" do
|
|
55
56
|
response = File.new('spec/fixtures/time_off_estimate.json')
|
56
57
|
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
57
58
|
|
58
|
-
client = Bamboozled.client(subdomain:'x', api_key:'x')
|
59
59
|
future = Time.now + (60 * 60 * 24 * 180)
|
60
|
-
estimate = client.employee.time_off_estimate(1234, future)
|
60
|
+
estimate = @client.employee.time_off_estimate(1234, future)
|
61
61
|
|
62
62
|
puts estimate
|
63
63
|
|
@@ -67,4 +67,41 @@ describe "Employees" do
|
|
67
67
|
estimate['estimates']['estimate'].first.keys.must_equal ['timeOffType', 'name', 'units', 'balance']
|
68
68
|
end
|
69
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
|
+
|
70
107
|
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.5
|
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-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/bamboozled/ext/yesno.rb
|
64
64
|
- lib/bamboozled/version.rb
|
65
65
|
- spec/fixtures/all_employees.json
|
66
|
+
- spec/fixtures/employee_emails.json
|
66
67
|
- spec/fixtures/job_info.xml
|
67
68
|
- spec/fixtures/one_employee.json
|
68
69
|
- spec/fixtures/time_off_estimate.json
|
@@ -94,6 +95,7 @@ specification_version: 4
|
|
94
95
|
summary: A Ruby Wrapper for the BambooHR API http://www.bamboohr.com/
|
95
96
|
test_files:
|
96
97
|
- spec/fixtures/all_employees.json
|
98
|
+
- spec/fixtures/employee_emails.json
|
97
99
|
- spec/fixtures/job_info.xml
|
98
100
|
- spec/fixtures/one_employee.json
|
99
101
|
- spec/fixtures/time_off_estimate.json
|