bamboozled-gitlab 0.2.9 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4d649a7e640ec6d04fc6681ae57c009a06074a094d6c03f34e4ebf7608971df
4
- data.tar.gz: 805f024096cb4ec040cebb5abfe38c0c176399b6fdb034af511f01b028cb4194
3
+ metadata.gz: ed4ff015705a09ed7b3ce6974b1a349ab648ac7b7161390e505f664aa023f46f
4
+ data.tar.gz: 1700f18975028a39afcc6965a8421ce45ee057c22efa096f03aac76f3ece9cce
5
5
  SHA512:
6
- metadata.gz: 643909c1f710fca8d51499ad4a83a812764de0a6cdb2c2505112088b0d9bc780de7470d4eaddffcfefbd418afcbb90bc43d9e89ba03b0e7c8df23ee649ea83c9
7
- data.tar.gz: cbfbc6cdb28d1a36345a1451bafcb3c0e36cb5d2789041b9155f059a3804dba33c7a956f694df2b3aac395c8994ac5877cb9459ff6280e93cf0c149d7cfbdda0
6
+ metadata.gz: 17be92333aadccfa927cb99e2e9689da92608622514ad8fd9e4924cd91e1e58eec51f4f1bb0389c3958286df91af1135c3cd190652200870a974a0d4500eebf9
7
+ data.tar.gz: 6cdc1179bd86c9cfd2cc3632fd4e32fca206afef3a584ffcc91abc17e4b0f79bfc1411a58bf4db3cc4d2a6cb5f61f8efd95f8930bf2d5a0a6af1406e2ac53f6a
data/README.md CHANGED
@@ -158,6 +158,11 @@ Please take the time to go through our [contribution guidelines](CONTRIBUTING.md
158
158
  Special thanks to all the awesome people who have helped make this gem better.
159
159
  You can see a list of them [here](https://github.com/Skookum/bamboozled/graphs/contributors).
160
160
 
161
+ #### Deploying to rubygems
162
+ 1. Update the version in the `lib/bamboozled/version.rb` file
163
+ 2. Update specs to use that version
164
+ 3. In github, add a [release](https://github.com/Skookum/bamboozled/releases) off the master branch. This will trigger the github action to deploy to rubygems
165
+
161
166
  ## License
162
167
 
163
168
  This project is licensed under the terms of the MIT license. See the
data/bamboozled.gemspec CHANGED
@@ -6,8 +6,8 @@ require "bamboozled/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "bamboozled-gitlab"
8
8
  spec.version = Bamboozled::VERSION
9
- spec.authors = ["Mark Rickert"]
10
- spec.email = ["mjar81@gmail.com"]
9
+ spec.authors = ["Mark Rickert", "Lien Van Den Steen"]
10
+ spec.email = ["mjar81@gmail.com", "lvandensteen@gitlab.com"]
11
11
  spec.summary = "A Ruby wrapper for the BambooHR API http://www.bamboohr.com/"
12
12
  spec.description = "Bamboozled wraps the BambooHR API without the use of Rails dependencies."
13
13
  spec.homepage = "http://github.com/Skookum/bamboozled"
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "webmock", "~> 1.20"
27
27
 
28
28
  spec.add_dependency "httparty", "~> 0.13"
29
- spec.add_dependency "json", "~> 2.3.0"
29
+ spec.add_dependency "json", ">= 2.3.0"
30
30
  end
@@ -42,7 +42,7 @@ module Bamboozled
42
42
  }.update(options[:headers] || {})
43
43
  })
44
44
 
45
- response = HTTParty.send(method, "#{path_prefix}#{path}", httparty_options)
45
+ response = HTTParty.send(method, "#{path_prefix(options[:api_version])}#{path}", httparty_options)
46
46
  params[:response] = response.inspect.to_s
47
47
  parse_response(response, params)
48
48
  end
@@ -53,8 +53,8 @@ module Bamboozled
53
53
  { username: api_key, password: "x" }
54
54
  end
55
55
 
56
- def path_prefix
57
- "https://api.bamboohr.com/api/gateway.php/#{subdomain}/v1/"
56
+ def path_prefix(version = 'v1')
57
+ "https://api.bamboohr.com/api/gateway.php/#{subdomain}/#{version || 'v1'}/"
58
58
  end
59
59
 
60
60
  def parse_response(response, params)
@@ -59,6 +59,33 @@ module Bamboozled
59
59
  request(:get, "employees/#{employee_id}/time_off/calculator?end=#{end_date}")
60
60
  end
61
61
 
