payroll_hero-api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +41 -0
- data/DEPLOYING.md +25 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +15 -0
- data/lib/payroll_hero/api/base_group.rb +31 -0
- data/lib/payroll_hero/api/client.rb +97 -0
- data/lib/payroll_hero/api/configuration.rb +16 -0
- data/lib/payroll_hero/api/errors.rb +30 -0
- data/lib/payroll_hero/api/v2/worksites.rb +23 -0
- data/lib/payroll_hero/api/v3/day_schedules.rb +38 -0
- data/lib/payroll_hero/api/v3/employees.rb +22 -0
- data/lib/payroll_hero/api/v4/employees.rb +74 -0
- data/lib/payroll_hero/api/v4/leaves.rb +20 -0
- data/lib/payroll_hero/api/v4/permissions.rb +12 -0
- data/lib/payroll_hero/api/version.rb +5 -0
- data/lib/payroll_hero/api.rb +45 -0
- data/payroll_hero-api.gemspec +35 -0
- metadata +219 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f019ac0f37a1ee9d08543de72ee7468ab96eef58
|
4
|
+
data.tar.gz: a134e2daffa4162cfa8b96d95552f4b9507f2262
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7a6d73beffab078c1a7daeb4daebeca7772f8098a6ab2bf952615e33bd6508b0425b29e164b23860599f1978c3255fed343c946e82b96446caa8a312c7cd6f5
|
7
|
+
data.tar.gz: afb0ba215721e307b91cbe78f9a53abfff1cb024d2f4122986433fbafcca8a2732f44fbd1239680bd7ab271d2283a20c9985a1d725e4b15936c9921b30168e2d
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.2.1](https://github.com/payrollhero/payroll_hero-api/tree/v0.2.1) (2016-01-20)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.2.0...v0.2.1)
|
6
|
+
|
7
|
+
- Add delete leave call. [\#5](https://github.com/payrollhero/payroll_hero-api/pull/5) ([mykola-kyryk](https://github.com/mykola-kyryk))
|
8
|
+
|
9
|
+
## [v0.2.0](https://github.com/payrollhero/payroll_hero-api/tree/v0.2.0) (2015-12-29)
|
10
|
+
|
11
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.1.4...v0.2.0)
|
12
|
+
|
13
|
+
## [v0.1.4](https://github.com/payrollhero/payroll_hero-api/tree/v0.1.4) (2015-12-28)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.1.3...v0.1.4)
|
16
|
+
|
17
|
+
- Add v4/permissions [\#4](https://github.com/payrollhero/payroll_hero-api/pull/4) ([mykola-kyryk](https://github.com/mykola-kyryk))
|
18
|
+
|
19
|
+
## [v0.1.3](https://github.com/payrollhero/payroll_hero-api/tree/v0.1.3) (2015-12-17)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.1.2...v0.1.3)
|
22
|
+
|
23
|
+
- Feature/add v4 leaves resource [\#2](https://github.com/payrollhero/payroll_hero-api/pull/2) ([nicosuria](https://github.com/nicosuria))
|
24
|
+
|
25
|
+
## [v0.1.2](https://github.com/payrollhero/payroll_hero-api/tree/v0.1.2) (2015-12-17)
|
26
|
+
|
27
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.1.1...v0.1.2)
|
28
|
+
|
29
|
+
- Add pagination params to V4 Employees [\#3](https://github.com/payrollhero/payroll_hero-api/pull/3) ([mykola-kyryk](https://github.com/mykola-kyryk))
|
30
|
+
|
31
|
+
## [v0.1.1](https://github.com/payrollhero/payroll_hero-api/tree/v0.1.1) (2015-12-07)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/payrollhero/payroll_hero-api/compare/v0.1.0...v0.1.1)
|
34
|
+
|
35
|
+
- Api v4 employees resource [\#1](https://github.com/payrollhero/payroll_hero-api/pull/1) ([nicosuria](https://github.com/nicosuria))
|
36
|
+
|
37
|
+
## [v0.1.0](https://github.com/payrollhero/payroll_hero-api/tree/v0.1.0) (2015-11-27)
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/DEPLOYING.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## Setup
|
2
|
+
|
3
|
+
In order to deploy a new version of the gem into the wild ...
|
4
|
+
|
5
|
+
You will need to configure your github api token for the changelog.
|
6
|
+
|
7
|
+
Generate a new token for changelogs [here](https://github.com/settings/tokens/new).
|
8
|
+
|
9
|
+
add:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
export CHANGELOG_GITHUB_TOKEN=YOUR_CHANGELOG_API_TOKEN
|
13
|
+
```
|
14
|
+
|
15
|
+
somewhere in your shell init. (ie .zshrc or simillar)
|
16
|
+
|
17
|
+
## Deploying
|
18
|
+
|
19
|
+
1. Update `lib/ph_utility/version.rb`
|
20
|
+
2. Commit the changed files with the version number eg: `1.8.0`
|
21
|
+
3. Push this to git
|
22
|
+
4. Run `rake release`
|
23
|
+
5. Run `rake changelog` (has to be ran after release since its based on github tagging)
|
24
|
+
6. Commit the changed changelog named something like `changelog for 1.8.0`
|
25
|
+
7. Push this to git
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 PayrollHero.com Pte. Ltd.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Payrollhero::Api
|
2
|
+
|
3
|
+
[ ![Codeship Status for payrollhero/payroll_hero-api](https://codeship.com/projects/d659b9a0-76ec-0133-c19b-5e44421d15ab/status?branch=master)](https://codeship.com/projects/118323)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'payroll_hero-api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
The main use is to directly invoke the endpoint groups (roughly corresponding to path prefixes on the endpoints) and
|
20
|
+
call things on them.
|
21
|
+
|
22
|
+
At this point its very rough, there is only a couple of endpoints defined but this should serve as a good framework.
|
23
|
+
|
24
|
+
See the tests for example usages.
|
25
|
+
|
26
|
+
## Configuration
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
PayrollHero::Api.configure do |config|
|
30
|
+
config.core_base_url = "http://api.payrollhero.ph.dev"
|
31
|
+
config.debug = false # when enabled all request info is logged to stdout
|
32
|
+
config.application_name = "Test Suite"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
39
|
+
Then, run `rake test` to run the tests.
|
40
|
+
You can also run `bundle exec pry --gem` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
43
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
44
|
+
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to Gemfury.
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/payrollhero/payroll_hero-api.
|
49
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
50
|
+
and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
51
|
+
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc "Updates the changelog"
|
13
|
+
task :changelog do
|
14
|
+
sh "github_changelog_generator payrollhero/payroll_hero-api --simple-list"
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class BaseGroup
|
5
|
+
def initialize(token)
|
6
|
+
@client = new_client(token, :core)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
attr_reader :client
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def base_url_for(name)
|
15
|
+
PayrollHero::Api.send("#{name}_base_url")
|
16
|
+
end
|
17
|
+
|
18
|
+
def new_client(token, name)
|
19
|
+
Client.new(token, base_url_for(name))
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_nil_values_from!(hash)
|
23
|
+
hash.delete_if { |_, value| value.nil? }
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove_empty_values_from!(hash)
|
27
|
+
hash.delete_if { |_, value| value.nil? || value.empty? }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'retries'
|
4
|
+
|
5
|
+
module PayrollHero
|
6
|
+
module Api
|
7
|
+
|
8
|
+
class Client
|
9
|
+
attr_reader :client
|
10
|
+
|
11
|
+
def initialize(token, base_url)
|
12
|
+
headers = {
|
13
|
+
'User-Agent' => user_agent_string,
|
14
|
+
}
|
15
|
+
params = {
|
16
|
+
token: token,
|
17
|
+
}
|
18
|
+
@client = Faraday.new(url: base_url) do |faraday|
|
19
|
+
faraday.request :url_encoded
|
20
|
+
faraday.response :logger if PayrollHero::Api.debug
|
21
|
+
|
22
|
+
faraday.use FaradayMiddleware::Mashify
|
23
|
+
faraday.response :json, content_type: /\bjson$/
|
24
|
+
|
25
|
+
faraday.headers.merge! headers
|
26
|
+
faraday.params.merge! params
|
27
|
+
|
28
|
+
faraday.adapter Faraday.default_adapter
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def get(path, params = {})
|
33
|
+
do_request(:get, path, params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def post(path, params)
|
37
|
+
do_request(:post, path, params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete(path, params = {})
|
41
|
+
do_request(:delete, path, params)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def do_request(method, path, params)
|
47
|
+
response = wrap_request { client.public_send(method, path, params) }
|
48
|
+
validate_response(response)
|
49
|
+
response.body
|
50
|
+
end
|
51
|
+
|
52
|
+
def error_from(response)
|
53
|
+
klass = {
|
54
|
+
401 => Errors::Unauthorized,
|
55
|
+
422 => Errors::UnprocessableEntity,
|
56
|
+
500 => Errors::InternalServerError,
|
57
|
+
}[response.status] || Errors::ServerReturnedError
|
58
|
+
|
59
|
+
case response.body
|
60
|
+
when Hash
|
61
|
+
if response.body['error'] && response.body['error_description']
|
62
|
+
raise klass.new(response.body['error'], response.body['error_description'])
|
63
|
+
else
|
64
|
+
raise klass.new('unknown', response.body.inspect)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
raise klass.new('unknown', response.body)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def validate_response(response)
|
72
|
+
case response.status
|
73
|
+
when 400..499, 500..599
|
74
|
+
raise error_from(response)
|
75
|
+
when 200
|
76
|
+
# this is cool, just return
|
77
|
+
return
|
78
|
+
else
|
79
|
+
raise "unhandled error: #{response.status}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def user_agent_string
|
84
|
+
if PayrollHero::Api.application_name != :none
|
85
|
+
"#{PayrollHero::Api.application_name} (PayrollHero::Api #{PayrollHero::Api::VERSION})"
|
86
|
+
else
|
87
|
+
"(PayrollHero::Api #{PayrollHero::Api::VERSION})"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def wrap_request
|
92
|
+
with_retries(max_tries: 3) { yield }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Configuration
|
2
|
+
def configure
|
3
|
+
yield self
|
4
|
+
end
|
5
|
+
|
6
|
+
def define_setting(name, default = nil)
|
7
|
+
class_variable_set("@@#{name}", default)
|
8
|
+
define_singleton_method "#{name}=" do |value|
|
9
|
+
class_variable_set("@@#{name}", value)
|
10
|
+
end
|
11
|
+
define_singleton_method name do
|
12
|
+
raise("#{name} is not configured") unless class_variable_defined?("@@#{name}")
|
13
|
+
class_variable_get("@@#{name}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
|
4
|
+
module Errors
|
5
|
+
|
6
|
+
class GenericError < Exception
|
7
|
+
end
|
8
|
+
|
9
|
+
class ServerReturnedError < GenericError
|
10
|
+
def initialize(code, message)
|
11
|
+
@code = code
|
12
|
+
super("#{code}: #{message}")
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :code
|
16
|
+
end
|
17
|
+
|
18
|
+
class Unauthorized < ServerReturnedError
|
19
|
+
end
|
20
|
+
|
21
|
+
class UnprocessableEntity < ServerReturnedError
|
22
|
+
end
|
23
|
+
|
24
|
+
class InternalServerError < ServerReturnedError
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
|
5
|
+
# Worksites Endpoint
|
6
|
+
class Worksites < BaseGroup
|
7
|
+
# implements the interface to the Worksites List endpoint
|
8
|
+
#
|
9
|
+
# @param [Fixnum] page
|
10
|
+
# @param [Fixnum] per_page
|
11
|
+
# @return [Hashie::Mash]
|
12
|
+
def list(page: nil, per_page: nil)
|
13
|
+
params = {
|
14
|
+
page: page,
|
15
|
+
per_page: per_page,
|
16
|
+
}
|
17
|
+
remove_nil_values_from!(params)
|
18
|
+
client.get("/api/v2/worksites", params)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
module V3
|
4
|
+
|
5
|
+
# DaySchedules Endpoint
|
6
|
+
class DaySchedules < BaseGroup
|
7
|
+
# implements the interface to the DaySchedules List endpoint
|
8
|
+
#
|
9
|
+
# @return [Hashie::Mash]
|
10
|
+
# @param [Fixnum] page
|
11
|
+
# @param [Fixnum] per_page
|
12
|
+
# @param [Date] start_date
|
13
|
+
# @param [Date] end_date
|
14
|
+
# @param [TrueClass|FalseClass] permissions
|
15
|
+
# @param [TrueClass|FalseClass] breaks
|
16
|
+
# @param [Fixnum] worksite_id
|
17
|
+
# @param [Fixnum] excluded_worksite_id
|
18
|
+
# @param [Fixnum] employee_id
|
19
|
+
def list(page: nil, per_page: nil, start_date: nil, end_date: nil, permissions: false, breaks: false, worksite_id: nil, excluded_worksite_id: nil, employee_id: nil)
|
20
|
+
params = {
|
21
|
+
page: page,
|
22
|
+
per_page: per_page,
|
23
|
+
start_date: start_date,
|
24
|
+
end_date: end_date,
|
25
|
+
permissions: permissions,
|
26
|
+
breaks: breaks,
|
27
|
+
worksite_id: worksite_id,
|
28
|
+
excluded_worksite_id: excluded_worksite_id,
|
29
|
+
employee_id: employee_id,
|
30
|
+
}
|
31
|
+
remove_nil_values_from!(params)
|
32
|
+
client.get("/api/v3/day_schedules", params)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
module V3
|
4
|
+
|
5
|
+
# Employees Endpoint
|
6
|
+
class Employees < BaseGroup
|
7
|
+
# implements the interface to get a single Employee record
|
8
|
+
#
|
9
|
+
# @return [Hashie::Mash]
|
10
|
+
# @param [Fixnum|String] id
|
11
|
+
# @param [TrueClass|FalseClass] show_tags
|
12
|
+
def get(id, show_tags: false)
|
13
|
+
params = {
|
14
|
+
show_tags: show_tags,
|
15
|
+
}
|
16
|
+
remove_nil_values_from!(params)
|
17
|
+
client.get("/api/v3/employees/#{id}", params)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
module V4
|
4
|
+
# Employees Endpoint
|
5
|
+
class Employees < BaseGroup
|
6
|
+
# Implements the interface to get a list of accessible employees.
|
7
|
+
#
|
8
|
+
# @return [Hashie::Mash]
|
9
|
+
# @param [Array|Symbol] only - Attribute names to be included on the response
|
10
|
+
# @param [Array|Symbol] except - Attribute names to be excluded on the response
|
11
|
+
# @param [Array|Symbol] include - Association names to be included in the response
|
12
|
+
def list(only: [], except: [], include: [], page: nil, per_page: nil)
|
13
|
+
params = {
|
14
|
+
only: Array(only),
|
15
|
+
except: Array(except),
|
16
|
+
include: Array(include),
|
17
|
+
page: page,
|
18
|
+
per_page: per_page,
|
19
|
+
}
|
20
|
+
|
21
|
+
remove_empty_values_from!(params)
|
22
|
+
client.get("/api/v4/employees", params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# implements the interface to get a single Employee record
|
26
|
+
#
|
27
|
+
# @return [Hashie::Mash]
|
28
|
+
# @param [Fixnum|String] id
|
29
|
+
# @param [Array|Symbol] only - Attribute names to be included on the response
|
30
|
+
# @param [Array|Symbol] except - Attribute names to be excluded on the response
|
31
|
+
# @param [Array|Symbol] include - Association names to be included in the response
|
32
|
+
def get(id, only: nil, except: nil, include: nil)
|
33
|
+
fetch(id, only: only, except: except, include: include)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Implements the interface to get a list of the API token owner's subordinates
|
37
|
+
#
|
38
|
+
# @return [Hashie::Mash]
|
39
|
+
# @param [Fixnum|String] id
|
40
|
+
# @param [Array|Symbol] only - Attribute names to be included on the response
|
41
|
+
# @param [Array|Symbol] except - Attribute names to be excluded on the response
|
42
|
+
# @param [Array|Symbol] include - Association names to be included in the response
|
43
|
+
def subordinates(id, only: [], except: [], include: [], page: nil, per_page: nil)
|
44
|
+
fetch("#{id}/subordinates", only: only, except: except, include: include, page: page, per_page: per_page)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Implements the interface to get a list of the API token owner's superiors
|
48
|
+
#
|
49
|
+
# @return [Hashie::Mash]
|
50
|
+
# @param [Fixnum|String] id
|
51
|
+
# @param [Array|Symbol] only - Attribute names to be included on the response
|
52
|
+
# @param [Array|Symbol] except - Attribute names to be excluded on the response
|
53
|
+
# @param [Array|Symbol] include - Association names to be included in the response
|
54
|
+
def superiors(id, only: [], except: [], include: [], page: nil, per_page: nil)
|
55
|
+
fetch("#{id}/superiors", only: only, except: except, include: include, page: page, per_page: per_page)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def fetch(identifier, only:, except:, include:, page: nil, per_page: nil)
|
61
|
+
params = {
|
62
|
+
only: Array(only),
|
63
|
+
except: Array(except),
|
64
|
+
include: Array(include),
|
65
|
+
page: page,
|
66
|
+
per_page: per_page,
|
67
|
+
}
|
68
|
+
remove_empty_values_from!(params)
|
69
|
+
client.get("/api/v4/employees/#{identifier}", params)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PayrollHero
|
2
|
+
module Api
|
3
|
+
module V4
|
4
|
+
# Leaves Endpoint
|
5
|
+
class Leaves < BaseGroup
|
6
|
+
# Creates a leave record.
|
7
|
+
#
|
8
|
+
# @param [Hash] attributes - Attributes of the Leave to be created.
|
9
|
+
# @return [Hashie::Mash]
|
10
|
+
def create(attributes)
|
11
|
+
client.post("/api/v4/leaves", attributes)
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy(id)
|
15
|
+
client.delete("/api/v4/leaves/#{id}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'api/configuration'
|
2
|
+
|
3
|
+
module PayrollHero
|
4
|
+
module Api
|
5
|
+
extend Configuration
|
6
|
+
|
7
|
+
define_setting :core_base_url
|
8
|
+
define_setting :debug, false
|
9
|
+
define_setting :application_name, :none
|
10
|
+
|
11
|
+
def self.new(token)
|
12
|
+
sections = {
|
13
|
+
v2: {
|
14
|
+
worksites: V2::Worksites.new(token),
|
15
|
+
},
|
16
|
+
v3: {
|
17
|
+
day_schedules: V3::DaySchedules.new(token),
|
18
|
+
employees: V3::Employees.new(token),
|
19
|
+
},
|
20
|
+
v4: {
|
21
|
+
employees: V4::Employees.new(token),
|
22
|
+
leaves: V4::Leaves.new(token),
|
23
|
+
permissions: V4::Permissions.new(token),
|
24
|
+
}
|
25
|
+
}
|
26
|
+
Hashie::Mash.new(sections)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require_relative 'api/version'
|
32
|
+
|
33
|
+
require_relative 'api/base_group'
|
34
|
+
|
35
|
+
require_relative 'api/errors'
|
36
|
+
require_relative 'api/client'
|
37
|
+
|
38
|
+
require_relative 'api/v2/worksites'
|
39
|
+
|
40
|
+
require_relative 'api/v3/day_schedules'
|
41
|
+
require_relative 'api/v3/employees'
|
42
|
+
|
43
|
+
require_relative 'api/v4/employees'
|
44
|
+
require_relative 'api/v4/leaves'
|
45
|
+
require_relative 'api/v4/permissions'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'payroll_hero/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'payroll_hero-api'
|
8
|
+
spec.version = PayrollHero::Api::VERSION
|
9
|
+
spec.authors = ['Piotr Banasik']
|
10
|
+
spec.email = ['piotr@payrollhero.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby API Client for PayrollHero Apis}
|
13
|
+
spec.description = %q{Provides a clean canonical interface to accessing PayrollHero APIs with Ruby}
|
14
|
+
spec.homepage = "http://github.com/payrollhero/"
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'faraday'
|
23
|
+
spec.add_runtime_dependency 'faraday_middleware'
|
24
|
+
spec.add_runtime_dependency 'hashie'
|
25
|
+
spec.add_runtime_dependency 'retries'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'minitest'
|
30
|
+
spec.add_development_dependency 'minitest-reporters'
|
31
|
+
spec.add_development_dependency 'vcr'
|
32
|
+
spec.add_development_dependency 'webmock'
|
33
|
+
# Version locked as 1.10.4 has known installation issues
|
34
|
+
spec.add_development_dependency 'github_changelog_generator', '1.10.1'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: payroll_hero-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Banasik
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: retries
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest-reporters
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: github_changelog_generator
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.10.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.10.1
|
167
|
+
description: Provides a clean canonical interface to accessing PayrollHero APIs with
|
168
|
+
Ruby
|
169
|
+
email:
|
170
|
+
- piotr@payrollhero.com
|
171
|
+
executables: []
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- CHANGELOG.md
|
177
|
+
- DEPLOYING.md
|
178
|
+
- Gemfile
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.md
|
181
|
+
- Rakefile
|
182
|
+
- lib/payroll_hero/api.rb
|
183
|
+
- lib/payroll_hero/api/base_group.rb
|
184
|
+
- lib/payroll_hero/api/client.rb
|
185
|
+
- lib/payroll_hero/api/configuration.rb
|
186
|
+
- lib/payroll_hero/api/errors.rb
|
187
|
+
- lib/payroll_hero/api/v2/worksites.rb
|
188
|
+
- lib/payroll_hero/api/v3/day_schedules.rb
|
189
|
+
- lib/payroll_hero/api/v3/employees.rb
|
190
|
+
- lib/payroll_hero/api/v4/employees.rb
|
191
|
+
- lib/payroll_hero/api/v4/leaves.rb
|
192
|
+
- lib/payroll_hero/api/v4/permissions.rb
|
193
|
+
- lib/payroll_hero/api/version.rb
|
194
|
+
- payroll_hero-api.gemspec
|
195
|
+
homepage: http://github.com/payrollhero/
|
196
|
+
licenses:
|
197
|
+
- MIT
|
198
|
+
metadata: {}
|
199
|
+
post_install_message:
|
200
|
+
rdoc_options: []
|
201
|
+
require_paths:
|
202
|
+
- lib
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
requirements: []
|
214
|
+
rubyforge_project:
|
215
|
+
rubygems_version: 2.5.1
|
216
|
+
signing_key:
|
217
|
+
specification_version: 4
|
218
|
+
summary: Ruby API Client for PayrollHero Apis
|
219
|
+
test_files: []
|