bamboozled 0.1.0 → 0.2.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 +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- data/.github/ISSUE_TEMPLATE/question.md +19 -0
- data/.github/main.workflow +38 -0
- data/.github/pull_request_template.md +27 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -2
- data/.rubocop_todo.yml +305 -0
- data/.travis.yml +7 -8
- data/CHANGELOG.md +22 -1
- data/CONTRIBUTING.md +2 -2
- data/Dockerfile +8 -0
- data/Gemfile +3 -2
- data/README.md +11 -1
- data/bamboozled.gemspec +2 -3
- data/lib/bamboozled.rb +4 -2
- data/lib/bamboozled/api/base.rb +63 -59
- data/lib/bamboozled/api/employee.rb +1 -6
- data/lib/bamboozled/api/field_collection.rb +107 -0
- data/lib/bamboozled/api/meta.rb +15 -5
- data/lib/bamboozled/api/report.rb +10 -6
- data/lib/bamboozled/api/time_off.rb +9 -6
- data/lib/bamboozled/api/time_tracking.rb +24 -0
- data/lib/bamboozled/base.rb +12 -6
- data/lib/bamboozled/version.rb +1 -1
- data/spec/fixtures/add_employee_xml.yml +1 -1
- data/spec/fixtures/custom_report.json +38 -0
- data/spec/fixtures/meta_fields.json +5 -0
- data/spec/fixtures/meta_lists.json +5 -0
- data/spec/fixtures/meta_tables.json +5 -0
- data/spec/fixtures/meta_users.json +4 -0
- data/spec/fixtures/time_tracking_add_200_response.json +7 -0
- data/spec/fixtures/time_tracking_add_empty_response.json +9 -0
- data/spec/fixtures/time_tracking_adjust_200_response.json +7 -0
- data/spec/fixtures/time_tracking_adjust_400_response.json +11 -0
- data/spec/fixtures/time_tracking_record_200_response.json +9 -0
- data/spec/fixtures/time_tracking_record_400_response.json +11 -0
- data/spec/fixtures/time_tracking_record_401_response.json +10 -0
- data/spec/fixtures/time_tracking_record_404_response.json +8 -0
- data/spec/fixtures/update_employee_xml.yml +1 -1
- data/spec/lib/bamboozled/api/base_spec.rb +18 -0
- data/spec/lib/bamboozled/api/employee_spec.rb +0 -14
- data/spec/lib/bamboozled/api/field_collection_spec.rb +17 -0
- data/spec/lib/bamboozled/api/meta_spec.rb +47 -0
- data/spec/lib/bamboozled/api/report_spec.rb +17 -0
- data/spec/lib/bamboozled/api/time_tracking_spec.rb +123 -0
- data/spec/lib/bamboozled/base_spec.rb +26 -0
- data/spec/lib/bamboozled_spec.rb +33 -0
- metadata +54 -21
- data/.hound.yml +0 -2
@@ -0,0 +1,123 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Time Tracking" do
|
4
|
+
before do
|
5
|
+
@client = Bamboozled.client(subdomain: "x", api_key: "x")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#record' do
|
9
|
+
context 'api success' do
|
10
|
+
it 'gets the given record' do
|
11
|
+
response = File.new("spec/fixtures/time_tracking_record_200_response.json")
|
12
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
13
|
+
|
14
|
+
record = @client.time_tracking.record('37_2301_REG')
|
15
|
+
|
16
|
+
expect(record).to be_a Hash
|
17
|
+
expect(record['payRate']).to eq('19.0000')
|
18
|
+
expect(record['employeeId']).to eq('40488')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'api failures' do
|
23
|
+
context 'bad api key' do
|
24
|
+
it 'should raise an error' do
|
25
|
+
response = File.new("spec/fixtures/time_tracking_record_401_response.json")
|
26
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
27
|
+
|
28
|
+
expect do
|
29
|
+
@client.time_tracking.record('37_2301_REG')
|
30
|
+
end.to raise_error(Bamboozled::AuthenticationFailed)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context 'invalid company name' do
|
34
|
+
it 'should raise an error' do
|
35
|
+
response = File.new("spec/fixtures/time_tracking_record_404_response.json")
|
36
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
37
|
+
|
38
|
+
expect do
|
39
|
+
@client.time_tracking.record('37_2301_REG')
|
40
|
+
end.to raise_error(Bamboozled::NotFound)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context 'invalid time tracking id' do
|
44
|
+
it 'should raise an error' do
|
45
|
+
response = File.new("spec/fixtures/time_tracking_record_400_response.json")
|
46
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
47
|
+
|
48
|
+
expect do
|
49
|
+
@client.time_tracking.record('37_2301_REG')
|
50
|
+
end.to raise_error(Bamboozled::BadRequest)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#add' do
|
57
|
+
describe 'api success' do
|
58
|
+
it 'should return a hash with the id of the created record' do
|
59
|
+
response = File.new("spec/fixtures/time_tracking_add_200_response.json")
|
60
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
61
|
+
|
62
|
+
data = {
|
63
|
+
timeTrackingId: '37_2302_REG',
|
64
|
+
employeeId: '40488',
|
65
|
+
dateHoursWorked: '2016-08-12',
|
66
|
+
payRate: '19.00',
|
67
|
+
rateType: 'REG',
|
68
|
+
hoursWorked: '4.5760'
|
69
|
+
}
|
70
|
+
record = @client.time_tracking.add(data)
|
71
|
+
expect(record).to be_a Hash
|
72
|
+
expect(record['id']).to eq('37_2302_REG')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'api failures' do
|
77
|
+
context 'employee id does not exist' do
|
78
|
+
it 'should not raise an error but should not have an object in the response payload' do
|
79
|
+
response = File.new("spec/fixtures/time_tracking_add_empty_response.json")
|
80
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
81
|
+
|
82
|
+
data = {
|
83
|
+
timeTrackingId: '37_2302_REG',
|
84
|
+
employeeId: '40488',
|
85
|
+
dateHoursWorked: '2016-08-12',
|
86
|
+
payRate: '19.00',
|
87
|
+
rateType: 'REG',
|
88
|
+
hoursWorked: '4.5760'
|
89
|
+
}
|
90
|
+
record = @client.time_tracking.add(data)
|
91
|
+
expect(record).to be_a Hash
|
92
|
+
expect(record['headers']['content-length']).to eq('0')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#adjust' do
|
99
|
+
describe 'api success' do
|
100
|
+
it 'should return a hash with the id of the created record' do
|
101
|
+
response = File.new("spec/fixtures/time_tracking_adjust_200_response.json")
|
102
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
103
|
+
|
104
|
+
record = @client.time_tracking.adjust('37_2302_REG', '4.8')
|
105
|
+
expect(record).to be_a Hash
|
106
|
+
expect(record['id']).to eq('37_2302_REG')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'api failures' do
|
111
|
+
context 'time tracking id does not exist' do
|
112
|
+
it 'should raise a Bad Request error' do
|
113
|
+
response = File.new("spec/fixtures/time_tracking_adjust_400_response.json")
|
114
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
115
|
+
|
116
|
+
expect do
|
117
|
+
@client.time_tracking.adjust('37_2303_REG', '4.8')
|
118
|
+
end.to raise_error(Bamboozled::BadRequest)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Bamboozled::Base" do
|
4
|
+
let(:base) { Bamboozled::Base.new(subdomain: "x", api_key: "x", httparty_options: {log_format: :curl}) }
|
5
|
+
|
6
|
+
it "passes HTTParty options to Bamboozled::API::Employee constructor" do
|
7
|
+
expect(Bamboozled::API::Employee).to receive(:new).with("x", "x", { log_format: :curl })
|
8
|
+
base.employee
|
9
|
+
end
|
10
|
+
it "passes HTTParty options to Bamboozled::API::Report constructor" do
|
11
|
+
expect(Bamboozled::API::Report).to receive(:new).with("x", "x", { log_format: :curl })
|
12
|
+
base.report
|
13
|
+
end
|
14
|
+
it "passes HTTParty options to Bamboozled::API::Meta constructor" do
|
15
|
+
expect(Bamboozled::API::Meta).to receive(:new).with("x", "x", { log_format: :curl })
|
16
|
+
base.meta
|
17
|
+
end
|
18
|
+
it "passes HTTParty options to Bamboozled::API::TimeOff constructor" do
|
19
|
+
expect(Bamboozled::API::TimeOff).to receive(:new).with("x", "x", { log_format: :curl })
|
20
|
+
base.time_off
|
21
|
+
end
|
22
|
+
it "passes HTTParty options to Bamboozled::API::TimeTracking constructor" do
|
23
|
+
expect(Bamboozled::API::TimeTracking).to receive(:new).with("x", "x", { log_format: :curl })
|
24
|
+
base.time_tracking
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Bamboozled" do
|
4
|
+
it "takes HTTParty options as a parameter" do
|
5
|
+
expect(Bamboozled::Base).to receive(:new).with(subdomain: "x", api_key: "x", httparty_options: { log_format: :curl })
|
6
|
+
Bamboozled.client(subdomain: "x", api_key: "x", httparty_options: { log_format: :curl })
|
7
|
+
end
|
8
|
+
|
9
|
+
it "throws no errors if no HTTParty options were provided (they are optional)" do
|
10
|
+
expect { Bamboozled.client(subdomain: "x", api_key: "x") }.not_to raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it "passes HTTParty params to HTTParty" do
|
14
|
+
logger = double("logger")
|
15
|
+
allow(Time).to receive_message_chain(:now, :strftime).and_return("Time.now")
|
16
|
+
expect(logger).to receive(:info).with('[HTTParty] [Time.now] 200 "GET https://api.bamboohr.com/api/gateway.php/x/v1/employees/1234?fields=" - ')
|
17
|
+
|
18
|
+
client = Bamboozled.client(subdomain: "x", api_key: "x", httparty_options: { log_format: :apache, logger: logger })
|
19
|
+
response = File.new("spec/fixtures/one_employee.json")
|
20
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
21
|
+
|
22
|
+
employee = client.employee.find(1234)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "works without HTTParty options provided" do
|
26
|
+
client = Bamboozled.client(subdomain: "x", api_key: "x")
|
27
|
+
response = File.new("spec/fixtures/one_employee.json")
|
28
|
+
stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
|
29
|
+
|
30
|
+
employee = client.employee.find(1234)
|
31
|
+
expect(employee["firstName"]).to eq "John"
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboozled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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: 2019-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.8'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: activesupport
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
description: Bamboozled wraps the BambooHR API without the use of Rails dependencies.
|
112
98
|
email:
|
113
99
|
- mjar81@gmail.com
|
@@ -115,12 +101,18 @@ executables: []
|
|
115
101
|
extensions: []
|
116
102
|
extra_rdoc_files: []
|
117
103
|
files:
|
104
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
105
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
106
|
+
- ".github/ISSUE_TEMPLATE/question.md"
|
107
|
+
- ".github/main.workflow"
|
108
|
+
- ".github/pull_request_template.md"
|
118
109
|
- ".gitignore"
|
119
|
-
- ".hound.yml"
|
120
110
|
- ".rubocop.yml"
|
111
|
+
- ".rubocop_todo.yml"
|
121
112
|
- ".travis.yml"
|
122
113
|
- CHANGELOG.md
|
123
114
|
- CONTRIBUTING.md
|
115
|
+
- Dockerfile
|
124
116
|
- Gemfile
|
125
117
|
- Guardfile
|
126
118
|
- LICENSE
|
@@ -131,9 +123,11 @@ files:
|
|
131
123
|
- lib/bamboozled.rb
|
132
124
|
- lib/bamboozled/api/base.rb
|
133
125
|
- lib/bamboozled/api/employee.rb
|
126
|
+
- lib/bamboozled/api/field_collection.rb
|
134
127
|
- lib/bamboozled/api/meta.rb
|
135
128
|
- lib/bamboozled/api/report.rb
|
136
129
|
- lib/bamboozled/api/time_off.rb
|
130
|
+
- lib/bamboozled/api/time_tracking.rb
|
137
131
|
- lib/bamboozled/base.rb
|
138
132
|
- lib/bamboozled/errors.rb
|
139
133
|
- lib/bamboozled/ext/yesno.rb
|
@@ -147,15 +141,35 @@ files:
|
|
147
141
|
- spec/fixtures/add_employee_response.json
|
148
142
|
- spec/fixtures/add_employee_xml.yml
|
149
143
|
- spec/fixtures/all_employees.json
|
144
|
+
- spec/fixtures/custom_report.json
|
150
145
|
- spec/fixtures/employee_emails.json
|
151
146
|
- spec/fixtures/job_info.xml
|
152
147
|
- spec/fixtures/last_changed.json
|
148
|
+
- spec/fixtures/meta_fields.json
|
149
|
+
- spec/fixtures/meta_lists.json
|
150
|
+
- spec/fixtures/meta_tables.json
|
151
|
+
- spec/fixtures/meta_users.json
|
153
152
|
- spec/fixtures/one_employee.json
|
154
153
|
- spec/fixtures/time_off_estimate.json
|
154
|
+
- spec/fixtures/time_tracking_add_200_response.json
|
155
|
+
- spec/fixtures/time_tracking_add_empty_response.json
|
156
|
+
- spec/fixtures/time_tracking_adjust_200_response.json
|
157
|
+
- spec/fixtures/time_tracking_adjust_400_response.json
|
158
|
+
- spec/fixtures/time_tracking_record_200_response.json
|
159
|
+
- spec/fixtures/time_tracking_record_400_response.json
|
160
|
+
- spec/fixtures/time_tracking_record_401_response.json
|
161
|
+
- spec/fixtures/time_tracking_record_404_response.json
|
155
162
|
- spec/fixtures/update_employee_details.json
|
156
163
|
- spec/fixtures/update_employee_response.json
|
157
164
|
- spec/fixtures/update_employee_xml.yml
|
165
|
+
- spec/lib/bamboozled/api/base_spec.rb
|
158
166
|
- spec/lib/bamboozled/api/employee_spec.rb
|
167
|
+
- spec/lib/bamboozled/api/field_collection_spec.rb
|
168
|
+
- spec/lib/bamboozled/api/meta_spec.rb
|
169
|
+
- spec/lib/bamboozled/api/report_spec.rb
|
170
|
+
- spec/lib/bamboozled/api/time_tracking_spec.rb
|
171
|
+
- spec/lib/bamboozled/base_spec.rb
|
172
|
+
- spec/lib/bamboozled_spec.rb
|
159
173
|
- spec/spec_helper.rb
|
160
174
|
homepage: http://github.com/Skookum/bamboozled
|
161
175
|
licenses:
|
@@ -176,8 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
190
|
- !ruby/object:Gem::Version
|
177
191
|
version: '0'
|
178
192
|
requirements: []
|
179
|
-
|
180
|
-
rubygems_version: 2.4.8
|
193
|
+
rubygems_version: 3.0.3
|
181
194
|
signing_key:
|
182
195
|
specification_version: 4
|
183
196
|
summary: A Ruby wrapper for the BambooHR API http://www.bamboohr.com/
|
@@ -186,13 +199,33 @@ test_files:
|
|
186
199
|
- spec/fixtures/add_employee_response.json
|
187
200
|
- spec/fixtures/add_employee_xml.yml
|
188
201
|
- spec/fixtures/all_employees.json
|
202
|
+
- spec/fixtures/custom_report.json
|
189
203
|
- spec/fixtures/employee_emails.json
|
190
204
|
- spec/fixtures/job_info.xml
|
191
205
|
- spec/fixtures/last_changed.json
|
206
|
+
- spec/fixtures/meta_fields.json
|
207
|
+
- spec/fixtures/meta_lists.json
|
208
|
+
- spec/fixtures/meta_tables.json
|
209
|
+
- spec/fixtures/meta_users.json
|
192
210
|
- spec/fixtures/one_employee.json
|
193
211
|
- spec/fixtures/time_off_estimate.json
|
212
|
+
- spec/fixtures/time_tracking_add_200_response.json
|
213
|
+
- spec/fixtures/time_tracking_add_empty_response.json
|
214
|
+
- spec/fixtures/time_tracking_adjust_200_response.json
|
215
|
+
- spec/fixtures/time_tracking_adjust_400_response.json
|
216
|
+
- spec/fixtures/time_tracking_record_200_response.json
|
217
|
+
- spec/fixtures/time_tracking_record_400_response.json
|
218
|
+
- spec/fixtures/time_tracking_record_401_response.json
|
219
|
+
- spec/fixtures/time_tracking_record_404_response.json
|
194
220
|
- spec/fixtures/update_employee_details.json
|
195
221
|
- spec/fixtures/update_employee_response.json
|
196
222
|
- spec/fixtures/update_employee_xml.yml
|
223
|
+
- spec/lib/bamboozled/api/base_spec.rb
|
197
224
|
- spec/lib/bamboozled/api/employee_spec.rb
|
225
|
+
- spec/lib/bamboozled/api/field_collection_spec.rb
|
226
|
+
- spec/lib/bamboozled/api/meta_spec.rb
|
227
|
+
- spec/lib/bamboozled/api/report_spec.rb
|
228
|
+
- spec/lib/bamboozled/api/time_tracking_spec.rb
|
229
|
+
- spec/lib/bamboozled/base_spec.rb
|
230
|
+
- spec/lib/bamboozled_spec.rb
|
198
231
|
- spec/spec_helper.rb
|
data/.hound.yml
DELETED