62
+ def time_off_balance_adjustment(employee_id, params)
63
+ allowed_parameters = %i[date timeOffTypeId amount note]
64
+ params = params.keep_if { |k, _| allowed_parameters.include? k }
65
+
66
+ options = {
67
+ body: params.to_json,
68
+ headers: { "Content-Type" => "application/json" }
69
+ }
70
+
71
+ request(:put, "employees/#{employee_id}/time_off/balance_adjustment", options)
72
+ end
73
+
74
+ def time_off_policies(employee_id)
75
+ request(:get, "employees/#{employee_id}/time_off/policies", { api_version: 'v1_1' })
76
+ end
77
+
78
+ def add_time_off_policies(employee_id, policies)
79
+ allowed_keys = %i[timeOffPolicyId accrualStartDate]
80
+ policies = policies.map { |policy| policy.keep_if { |k, _| allowed_keys.include? k } }
81
+
82
+ options = {
83
+ body: policies.to_json
84
+ }
85
+
86
+ request(:put, "employees/#{employee_id}/time_off/policies", options)
87
+ end
88
+
62
89
  def photo_binary(employee_id)
63
90
  request(:get, "employees/#{employee_id}/photo/small")
64
91
  end
@@ -19,7 +19,16 @@ module Bamboozled
19
19
  typecast_values: false)
20
20
  end
21
21
 
22
+ def time_off_types
23
+ request(:get, "meta/time_off/types")
24
+ end
25
+
26
+ def time_off_policies
27
+ options = {
28
+ headers: { "Content-Type" => "application/json" }
29
+ }
30
+ request(:get, "meta/time_off/policies", options)
31
+ end
22
32
  end
23
33
  end
24
34
  end
25
-
@@ -1,3 +1,3 @@
1
1
  module Bamboozled
2
- VERSION = "0.2.9".freeze
2
+ VERSION = "0.2.13".freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ HTTP/1.1 200 OK
2
+ content-type: application/json; charset=utf-8
3
+ date: Tue, 17 Jun 2014 19:25:35 UTC
4
+
5
+ [{"timeOffPolicyId":"14","timeOffTypeId":"3","accrualStartDate":"2014-06-17"}]
@@ -0,0 +1,5 @@
1
+ HTTP/1.1 200 OK
2
+ content-type: application/json; charset=utf-8
3
+ date: Tue, 17 Jun 2014 19:25:35 UTC
4
+
5
+ [{"id":"14","timeOffTypeId":"3","name":"BambooHR Manual Policy","effectiveDate":null,"type":"manual"}]
@@ -0,0 +1,5 @@
1
+ HTTP/1.1 200 OK
2
+ content-type: application/json; charset=utf-8
3
+ date: Tue, 17 Jun 2014 19:25:35 UTC
4
+
5
+ {"timeOffTypes":[{"id":"2","name":"Employee Accruals","units":"days","color":"company","icon":null}],"defaultHours":[{"name":"Saturday","amount":"0"},{"name":"Sunday","amount":"0"},{"name":"default","amount":"8"},{"name":"Monday","amount":"8"},{"name":"Tuesday","amount":"8"},{"name":"Wednesday","amount":"8"},{"name":"Thursday","amount":"8"},{"name":"Friday","amount":"8"}]}
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 201 Created
2
+ content-type: application/json; charset=utf-8
3
+ date: Tue, 17 Jun 2014 19:25:35 UTC
4
+ location: https://api.bamboohr.com/api/gateway.php/alphasights/v1/employees/44259/time_off/history/38668
@@ -66,6 +66,45 @@ RSpec.describe "Employees" do
66
66
  .to match_array %w(timeOffType name units balance)
67
67
  end
68
68
 
69
+ it "Adjusts an employee's time off balance" do
70
+ response = File.new("spec/fixtures/time_off_balance_adjustment.json")
71
+ stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
72
+
73
+ options = {
74
+ date: "2014-06-17",
75
+ timeOffTypeId: 2,
76
+ amount: -1.5,
77
+ note: "test"
78
+ }
79
+
80
+ result = @client.employee.time_off_balance_adjustment("44259", options)
81
+ expect(result).to be_a Hash
82
+ end
83
+
84
+ it "Gets an employee's time off policies" do
85
+ response = File.new("spec/fixtures/employee_time_off_policies.json")
86
+ stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
87
+
88
+ policies = @client.employee.time_off_policies("44259")
89
+
90
+ expect(policies).to be_a Array
91
+ expect(policies.first.keys).to match_array %w(timeOffPolicyId timeOffTypeId accrualStartDate)
92
+ end
93
+
94
+ it "adds an employee time off policy" do
95
+ response = File.new("spec/fixtures/employee_time_off_policies.json")
96
+ stub_request(:any, /.*api\.bamboohr\.com.*/).to_return(response)
97
+
98
+ policies = [{
99
+ timeOffPolicyId: 2,
100
+ accrualStartDate: "2014-06-17"
101
+ }]
102
+
103
+ result = @client.employee.add_time_off_policies("44259", policies)
104
+ expect(policies).to be_a Array
105
+ expect(result.first.keys).to match_array %w(timeOffPolicyId timeOffTypeId accrualStartDate)
106
+ end
107
+
69
108
  it "returns the proper url using employee email address" do
70
109
  hashed = "4fdce145bab6d27d69e34403f99fd11c" # Hash of me@here.com
71
110
  required_url = "http://x.bamboohr.com/employees/photos/?h=#{hashed}"
@@ -44,4 +44,20 @@ RSpec.describe "Meta" do
44
44
  fields = @client.meta.lists
