bamboozled 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,8 @@
|
|
1
|
+
body:
|
2
|
+
<employee><field id='firstName'>Bruce</field><field id='lastName'>Wayne</field><field id='workEmail'>b.wayne@gmail.com</field><field id='jobTitle'>Batman</field><field id='city'>Gotham</field></employee>
|
3
|
+
headers:
|
4
|
+
Accept:
|
5
|
+
- application/json
|
6
|
+
User-Agent:
|
7
|
+
- Bamboozled/0.0.7
|
8
|
+
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Employees" do
|
4
|
+
before do
|
5
|
+
@client = Bamboozled.client(subdomain: "x", api_key: "x")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "Gets data in a hash with indifferent access" do
|
9
|
+
response = File.new("spec/fixtures/one_employee.json")
|
10
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
11
|
+
|
12
|
+
employee = @client.employee.find(1234)
|
13
|
+
|
14
|
+
expect(employee).to be_a Hash
|
15
|
+
expect(employee.count).to eq 3
|
16
|
+
expect(employee["firstName"]).to eq "John"
|
17
|
+
expect(employee[:firstName]).to eq "John"
|
18
|
+
expect(employee["lastName"]).to eq "Doe"
|
19
|
+
expect(employee[:lastName]).to eq "Doe"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Gets all employees" do
|
23
|
+
response = File.new("spec/fixtures/all_employees.json")
|
24
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
25
|
+
|
26
|
+
employees = @client.employee.all
|
27
|
+
|
28
|
+
expect(employees).to be_a Array
|
29
|
+
expect(employees.first.count).to eq 7
|
30
|
+
end
|
31
|
+
|
32
|
+
it "Gets one employee" do
|
33
|
+
response = File.new("spec/fixtures/one_employee.json")
|
34
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
35
|
+
|
36
|
+
employee = @client.employee.find(1234)
|
37
|
+
|
38
|
+
expect(employee).to be_a Hash
|
39
|
+
expect(employee.count).to eq 3
|
40
|
+
expect(employee["firstName"]).to eq "John"
|
41
|
+
expect(employee["lastName"]).to eq "Doe"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "Gets employee job info" do
|
45
|
+
response = File.new("spec/fixtures/job_info.xml")
|
46
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
47
|
+
|
48
|
+
info = @client.employee.job_info(1234)
|
49
|
+
|
50
|
+
expect(info).to be_a Hash
|
51
|
+
expect(info[:table][:row].first[:employeeId]).to eq "100"
|
52
|
+
|
53
|
+
info[:table][:row].first[:field].each do |f|
|
54
|
+
case f[:id]
|
55
|
+
when "location"
|
56
|
+
expect(f[:__content__]).to eq "New York Office"
|
57
|
+
when "division"
|
58
|
+
expect(f[:__content__]).to eq "Sprockets"
|
59
|
+
when "department"
|
60
|
+
expect(f[:__content__]).to eq "Research and Development"
|
61
|
+
when "jobTitle"
|
62
|
+
expect(f[:__content__]).to eq "Machinist"
|
63
|
+
when "reportsTo"
|
64
|
+
expect(f[:__content__]).to eq "John Smith"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "Gets an employee's time off estimate" do
|
70
|
+
response = File.new("spec/fixtures/time_off_estimate.json")
|
71
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
72
|
+
|
73
|
+
future = Time.now + (60 * 60 * 24 * 180)
|
74
|
+
estimate = @client.employee.time_off_estimate(1234, future)
|
75
|
+
|
76
|
+
expect(estimate).to be_a Hash
|
77
|
+
expect(estimate["estimates"].keys).to match_array %w(end estimate)
|
78
|
+
expect(estimate["estimates"]["estimate"].count).to eq 2
|
79
|
+
expect(estimate["estimates"]["estimate"].first.keys)
|
80
|
+
.to match_array %w(timeOffType name units balance)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns the proper url using employee email address" do
|
84
|
+
hashed = "4fdce145bab6d27d69e34403f99fd11c" # Hash of me@here.com
|
85
|
+
required_url = "http://x.bamboohr.com/employees/photos/?h=#{hashed}"
|
86
|
+
|
87
|
+
# Normal
|
88
|
+
url = @client.employee.photo_url("me@here.com")
|
89
|
+
expect(url).to eq required_url
|
90
|
+
|
91
|
+
# Email with spaces
|
92
|
+
url = @client.employee.photo_url(" me@here.com ")
|
93
|
+
expect(url).to eq required_url
|
94
|
+
|
95
|
+
# Uppercase emails
|
96
|
+
url = @client.employee.photo_url("ME@HERE.COM")
|
97
|
+
expect(url).to eq required_url
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns the proper url using employee id" do
|
101
|
+
response = File.new("spec/fixtures/employee_emails.json")
|
102
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
103
|
+
|
104
|
+
hashed = "4fdce145bab6d27d69e34403f99fd11c"
|
105
|
+
required_url = "http://x.bamboohr.com/employees/photos/?h=#{hashed}"
|
106
|
+
|
107
|
+
url = @client.employee.photo_url(123)
|
108
|
+
expect(url).to eq required_url
|
109
|
+
end
|
110
|
+
|
111
|
+
it "Gets all employee records which have changed since a given date" do
|
112
|
+
response = File.new("spec/fixtures/last_changed.json")
|
113
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
114
|
+
|
115
|
+
employees = @client.employee.last_changed("2011-06-02T19:26:23+00:00")
|
116
|
+
|
117
|
+
expect(employees).to be_a Hash
|
118
|
+
expect(employees.keys.count).to eq 4
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#add" do
|
122
|
+
it "creates a new employee in BambooHR" do
|
123
|
+
xml = YAML.load_file("spec/fixtures/add_employee_xml.yml")
|
124
|
+
response = File.new("spec/fixtures/add_employee_response.json")
|
125
|
+
details = JSON.parse(File.read("spec/fixtures/add_employee_details.json"))
|
126
|
+
|
127
|
+
stub_request(:post, /.*api\.bamboohr\.com.*/)
|
128
|
+
.with(xml).to_return(response)
|
129
|
+
|
130
|
+
employee = @client.employee.add(details)
|
131
|
+
location = employee["headers"]["location"]
|
132
|
+
|
133
|
+
expect(location).to eq "https://api.bamboohr.com/api/gateway.php/alphasights/v1/employees/44259"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "#update" do
|
138
|
+
it "updates an employee in BambooHR" do
|
139
|
+
xml = YAML.load_file("spec/fixtures/update_employee_xml.yml")
|
140
|
+
response = File.new("spec/fixtures/update_employee_response.json")
|
141
|
+
details = JSON.parse(File.read("spec/fixtures/update_employee_details.json"))
|
142
|
+
url = "https://x:x@api.bamboohr.com/api/gateway.php/x/v1/employees/1234"
|
143
|
+
|
144
|
+
stub_request(:post, url).with(xml).to_return(response)
|
145
|
+
employee = @client.employee.update("1234", details)
|
146
|
+
expected_headers = {
|
147
|
+
"content-type" => ["application/json; charset=utf-8"],
|
148
|
+
"date" => ["Tue, 17 Jun 2014 19:25:35 UTC"]
|
149
|
+
}
|
150
|
+
|
151
|
+
expect(employee["headers"]).to eq(expected_headers)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
|
-
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
2
3
|
|
3
|
-
|
4
|
-
require
|
5
|
-
require 'webmock/minitest'
|
4
|
+
require "webmock/rspec"
|
5
|
+
require "rspec"
|
6
6
|
|
7
|
-
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.expect_with :rspec do |expectations|
|
9
|
+
# Only allow the expectation syntax
|
10
|
+
expectations.syntax = :expect
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# Include custom matcher descriptions in output
|
13
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
14
|
+
end
|
15
|
+
|
16
|
+
# Disable monkey patching for describe
|
17
|
+
config.expose_dsl_globally = false
|
18
|
+
config.disable_monkey_patching!
|
19
|
+
|
20
|
+
if config.files_to_run.one?
|
21
|
+
# Use the documentation formatter for detailed output
|
22
|
+
config.default_formatter = "doc"
|
23
|
+
end
|
24
|
+
|
25
|
+
# Run specs in random order to surface order dependencies
|
26
|
+
config.order = :random
|
27
|
+
|
28
|
+
# Seed global randomization in this process using the `--seed` CLI option
|
29
|
+
Kernel.srand config.seed
|
16
30
|
end
|
31
|
+
|
32
|
+
require "bamboozled"
|
metadata
CHANGED
@@ -1,43 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboozled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.20'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.20'
|
13
69
|
- !ruby/object:Gem::Dependency
|
14
70
|
name: httparty
|
15
71
|
requirement: !ruby/object:Gem::Requirement
|
16
72
|
requirements:
|
17
|
-
- - "
|
73
|
+
- - "~>"
|
18
74
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
75
|
+
version: '0.13'
|
20
76
|
type: :runtime
|
21
77
|
prerelease: false
|
22
78
|
version_requirements: !ruby/object:Gem::Requirement
|
23
79
|
requirements:
|
24
|
-
- - "
|
80
|
+
- - "~>"
|
25
81
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
82
|
+
version: '0.13'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
84
|
name: json
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|
30
86
|
requirements:
|
31
|
-
- - "
|
87
|
+
- - "~>"
|
32
88
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
89
|
+
version: '1.8'
|
34
90
|
type: :runtime
|
35
91
|
prerelease: false
|
36
92
|
version_requirements: !ruby/object:Gem::Requirement
|
37
93
|
requirements:
|
38
|
-
- - "
|
94
|
+
- - "~>"
|
39
95
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
96
|
+
version: '1.8'
|
41
97
|
- !ruby/object:Gem::Dependency
|
42
98
|
name: activesupport
|
43
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,12 +116,16 @@ extensions: []
|
|
60
116
|
extra_rdoc_files: []
|
61
117
|
files:
|
62
118
|
- ".gitignore"
|
119
|
+
- ".hound.yml"
|
120
|
+
- ".rubocop.yml"
|
63
121
|
- ".travis.yml"
|
122
|
+
- CHANGELOG.md
|
123
|
+
- CONTRIBUTING.md
|
64
124
|
- Gemfile
|
65
|
-
-
|
125
|
+
- Guardfile
|
66
126
|
- LICENSE
|
127
|
+
- README.md
|
67
128
|
- Rakefile
|
68
|
-
- Readme.md
|
69
129
|
- bamboozled.gemspec
|
70
130
|
- examples/employees_over_time.rb
|
71
131
|
- lib/bamboozled.rb
|
@@ -78,13 +138,24 @@ files:
|
|
78
138
|
- lib/bamboozled/errors.rb
|
79
139
|
- lib/bamboozled/ext/yesno.rb
|
80
140
|
- lib/bamboozled/version.rb
|
141
|
+
- logos/bamboozled_logo_black.png
|
142
|
+
- logos/bamboozled_logo_green.png
|
143
|
+
- logos/skookum_mark_black.png
|
144
|
+
- logos/skookum_mark_black.svg
|
145
|
+
- relnotes/v0.1.0.md
|
146
|
+
- spec/fixtures/add_employee_details.json
|
147
|
+
- spec/fixtures/add_employee_response.json
|
148
|
+
- spec/fixtures/add_employee_xml.yml
|
81
149
|
- spec/fixtures/all_employees.json
|
82
150
|
- spec/fixtures/employee_emails.json
|
83
151
|
- spec/fixtures/job_info.xml
|
152
|
+
- spec/fixtures/last_changed.json
|
84
153
|
- spec/fixtures/one_employee.json
|
85
154
|
- spec/fixtures/time_off_estimate.json
|
86
|
-
- spec/
|
87
|
-
- spec/
|
155
|
+
- spec/fixtures/update_employee_details.json
|
156
|
+
- spec/fixtures/update_employee_response.json
|
157
|
+
- spec/fixtures/update_employee_xml.yml
|
158
|
+
- spec/lib/bamboozled/api/employee_spec.rb
|
88
159
|
- spec/spec_helper.rb
|
89
160
|
homepage: http://github.com/Skookum/bamboozled
|
90
161
|
licenses:
|
@@ -106,16 +177,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
177
|
version: '0'
|
107
178
|
requirements: []
|
108
179
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
180
|
+
rubygems_version: 2.4.8
|
110
181
|
signing_key:
|
111
182
|
specification_version: 4
|
112
|
-
summary: A Ruby
|
183
|
+
summary: A Ruby wrapper for the BambooHR API http://www.bamboohr.com/
|
113
184
|
test_files:
|
185
|
+
- spec/fixtures/add_employee_details.json
|
186
|
+
- spec/fixtures/add_employee_response.json
|
187
|
+
- spec/fixtures/add_employee_xml.yml
|
114
188
|
- spec/fixtures/all_employees.json
|
115
189
|
- spec/fixtures/employee_emails.json
|
116
190
|
- spec/fixtures/job_info.xml
|
191
|
+
- spec/fixtures/last_changed.json
|
117
192
|
- spec/fixtures/one_employee.json
|
118
193
|
- spec/fixtures/time_off_estimate.json
|
119
|
-
- spec/
|
120
|
-
- spec/
|
194
|
+
- spec/fixtures/update_employee_details.json
|
195
|
+
- spec/fixtures/update_employee_response.json
|
196
|
+
- spec/fixtures/update_employee_xml.yml
|
197
|
+
- spec/lib/bamboozled/api/employee_spec.rb
|
121
198
|
- spec/spec_helper.rb
|
data/Gemfile.lock
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bamboozled (0.0.6)
|
5
|
-
activesupport
|
6
|
-
httparty
|
7
|
-
json
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: http://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activesupport (3.2.21)
|
13
|
-
i18n (~> 0.6, >= 0.6.4)
|
14
|
-
multi_json (~> 1.0)
|
15
|
-
addressable (2.3.6)
|
16
|
-
ansi (1.4.3)
|
17
|
-
crack (0.4.2)
|
18
|
-
safe_yaml (~> 1.0.0)
|
19
|
-
httparty (0.13.3)
|
20
|
-
json (~> 1.8)
|
21
|
-
multi_xml (>= 0.5.2)
|
22
|
-
i18n (0.7.0)
|
23
|
-
json (1.8.2)
|
24
|
-
minitest (4.7.5)
|
25
|
-
multi_json (1.10.1)
|
26
|
-
multi_xml (0.5.5)
|
27
|
-
rake (10.3.2)
|
28
|
-
safe_yaml (1.0.4)
|
29
|
-
turn (0.9.7)
|
30
|
-
ansi
|
31
|
-
minitest (~> 4)
|
32
|
-
webmock (1.20.4)
|
33
|
-
addressable (>= 2.3.6)
|
34
|
-
crack (>= 0.3.2)
|
35
|
-
|
36
|
-
PLATFORMS
|
37
|
-
ruby
|
38
|
-
|
39
|
-
DEPENDENCIES
|
40
|
-
bamboozled!
|
41
|
-
bundler (>= 1.6.2)
|
42
|
-
rake
|
43
|
-
turn
|
44
|
-
webmock
|