keypay_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +13 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/keypay_api.gemspec +35 -0
- data/lib/keypay_api.rb +15 -0
- data/lib/keypay_api/client.rb +24 -0
- data/lib/keypay_api/client/business.rb +12 -0
- data/lib/keypay_api/client/connection.rb +45 -0
- data/lib/keypay_api/client/employee.rb +62 -0
- data/lib/keypay_api/resource.rb +25 -0
- data/lib/keypay_api/resource_collection.rb +27 -0
- data/lib/keypay_api/version.rb +5 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ae27176b2300faa27427e573494b72a188ad3864f3edd54cdcceff911f0e9f88
|
4
|
+
data.tar.gz: 3f4469b387e83f476e855af79643d4e7d1b24a45b2a88a934ecf86286bc15fa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c6088c51555b83f76ec05eaa1ca1720b6f1a88aed33550fa926587189a5347f4c02f019be792646ecdde655ae43697cb62501f2888fb0bebedde6ef579e94307
|
7
|
+
data.tar.gz: 104ff9e1bcf3f1b25eba027de365aaec9c52dc90713fb056c4102c3d54352684c16e77434ee25ae9be118d609047f566cb6f1ba59ea5187dce3e6dca83549654
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at matt@didcoe.id.au. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
keypay_api (0.1.0)
|
5
|
+
activesupport
|
6
|
+
httparty
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.1.3.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
ast (2.4.1)
|
18
|
+
concurrent-ruby (1.1.8)
|
19
|
+
httparty (0.18.1)
|
20
|
+
mime-types (~> 3.0)
|
21
|
+
multi_xml (>= 0.5.2)
|
22
|
+
i18n (1.8.9)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
mime-types (3.3.1)
|
25
|
+
mime-types-data (~> 3.2015)
|
26
|
+
mime-types-data (3.2020.1104)
|
27
|
+
minitest (5.14.4)
|
28
|
+
multi_xml (0.6.0)
|
29
|
+
parallel (1.20.1)
|
30
|
+
parser (3.0.0.0)
|
31
|
+
ast (~> 2.4.1)
|
32
|
+
rainbow (3.0.0)
|
33
|
+
rake (13.0.3)
|
34
|
+
regexp_parser (2.1.1)
|
35
|
+
rexml (3.2.4)
|
36
|
+
rubocop (1.8.0)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 3.0.0.0)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8, < 3.0)
|
41
|
+
rexml
|
42
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
45
|
+
rubocop-ast (1.3.0)
|
46
|
+
parser (>= 2.7.1.5)
|
47
|
+
ruby-progressbar (1.10.1)
|
48
|
+
tzinfo (2.0.4)
|
49
|
+
concurrent-ruby (~> 1.0)
|
50
|
+
unicode-display_width (1.7.0)
|
51
|
+
zeitwerk (2.4.2)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
x86_64-linux
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
bundler
|
58
|
+
keypay_api!
|
59
|
+
rake (~> 13.0)
|
60
|
+
rubocop (~> 1.7)
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
2.2.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Matt Didcoe
|
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,68 @@
|
|
1
|
+
# KeyPay API
|
2
|
+
|
3
|
+
This is a Ruby gem client for accessing the [KeyPay](https://www.keypay.com.au) API, specifically developed for use in the Australian version of the API.
|
4
|
+
|
5
|
+
Documentation for the KeyPay API can be found at https://api.keypay.com.au/australia/reference
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'keypay_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install keypay_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
First, initialise a client using your API key
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
client = KeyPayAPI::Client.new("KEYPAY_API_TOKEN")
|
29
|
+
```
|
30
|
+
|
31
|
+
or, you can set an environment variable `ENV['KEYPAY_API_TOKEN']`, in whih case initialise as follows
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
client = KeyPayAPI::Client.new
|
35
|
+
```
|
36
|
+
|
37
|
+
Then call the relevant method
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
client.list_businesses
|
41
|
+
```
|
42
|
+
|
43
|
+
### List of available methods
|
44
|
+
```ruby
|
45
|
+
client.list_businesses
|
46
|
+
client.list_employees
|
47
|
+
client.show_employee(businessId, employeeId)
|
48
|
+
client.create_employee(businessId, options)
|
49
|
+
client.onboard_employee(businessId, options)
|
50
|
+
```
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mattman/keypay_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mattman/keypay_api/blob/master/CODE_OF_CONDUCT.md).
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the KeypayApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mattman/keypay_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "keypay_api"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/keypay_api.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/keypay_api/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "keypay_api"
|
7
|
+
spec.version = KeyPayAPI::VERSION
|
8
|
+
spec.authors = ["Matt Didcoe"]
|
9
|
+
spec.email = ["matt@mattdidcoe.com"]
|
10
|
+
|
11
|
+
spec.summary = "Client for the KeyPay (YourPayroll) API"
|
12
|
+
spec.homepage = "https://github.com/mattman/keypay_api"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/mattman/keypay_api"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
# Uncomment to register a new dependency of your gem
|
29
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
30
|
+
spec.add_dependency "httparty"
|
31
|
+
spec.add_dependency "activesupport"
|
32
|
+
# For more information and examples about making a new gem, checkout our
|
33
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
34
|
+
spec.add_development_dependency "bundler"
|
35
|
+
end
|
data/lib/keypay_api.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/hash'
|
4
|
+
require 'httparty'
|
5
|
+
|
6
|
+
require_relative "keypay_api/version"
|
7
|
+
require_relative "keypay_api/resource"
|
8
|
+
require_relative "keypay_api/resource_collection"
|
9
|
+
require_relative "keypay_api/client"
|
10
|
+
|
11
|
+
# Access to the Australian KeyPay API
|
12
|
+
# @version 2.0
|
13
|
+
module KeyPayAPI
|
14
|
+
class Error < StandardError; end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'client/connection'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
require_relative 'client/business'
|
5
|
+
require_relative 'client/employee'
|
6
|
+
|
7
|
+
module KeyPayAPI
|
8
|
+
class Client
|
9
|
+
include HTTParty
|
10
|
+
include KeyPayAPI::Client::Connection
|
11
|
+
include KeyPayAPI::Client::Employee
|
12
|
+
include KeyPayAPI::Client::Business
|
13
|
+
|
14
|
+
base_uri 'https://api.yourpayroll.com.au/api/v2'
|
15
|
+
format :json
|
16
|
+
|
17
|
+
def initialize(api_key = nil)
|
18
|
+
api_key ||= ENV["KEYPAY_API_KEY"]
|
19
|
+
raise KeyPayAPI::Error('Must pass an API key') if api_key.nil?
|
20
|
+
enc_key = Base64.encode64(api_key + ':').gsub(/\n/,'')
|
21
|
+
self.class.default_options.merge!(headers: {'Authorization': "Basic #{enc_key}", 'Content-Type': 'application/json'})
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module KeyPayAPI
|
2
|
+
class Client
|
3
|
+
module Business
|
4
|
+
# List businesses attached to current KeyPay account
|
5
|
+
#
|
6
|
+
# @return [ResourceCollection, Resource] either single resource object if one business, else collection
|
7
|
+
def list_businesses
|
8
|
+
get("/business")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module KeyPayAPI
|
2
|
+
class Client
|
3
|
+
module Connection
|
4
|
+
|
5
|
+
def get(path, options = {})
|
6
|
+
request :get, path, options
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(path, options = {})
|
10
|
+
request :post, path, options
|
11
|
+
end
|
12
|
+
|
13
|
+
def put(path, options = {})
|
14
|
+
request :put, path, options
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete(path, options = {})
|
18
|
+
request :delete, path, options
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def request(http_method, path, options)
|
24
|
+
response = self.class.send(http_method, path, { body: options })
|
25
|
+
raise KeyPayAPI::Error.new response.message if !response.success?
|
26
|
+
data = response.parsed_response
|
27
|
+
parse_data(data)
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_data(original_data)
|
31
|
+
return unless original_data
|
32
|
+
|
33
|
+
data = original_data.length == 1 ? original_data.first : original_data
|
34
|
+
|
35
|
+
case data
|
36
|
+
when Hash then Resource.new(self, data)
|
37
|
+
when Array then ResourceCollection.new(self, data)
|
38
|
+
when nil then nil
|
39
|
+
else data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module KeyPayAPI
|
2
|
+
class Client
|
3
|
+
module Employee
|
4
|
+
# List employees attached to business
|
5
|
+
#
|
6
|
+
# @param businessId [String] the KeyPay business ID
|
7
|
+
# @return [ResourceCollection] list of employees
|
8
|
+
def list_employees(businessId)
|
9
|
+
get("/business/#{businessId}/employee/unstructured")
|
10
|
+
end
|
11
|
+
|
12
|
+
# Get a specific employee using their KeyPay employee ID
|
13
|
+
#
|
14
|
+
# @param businessId [String] the KeyPay business ID employee is working for
|
15
|
+
# @param employeeId [String] the KeyPay employee ID you want to return
|
16
|
+
# @return [Resource] a Resource object with the employee data
|
17
|
+
def get_employee(businessId, employeeId)
|
18
|
+
get("/business/#{businessId}/employee/unstructured/#{employeeId}")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a specific employee using their external ID
|
22
|
+
#
|
23
|
+
# @param businessId [String] the KeyPay business ID employee is working for
|
24
|
+
# @param externalId [String] the external ID of the employee you want to return
|
25
|
+
# @return [Resource] a Resource object with the employee data
|
26
|
+
def get_employee_external_id(businessId, externalId)
|
27
|
+
get("/business/#{businessId}/employee/unstructured/externalid/#{externalId}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create a new employee in KeyPay
|
31
|
+
#
|
32
|
+
# @param businessId [String] the business you want to employ them under's KeyPay id
|
33
|
+
# @param options [Hash] a hash of all relevant fields to create the employee (as per the KeyPay API docs), minimum list below to create an "Incomplete" employee
|
34
|
+
# @option options [String] :taxFileNumber An Australian Tax File Number, can be '000000000' if you don't have it
|
35
|
+
# @option options [String] :firstName The employee's first name
|
36
|
+
# @option options [String] :surname The employee's surname / family name
|
37
|
+
# @option options [String] :startDate Start date for the employment
|
38
|
+
# @option options [String] :employmentType The employee's employment type, e.g. 'Casual'
|
39
|
+
def create_employee(businessId, options)
|
40
|
+
post("/business/#{businessId}/employee/unstructured", options.to_json)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Onboard an employee using the Onboard self service tool
|
44
|
+
#
|
45
|
+
# @param base Keypay::Base
|
46
|
+
# @param businessId [String] the KeyPay business ID to employ under
|
47
|
+
# @param options [Hash] Attributes to use for onboarding, must be in key/value pairs per KeyPay API Docs
|
48
|
+
# @option options [String] :email The email address the employee has on file (or will update record if id supplied)
|
49
|
+
# @option options [Boolean] :emergencyContactDetailsRequired
|
50
|
+
# @option options [String] :firstName The employee's first name
|
51
|
+
# @option options [String] :id The employee's existing KeyPay employeeId if already in system and just wanting to trigger onboard, otherwise ''
|
52
|
+
# @option options [String] :mobile The employee's mobile phone number
|
53
|
+
# @option options [Boolean] :qualificationsRequired
|
54
|
+
# @option options [String] :surname The employee's surname / family name
|
55
|
+
#
|
56
|
+
# @return [nil] the API currently returns nothing if the employee is onboarded successfully
|
57
|
+
def onboard_employee(businessId, options)
|
58
|
+
post("/business/#{businessId}/employeeonboarding/initiateselfservice", options.to_json)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KeyPayAPI
|
2
|
+
class Resource
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def initialize(client, data)
|
6
|
+
data = {} unless data.is_a?(Hash)
|
7
|
+
|
8
|
+
@client = client
|
9
|
+
|
10
|
+
data = data.with_indifferent_access
|
11
|
+
|
12
|
+
@data = OpenStruct.new(data.with_indifferent_access)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(method_sym, *arguments, &block)
|
17
|
+
if @data.respond_to?(method_sym)
|
18
|
+
@data.send(method_sym)
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module KeyPayAPI
|
2
|
+
class ResourceCollection < Resource
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(client, data, options = {})
|
8
|
+
@client = client
|
9
|
+
|
10
|
+
collection = Array(data).map do |item|
|
11
|
+
Resource.new(client, item)
|
12
|
+
end
|
13
|
+
|
14
|
+
@data = OpenStruct.new(collection: collection)
|
15
|
+
@options = options.with_indifferent_access
|
16
|
+
end
|
17
|
+
|
18
|
+
def each
|
19
|
+
return enum_for(:each) unless block_given?
|
20
|
+
|
21
|
+
collection.each { |item| yield item }
|
22
|
+
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: keypay_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Didcoe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
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: activesupport
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- matt@mattdidcoe.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- keypay_api.gemspec
|
73
|
+
- lib/keypay_api.rb
|
74
|
+
- lib/keypay_api/client.rb
|
75
|
+
- lib/keypay_api/client/business.rb
|
76
|
+
- lib/keypay_api/client/connection.rb
|
77
|
+
- lib/keypay_api/client/employee.rb
|
78
|
+
- lib/keypay_api/resource.rb
|
79
|
+
- lib/keypay_api/resource_collection.rb
|
80
|
+
- lib/keypay_api/version.rb
|
81
|
+
homepage: https://github.com/mattman/keypay_api
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
homepage_uri: https://github.com/mattman/keypay_api
|
86
|
+
source_code_uri: https://github.com/mattman/keypay_api
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.4.0
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.2.5
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Client for the KeyPay (YourPayroll) API
|
106
|
+
test_files: []
|