45
45
  expect(fields).to be_a Array
46
46
  end
47
+
48
+ it "Gets time off types" do
49
+ res = get_response("spec/fixtures/meta_time_off_types.json")
50
+ make_stub(res)
51
+
52
+ types = @client.meta.time_off_types
53
+ expect(types).to be_a Hash
54
+ end
55
+
56
+ it "Gets time off policies" do
57
+ res = get_response("spec/fixtures/meta_time_off_policies.json")
58
+ make_stub(res)
59
+
60
+ types = @client.meta.time_off_types
61
+ expect(types).to be_a Array
62
+ end
47
63
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboozled-gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rickert
8
- autorequire:
8
+ - Lien Van Den Steen
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
12
+ date: 2022-01-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -84,19 +85,20 @@ dependencies:
84
85
  name: json
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
- - - "~>"
88
+ - - ">="
88
89
  - !ruby/object:Gem::Version
89
90
  version: 2.3.0
90
91
  type: :runtime
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - "~>"
95
+ - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: 2.3.0
97
98
  description: Bamboozled wraps the BambooHR API without the use of Rails dependencies.
98
99
  email:
99
100
  - mjar81@gmail.com
101
+ - lvandensteen@gitlab.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []
@@ -136,7 +138,6 @@ files:
136
138
  - logos/bamboozled_logo_green.png
137
139
  - logos/skookum_mark_black.png
138
140
  - logos/skookum_mark_black.svg
139
- - relnotes/v0.1.0.md
140
141
  - spec/fixtures/add_employee_details.json
141
142
  - spec/fixtures/add_employee_response.json
142
143
  - spec/fixtures/add_employee_xml.yml
@@ -144,13 +145,17 @@ files:
144
145
  - spec/fixtures/custom_report.json
145
146
  - spec/fixtures/employee_emails.json
146
147
  - spec/fixtures/employee_table_details.json
148
+ - spec/fixtures/employee_time_off_policies.json
147
149
  - spec/fixtures/job_info.xml
148
150
  - spec/fixtures/last_changed.json
149
151
  - spec/fixtures/meta_fields.json
150
152
  - spec/fixtures/meta_lists.json
151
153
  - spec/fixtures/meta_tables.json
154
+ - spec/fixtures/meta_time_off_policies.json
155
+ - spec/fixtures/meta_time_off_types.json
152
156
  - spec/fixtures/meta_users.json
153
157
  - spec/fixtures/one_employee.json
158
+ - spec/fixtures/time_off_balance_adjustment.json
154
159
  - spec/fixtures/time_off_estimate.json
155
160
  - spec/fixtures/time_tracking_add_200_response.json
156
161
  - spec/fixtures/time_tracking_add_empty_response.json
@@ -178,7 +183,7 @@ homepage: http://github.com/Skookum/bamboozled
178
183
  licenses:
179
184
  - MIT
180
185
  metadata: {}
181
- post_install_message:
186
+ post_install_message:
182
187
  rdoc_options: []
183
188
  require_paths:
184
189
  - lib
@@ -193,8 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
198
  - !ruby/object:Gem::Version
194
199
  version: '0'
195
200
  requirements: []
196
- rubygems_version: 3.1.2
197
- signing_key:
201
+ rubygems_version: 3.2.3
202
+ signing_key:
198
203
  specification_version: 4
199
204
  summary: A Ruby wrapper for the BambooHR API http://www.bamboohr.com/
200
205
  test_files:
@@ -205,13 +210,17 @@ test_files:
205
210
  - spec/fixtures/custom_report.json
206
211
  - spec/fixtures/employee_emails.json
207
212
  - spec/fixtures/employee_table_details.json
213
+ - spec/fixtures/employee_time_off_policies.json
208
214
  - spec/fixtures/job_info.xml
209
215
  - spec/fixtures/last_changed.json
210
216
  - spec/fixtures/meta_fields.json
211
217
  - spec/fixtures/meta_lists.json
212
218
  - spec/fixtures/meta_tables.json
219
+ - spec/fixtures/meta_time_off_policies.json
220
+ - spec/fixtures/meta_time_off_types.json
213
221
  - spec/fixtures/meta_users.json
214
222
  - spec/fixtures/one_employee.json
223
+ - spec/fixtures/time_off_balance_adjustment.json
215
224
  - spec/fixtures/time_off_estimate.json
216
225
  - spec/fixtures/time_tracking_add_200_response.json
217
226
  - spec/fixtures/time_tracking_add_empty_response.json
data/relnotes/v0.1.0.md DELETED
@@ -1,13 +0,0 @@
1
- ### New Features
2
-
3
- * New method `Employee#add` allows client to create new employees. ([@kylefdoherty][])
4
- * New method `Employee#update` allows client to update new employees. ([@kylefdoherty][])
5
-
6
- ### Changes
7
-
8
- ### Bug Fixes
9
-
10
- * Added missing documentation for `Employee#add`. ([@mjording][])
11
-
12
- [@kylefdoherty]: https://github.com/kylefdoherty
13
- [@mjording]: https://github.com/mjording