bamboozled-gitlab 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  4. data/.github/ISSUE_TEMPLATE/question.md +19 -0
  5. data/.github/main.workflow +38 -0
  6. data/.github/pull_request_template.md +27 -0
  7. data/.gitignore +38 -0
  8. data/.rubocop.yml +39 -0
  9. data/.rubocop_todo.yml +305 -0
  10. data/.travis.yml +18 -0
  11. data/CHANGELOG.md +48 -0
  12. data/CONTRIBUTING.md +91 -0
  13. data/Dockerfile +8 -0
  14. data/Gemfile +16 -0
  15. data/Guardfile +21 -0
  16. data/LICENSE +22 -0
  17. data/README.md +170 -0
  18. data/Rakefile +11 -0
  19. data/bamboozled.gemspec +30 -0
  20. data/examples/employees_over_time.rb +53 -0
  21. data/lib/bamboozled.rb +24 -0
  22. data/lib/bamboozled/api/base.rb +101 -0
  23. data/lib/bamboozled/api/employee.rb +118 -0
  24. data/lib/bamboozled/api/field_collection.rb +107 -0
  25. data/lib/bamboozled/api/meta.rb +25 -0
  26. data/lib/bamboozled/api/report.rb +20 -0
  27. data/lib/bamboozled/api/time_off.rb +34 -0
  28. data/lib/bamboozled/api/time_tracking.rb +24 -0
  29. data/lib/bamboozled/base.rb +31 -0
  30. data/lib/bamboozled/errors.rb +33 -0
  31. data/lib/bamboozled/ext/yesno.rb +11 -0
  32. data/lib/bamboozled/version.rb +3 -0
  33. data/logos/bamboozled_logo_black.png +0 -0
  34. data/logos/bamboozled_logo_green.png +0 -0
  35. data/logos/skookum_mark_black.png +0 -0
  36. data/logos/skookum_mark_black.svg +175 -0
  37. data/relnotes/v0.1.0.md +13 -0
  38. data/spec/fixtures/add_employee_details.json +7 -0
  39. data/spec/fixtures/add_employee_response.json +4 -0
  40. data/spec/fixtures/add_employee_xml.yml +8 -0
  41. data/spec/fixtures/all_employees.json +58 -0
  42. data/spec/fixtures/custom_report.json +38 -0
  43. data/spec/fixtures/employee_emails.json +9 -0
  44. data/spec/fixtures/employee_table_details.json +17 -0
  45. data/spec/fixtures/job_info.xml +22 -0
  46. data/spec/fixtures/last_changed.json +28 -0
  47. data/spec/fixtures/meta_fields.json +5 -0
  48. data/spec/fixtures/meta_lists.json +5 -0
  49. data/spec/fixtures/meta_tables.json +5 -0
  50. data/spec/fixtures/meta_users.json +4 -0
  51. data/spec/fixtures/one_employee.json +9 -0
  52. data/spec/fixtures/time_off_estimate.json +23 -0
  53. data/spec/fixtures/time_tracking_add_200_response.json +7 -0
  54. data/spec/fixtures/time_tracking_add_empty_response.json +9 -0
  55. data/spec/fixtures/time_tracking_adjust_200_response.json +7 -0
  56. data/spec/fixtures/time_tracking_adjust_400_response.json +11 -0
  57. data/spec/fixtures/time_tracking_record_200_response.json +9 -0
  58. data/spec/fixtures/time_tracking_record_400_response.json +11 -0
  59. data/spec/fixtures/time_tracking_record_401_response.json +10 -0
  60. data/spec/fixtures/time_tracking_record_404_response.json +8 -0
  61. data/spec/fixtures/update_employee_details.json +7 -0
  62. data/spec/fixtures/update_employee_response.json +3 -0
  63. data/spec/fixtures/update_employee_table.json +8 -0
  64. data/spec/fixtures/update_employee_table_xml.yml +6 -0
  65. data/spec/fixtures/update_employee_xml.yml +8 -0
  66. data/spec/lib/bamboozled/api/base_spec.rb +18 -0
  67. data/spec/lib/bamboozled/api/employee_spec.rb +186 -0
  68. data/spec/lib/bamboozled/api/field_collection_spec.rb +17 -0
  69. data/spec/lib/bamboozled/api/meta_spec.rb +47 -0
  70. data/spec/lib/bamboozled/api/report_spec.rb +17 -0
  71. data/spec/lib/bamboozled/api/time_tracking_spec.rb +123 -0
  72. data/spec/lib/bamboozled/base_spec.rb +26 -0
  73. data/spec/lib/bamboozled_spec.rb +33 -0
  74. data/spec/spec_helper.rb +32 -0
  75. metadata +237 -0
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.2
5
+ - 2.3.0
6
+ - 2.4.0
7
+ - ruby-head
8
+ - jruby-head
9
+
10
+ script:
11
+ - bundle exec rspec
12
+ - bundle exec rubocop
13
+
14
+ matrix:
15
+ fast_finish: true
16
+ allow_failures:
17
+ - rvm: ruby-head
18
+ - rvm: jruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ ## develop (unreleased)
4
+
5
+ ### New Features
6
+
7
+ ### Changes
8
+
9
+ ### Bug Fixes
10
+
11
+ ## 0.2.0 (2019-03-01)
12
+
13
+ ### New Features
14
+
15
+ * New method `Report#custom` allows fetching a custom report of employees. ([@artfuldodger][])
16
+ * Make httpparty options configurable ([@ivanovv][])
17
+ * Add time tracking api interface ([@nlively][])
18
+
19
+ ### Changes
20
+
21
+ * Using github actions for linting and testing
22
+
23
+ ### Bug Fixes
24
+
25
+ * Fix Metadata API calls. Fixes [Issue #38](https://github.com/Skookum/bamboozled/issues/36) and [Issue #5](https://github.com/Skookum/bamboozled/issues/5)
26
+
27
+ ## 0.1.0 (2016-06-14)
28
+
29
+ ### New Features
30
+
31
+ * New method `Employee#add` allows client to create new employees. ([@kylefdoherty][])
32
+ * New method `Employee#update` allows client to update new employees. ([@kylefdoherty][])
33
+
34
+ ### Changes
35
+
36
+ ### Bug Fixes
37
+
38
+ * Added missing documentation for `Employee#add`. ([@mjording][])
39
+
40
+ [@markrickert]: https://github.com/markrickert
41
+ [@enriikke]: https://github.com/Enriikke
42
+ [@kylefdoherty]: https://github.com/kylefdoherty
43
+ [@mjording]: https://github.com/mjording
44
+ [@artfuldodger]: https://github.com/artfuldodger
45
+ [@splybon]: https://github.com/splybon
46
+ [@chrisman]: https://github.com/chrisman
47
+ [@ivanovv]: https://github.com/ivanovv
48
+ [@nlively]: https://github.com/nlively
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,91 @@
1
+ # Contributing
2
+
3
+ Contributions are always welcome! If you discover issues or have ideas for
4
+ improvements, report them or submit pull requests. Please follow the guidelines
5
+ below when doing so.
6
+
7
+ ## Issue Reporting
8
+
9
+ * Make sure the issue has not already been reported.
10
+ * Check that the issue has not already been fixed in `develop`.
11
+ * Open a [new issue](https://github.com/Skookum/bamboozled/issues/new) with a
12
+ clear and concise description of the problem.
13
+ * Include any relevant code or error output in the issue summary.
14
+
15
+ ## Pull Request
16
+
17
+ * Fork the project.
18
+ * Create a new branch for your feature/bug **off of develop**.
19
+ * Get coding!
20
+ * Write good tests. See [Testing](#testing).
21
+ * Follow the same coding conventions as the rest of the project. See [Coding Style](#coding-style).
22
+ * Squash related commits when needed and write good commit messages.
23
+ * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [Changelog Entries](#changelog-entries).
24
+ * Make sure the test suite is passing and that there are no style violations
25
+ before pushing your code.
26
+ * Pull requests should be related to a single subject.
27
+ * Open a pull request until you are happy with your contribution.
28
+
29
+ ### Testing
30
+
31
+ Always include tests with you code. Bamboozled uses [RSpec](https://github.com/rspec/rspec)
32
+ for testing. We like to follow the recommendations listed in [Better Specs](http://betterspecs.org/).
33
+
34
+ ```sh
35
+ # Run the entire test suite.
36
+ bundle exec rspec
37
+
38
+ # Run specific test files.
39
+ bundle exec rspec spec/lib/bamboozled/lib/employee_spec.rb
40
+ ```
41
+
42
+ Alternatively, the `Gemfile` includes [Guard](https://github.com/guard/guard), a
43
+ file watcher that will automatically run `rspec` when a file is saved. This is
44
+ not a requirement but we encourage running `bundle exec guard` before starting
45
+ development so that you are able to catch failed tests as you code away :-).
46
+
47
+ ### Coding Style
48
+
49
+ Bamboozled leverages [Hound](https://houndci.com/) to maintain the code style
50
+ consistent. Hound uses [rubocop](https://github.com/bbatsov/rubocop), which you
51
+ can run locally:
52
+
53
+ ```sh
54
+ # Run for the entire codebase.
55
+ bundle exec rubocop
56
+
57
+ # Run for a specific file.
58
+ bundle exec rubocop lib/bamboozled.rb
59
+ ```
60
+
61
+ Just like with tests, `guard` will automatically run `rubocop` when a file is
62
+ saved (unless a test fails). Once again, we would like to encourage running
63
+ `bundle exec guard` before starting development.
64
+
65
+ Hound will comment on pull requests with style violations, and pull requests
66
+ won't be merged until violations are corrected.
67
+
68
+ ### Changelog Entries
69
+
70
+ * Use [Markdown syntax](http://daringfireball.net/projects/markdown/syntax).
71
+ * The entry line should start with a bullet point `*`.
72
+ * If the change has a related GitHub issue, include a link to it as
73
+ `[#1](https://github.com/Skookum/bamboozled/issues/1):`.
74
+ * Provide a brief summary of the change.
75
+ * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
76
+ * If this is your first contribution, add a link definition for the implicit
77
+ link to the bottom of the changelog as `[@username]:
78
+ https://github.com/username`.
79
+
80
+ Here are a few examples:
81
+
82
+ ```
83
+ * [#3](https://github.com/Skookum/bamboozled/issues/3): Added `HashWithIndifferentAccess` to to fix inconsistencies when accessing data. ([@markrickert][])
84
+ * New method `Employee#add` allows client to create new employees. ([@kylefdoherty][])
85
+ ```
86
+
87
+ ---
88
+
89
+ <p align="center">
90
+ <img src="logos/skookum_mark_black.png" alt="Skookum" width="100" />
91
+ </p>
data/Dockerfile ADDED
@@ -0,0 +1,8 @@
1
+ FROM ruby:2.5
2
+
3
+ ENV APP_HOME /app
4
+ RUN apt-get update -qq && apt-get install -y build-essential
5
+ RUN mkdir $APP_HOME
6
+ WORKDIR $APP_HOME
7
+ ADD . $APP_HOME/
8
+ RUN bundle install
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+ group :test do
5
+ gem "coveralls", require: false
6
+ end
7
+
8
+ group :development, :test do
9
+ gem "listen", "3.0.7"
10
+ gem "guard"
11
+ gem "guard-rspec", require: false
12
+ gem "guard-rubocop", require: false
13
+ gem "rubocop", "~> 0.63.1", require: false
14
+ gem "rubocop-rspec", require: false
15
+
16
+ end
data/Guardfile ADDED
@@ -0,0 +1,21 @@
1
+ group :tdd, halt_on_fail: true do
2
+ guard :rspec, cmd: "bundle exec rspec" do
3
+ require "guard/rspec/dsl"
4
+ dsl = Guard::RSpec::Dsl.new(self)
5
+
6
+ # RSpec files
7
+ rspec = dsl.rspec
8
+ watch(rspec.spec_helper) { rspec.spec_dir }
9
+ watch(rspec.spec_support) { rspec.spec_dir }
10
+ watch(rspec.spec_files)
11
+
12
+ # Ruby files
13
+ ruby = dsl.ruby
14
+ dsl.watch_spec_files_for(ruby.lib_files)
15
+ end
16
+
17
+ guard :rubocop, all_on_start: false, cmd: "rubocop --require rubocop-rspec" do
18
+ watch(%r{.+\.rb$}) { |m| m[0] }
19
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
20
+ end
21
+ end
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 ADDED
@@ -0,0 +1,170 @@
1
+ [![Gem Version](https://img.shields.io/gem/v/bamboozled.svg)][rubygems]
2
+ [![Build Status](https://img.shields.io/travis/Skookum/bamboozled.svg)][travis]
3
+ [![Code Climate](https://img.shields.io/codeclimate/github/Skookum/bamboozled.svg)][codeclimate]
4
+ [![Coverage Status](https://img.shields.io/coveralls/Skookum/bamboozled.svg)][coveralls]
5
+ [![Inline Docs](http://inch-ci.org/github/Skookum/bamboozled.svg?style=shields)][inchdocs]
6
+
7
+ [rubygems]: https://rubygems.org/gems/bamboozled
8
+ [travis]: https://travis-ci.org/Skookum/bamboozled
9
+ [codeclimate]: https://codeclimate.com/github/Skookum/bamboozled
10
+ [coveralls]: https://coveralls.io/r/Skookum/bamboozled
11
+ [inchdocs]: http://inch-ci.org/github/Skookum/bamboozled
12
+
13
+ ---
14
+
15
+ <p align="center">
16
+ <img src="logos/bamboozled_logo_black.png" alt="Bamboozled" />
17
+ </p>
18
+
19
+ Bamboozled is a Ruby wrapper for the [BambooHR API](http://www.bamboohr.com/api/documentation/).
20
+
21
+ ## Versioning
22
+
23
+ Bamboozled follows [Semantic Versioning 2.0.0](http://semver.org/). Make sure to
24
+ always bound the major version when installing if you want to avoid breaking
25
+ changes.
26
+
27
+ ## Documentation
28
+
29
+ This documentation tracks the latest changes in the `master` branch of this
30
+ repo. Some of the features described might not be available in older versions of
31
+ the gem (including the current stable version). Please consult the relevant git
32
+ tag (e.g. v0.0.7) if you need documentation for a specific Bamboozled version.
33
+
34
+ ## Installation
35
+
36
+ Bamboozled's installation follows the standard gem installation process:
37
+
38
+ ```sh
39
+ $ gem install bamboozled
40
+ ```
41
+
42
+ If you prefer to install Bamboozled through `bundler` then add it to your
43
+ `Gemfile`:
44
+
45
+ ```ruby
46
+ gem "bamboozled"
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ Create a `client` and provide it with your BambooHR subdomain and an API key:
52
+
53
+ ```ruby
54
+ # Create the client:
55
+ client = Bamboozled.client(subdomain: "your_subdomain", api_key: "your_api_key")
56
+ ```
57
+
58
+ > TIP! Create an API key by logging into your BambooHR account, then click your
59
+ > image in the upper right corner and select "API Keys".
60
+
61
+ ### Employee related data:
62
+
63
+ You can pass an array of fields to `all` or `:all` to get all fields your user
64
+ is allowed to access. Because BambooHR's API doesn't allow for specifying fields
65
+ on the `/employees/directory` API endpoint, passing a list of fields to retrieve
66
+ will be signifigantly slower than getting just the default fields since the gem
67
+ will get the directory of employees, then request the data for each individual
68
+ employee resulting in `employees.count + 1` API calls. To get around this,
69
+ consider using a custom report.
70
+
71
+ ```ruby
72
+ # Returns an array of all employees
73
+ client.employee.all # Gets all employees with default fields
74
+ client.employee.all(:all) # Gets all fields for all employees
75
+ client.employee.all(["hireDate", "displayName"])
76
+ client.employee.all("hireDate,displayName")
77
+
78
+ # Get the employee records which have changed since a given date
79
+ client.employee.last_changed("2015-01-01T00:00:00-08:00", :updated)
80
+ client.employee.last_changed("2015-01-01T00:00:00-08:00", :inserted)
81
+ client.employee.last_changed("2015-01-01T00:00:00-08:00", :deleted)
82
+ client.employee.last_changed("2015-01-01T00:00:00-08:00") # Return all changes
83
+
84
+ # Returns a hash of a single employee
85
+ client.employee.find(employee_id, fields = nil)
86
+
87
+ # Adds an employee
88
+ client.employee.add(employee_details_hash)
89
+
90
+ # Tabular employee data
91
+ client.employee.job_info(employee_id)
92
+ client.employee.employment_status(employee_id)
93
+ client.employee.compensation(employee_id)
94
+ client.employee.dependents(employee_id)
95
+ client.employee.contacts(employee_id)
96
+
97
+ # Time off estimate for employee. Requires end date in Date or Time format or YY-MM-DD string.
98
+ client.employee.time_off_estimate(employee_id, end_date)
99
+
100
+ # Photos for an employee
101
+ client.employee.photo_url(employee_work_email)
102
+ client.employee.photo_url(employee_id)
103
+ client.employee.photo_binary(employee_id)
104
+ ```
105
+
106
+ ### Time off data
107
+
108
+ ```ruby
109
+ # Get time off requests filtered by a number of parameters
110
+ # :id - the ID of the time off request
111
+ # :action -
112
+ # :employeeId - the ID of the employee you're looking for
113
+ # :start - filter start date
114
+ # :end - filter end date
115
+ # :type - type of time off request
116
+ # :status - must be one or more of the following: approved denied superceded requested canceled
117
+ client.time_off.requests(:employeeId: employee_id, start: Time.now)
118
+
119
+ # See who is out when.
120
+ client.time_off.whos_out(Time.now, "2014-12-31")
121
+ ```
122
+
123
+ ### Reports
124
+
125
+ ```ruby
126
+ # Get a list of employees with specified fields
127
+ # Send `:all` for `fields` to get all fields.
128
+ # Note that this can get a list of employees with additional fields via a single
129
+ # API request instead of one per employee when using the `employees` endpoint.
130
+ client.report.custom(fields, format = "JSON")
131
+ ```
132
+
133
+
134
+ ```ruby
135
+ # Find a report by its number
136
+ client.report.find(report_number, format = "JSON", fd = true)
137
+ ```
138
+
139
+ ### Metadata
140
+
141
+ ```ruby
142
+ # Get fields
143
+ client.meta.fields
144
+ # Get lists
145
+ client.meta.lists
146
+ # Get tables
147
+ client.meta.tables
148
+ # Get users
149
+ # Note: this is all uses in the system, whereas client.employee.all only gets active employees
150
+ client.meta.users
151
+ ```
152
+
153
+ ## Contributing
154
+
155
+ Thank you for contributing! We always welcome bug reports and/or pull requests.
156
+ Please take the time to go through our [contribution guidelines](CONTRIBUTING.md).
157
+
158
+ Special thanks to all the awesome people who have helped make this gem better.
159
+ You can see a list of them [here](https://github.com/Skookum/bamboozled/graphs/contributors).
160
+
161
+ ## License
162
+
163
+ This project is licensed under the terms of the MIT license. See the
164
+ [LICENSE](/LICENSE) file.
165
+
166
+ ---
167
+
168
+ <p align="center">
169
+ <img src="logos/skookum_mark_black.png" alt="Skookum" width="100" />
170
+ </p>
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ desc "Open an irb session preloaded with this library"
7
+ task :console do
8
+ sh "irb -rubygems -I lib -r bamboozled.rb"
9
+ end
10
+
11
+ task default: :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("lib", __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bamboozled/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bamboozled-gitlab"
8
+ spec.version = Bamboozled::VERSION
9
+ spec.authors = ["Mark Rickert"]
10
+ spec.email = ["mjar81@gmail.com"]
11
+ spec.summary = "A Ruby wrapper for the BambooHR API http://www.bamboohr.com/"
12
+ spec.description = "Bamboozled wraps the BambooHR API without the use of Rails dependencies."
13
+ spec.homepage = "http://github.com/Skookum/bamboozled"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = ">= 2.0"
22
+
23
+ spec.add_development_dependency "bundler", ">= 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.4"
25
+ spec.add_development_dependency "rspec", "~> 3.1"
26
+ spec.add_development_dependency "webmock", "~> 1.20"
27
+
28
+ spec.add_dependency "httparty", "~> 0.13"
29
+ spec.add_dependency "json", "~> 2.3.0"
30
+ end