taleo 0.1.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 +7 -0
- data/.github/workflows/checks.yml +71 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +16 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +8 -0
- data/bin/console +8 -0
- data/bin/setup +8 -0
- data/lib/taleo.rb +10 -0
- data/lib/taleo/activity.rb +32 -0
- data/lib/taleo/attachment.rb +31 -0
- data/lib/taleo/candidate.rb +34 -0
- data/lib/taleo/client.rb +130 -0
- data/lib/taleo/cursor.rb +59 -0
- data/lib/taleo/employee.rb +19 -0
- data/lib/taleo/packet.rb +23 -0
- data/lib/taleo/resource.rb +69 -0
- data/lib/taleo/version.rb +5 -0
- data/taleo.gemspec +40 -0
- metadata +138 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 67b1e8be41a41210631e9ce7a6e09ebea36cc5f14f8b615b9f23cbdb71e135a7
|
|
4
|
+
data.tar.gz: 96280b9e97cae91011c633cf3680b1922c7a565d890fff4f5b0b33af210a44a8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b58832c2d980c40ee41e7a921e1b7a9c6c835dd6bb2f75a55957741d57ac84780f169bb7aad9063c9a4af0b386ca8adbc9efcd61e3c154152be9642819809ee8
|
|
7
|
+
data.tar.gz: 5184a2ff23c7a6a4c9adc4ee8838d7959cbbb6913b4977922f701907f2cb9f142da3dd4b52471ee95ebd4cd019504d606be0b91158491707000966143037bff7
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Checks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
- '*'
|
|
9
|
+
paths:
|
|
10
|
+
- 'lib/**'
|
|
11
|
+
- 'Gemfile'
|
|
12
|
+
- 'Gemfile.lock'
|
|
13
|
+
- 'taleo.gemspec'
|
|
14
|
+
- 'spec/**'
|
|
15
|
+
- '.github/workflows/checks.yml'
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
name: Run automated tests
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout repository
|
|
23
|
+
uses: actions/checkout@v2
|
|
24
|
+
|
|
25
|
+
- name: Set up ruby
|
|
26
|
+
uses: actions/setup-ruby@v1
|
|
27
|
+
with:
|
|
28
|
+
ruby-version: 2.6
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
gem install bundler -v 2.1.4
|
|
33
|
+
bundle install
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: bundle exec rake
|
|
37
|
+
|
|
38
|
+
rubocop:
|
|
39
|
+
name: Rubocop
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout repository
|
|
46
|
+
uses: actions/checkout@v2
|
|
47
|
+
|
|
48
|
+
- name: Set up Ruby
|
|
49
|
+
uses: ruby/setup-ruby@v1
|
|
50
|
+
with:
|
|
51
|
+
ruby-version: 2.6
|
|
52
|
+
|
|
53
|
+
- name: Install Code Scanning integration
|
|
54
|
+
run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install
|
|
55
|
+
|
|
56
|
+
- name: Install dependencies
|
|
57
|
+
run: |
|
|
58
|
+
gem install bundler -v 2.1.4
|
|
59
|
+
bundle install
|
|
60
|
+
|
|
61
|
+
- name: Rubocop run
|
|
62
|
+
run: |
|
|
63
|
+
bash -c "
|
|
64
|
+
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
|
65
|
+
[[ $? -ne 2 ]]
|
|
66
|
+
"
|
|
67
|
+
|
|
68
|
+
- name: Upload Sarif output
|
|
69
|
+
uses: github/codeql-action/upload-sarif@v1
|
|
70
|
+
with:
|
|
71
|
+
sarif_file: rubocop.sarif
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
os: linux
|
|
3
|
+
dist: xenial
|
|
4
|
+
language: ruby
|
|
5
|
+
cache: bundler
|
|
6
|
+
rvm:
|
|
7
|
+
- 2.6.0
|
|
8
|
+
before_install: gem install bundler -v 2.1.4
|
|
9
|
+
before_script:
|
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
11
|
+
- chmod +x ./cc-test-reporter
|
|
12
|
+
- ./cc-test-reporter before-build
|
|
13
|
+
script:
|
|
14
|
+
- bundle exec rspec
|
|
15
|
+
after_script:
|
|
16
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
taleo (0.1.0)
|
|
5
|
+
faraday (~> 1.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.7.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
backports (3.18.2)
|
|
13
|
+
crack (0.4.3)
|
|
14
|
+
safe_yaml (~> 1.0.0)
|
|
15
|
+
diff-lcs (1.4.4)
|
|
16
|
+
docile (1.3.2)
|
|
17
|
+
faraday (1.0.1)
|
|
18
|
+
multipart-post (>= 1.2, < 3)
|
|
19
|
+
hashdiff (1.0.0)
|
|
20
|
+
json (2.3.1)
|
|
21
|
+
multi_json (1.15.0)
|
|
22
|
+
multipart-post (2.1.1)
|
|
23
|
+
mustermann (1.0.3)
|
|
24
|
+
public_suffix (4.0.6)
|
|
25
|
+
rack (2.2.3)
|
|
26
|
+
rack-protection (2.0.7)
|
|
27
|
+
rack
|
|
28
|
+
rake (13.0.1)
|
|
29
|
+
rspec (3.9.0)
|
|
30
|
+
rspec-core (~> 3.9.0)
|
|
31
|
+
rspec-expectations (~> 3.9.0)
|
|
32
|
+
rspec-mocks (~> 3.9.0)
|
|
33
|
+
rspec-core (3.9.3)
|
|
34
|
+
rspec-support (~> 3.9.3)
|
|
35
|
+
rspec-expectations (3.9.2)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.9.0)
|
|
38
|
+
rspec-mocks (3.9.1)
|
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
+
rspec-support (~> 3.9.0)
|
|
41
|
+
rspec-support (3.9.3)
|
|
42
|
+
safe_yaml (1.0.5)
|
|
43
|
+
simplecov (0.17.1)
|
|
44
|
+
docile (~> 1.1)
|
|
45
|
+
json (>= 1.8, < 3)
|
|
46
|
+
simplecov-html (~> 0.10.0)
|
|
47
|
+
simplecov-html (0.10.2)
|
|
48
|
+
sinatra (2.0.7)
|
|
49
|
+
mustermann (~> 1.0)
|
|
50
|
+
rack (~> 2.0)
|
|
51
|
+
rack-protection (= 2.0.7)
|
|
52
|
+
tilt (~> 2.0)
|
|
53
|
+
sinatra-contrib (2.0.7)
|
|
54
|
+
backports (>= 2.8.2)
|
|
55
|
+
multi_json
|
|
56
|
+
mustermann (~> 1.0)
|
|
57
|
+
rack-protection (= 2.0.7)
|
|
58
|
+
sinatra (= 2.0.7)
|
|
59
|
+
tilt (~> 2.0)
|
|
60
|
+
tilt (2.0.10)
|
|
61
|
+
webmock (3.6.0)
|
|
62
|
+
addressable (>= 2.3.6)
|
|
63
|
+
crack (>= 0.3.2)
|
|
64
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
65
|
+
yard (0.9.25)
|
|
66
|
+
|
|
67
|
+
PLATFORMS
|
|
68
|
+
ruby
|
|
69
|
+
|
|
70
|
+
DEPENDENCIES
|
|
71
|
+
rake (>= 12.3.3)
|
|
72
|
+
rspec (~> 3.0)
|
|
73
|
+
simplecov (~> 0.17.1)
|
|
74
|
+
sinatra (~> 2.0)
|
|
75
|
+
sinatra-contrib
|
|
76
|
+
taleo!
|
|
77
|
+
webmock (~> 3.6)
|
|
78
|
+
yard
|
|
79
|
+
|
|
80
|
+
BUNDLED WITH
|
|
81
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Paul Holden
|
|
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,37 @@
|
|
|
1
|
+
# Taleo
|
|
2
|
+
|
|
3
|
+
[](https://codeclimate.com/github/paulholden2/taleo/maintainability) [](https://codeclimate.com/github/paulholden2/taleo/test_coverage)
|
|
4
|
+
|
|
5
|
+
A library for using the Taleo REST API.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'taleo'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install taleo
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Check back later.
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/paulholden2/taleo.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
34
|
+
|
|
35
|
+
## Code of Conduct
|
|
36
|
+
|
|
37
|
+
Be cool.
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/taleo.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/resource'
|
|
4
|
+
|
|
5
|
+
module Taleo
|
|
6
|
+
# Stub for Employee resource class
|
|
7
|
+
class Employee < Resource; end
|
|
8
|
+
|
|
9
|
+
class Activity < Resource
|
|
10
|
+
def id
|
|
11
|
+
data.fetch('id')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def employee_id
|
|
15
|
+
data.fetch('activityEmployee')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def can_download?
|
|
19
|
+
relationship_urls.key?('formDownloadUrl')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def download
|
|
23
|
+
unless can_download?
|
|
24
|
+
raise Error.new("Activity #{id} is not available for download")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
client.download(relationship_urls.fetch('formDownloadUrl'))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
has_one :employee, Employee, through: 'activityEmployee'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/resource'
|
|
4
|
+
|
|
5
|
+
module Taleo
|
|
6
|
+
class Attachment < Resource
|
|
7
|
+
def id
|
|
8
|
+
data.fetch('id')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def type
|
|
12
|
+
data.fetch('attachmentType')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def content_type
|
|
16
|
+
data.fetch('contentType')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def can_download?
|
|
20
|
+
data.key?('downloadUrl')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def download
|
|
24
|
+
unless can_download?
|
|
25
|
+
raise Error.new("Attachment #{id} is not available for download")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
client.download(data.fetch('downloadUrl'))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/resource'
|
|
4
|
+
require 'taleo/attachment'
|
|
5
|
+
|
|
6
|
+
module Taleo
|
|
7
|
+
# Stub Employee class
|
|
8
|
+
class Employee < Resource; end
|
|
9
|
+
|
|
10
|
+
class Candidate < Resource
|
|
11
|
+
def id
|
|
12
|
+
data.fetch('candId')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def employee_id
|
|
16
|
+
data.fetch('employee')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def has_resume?
|
|
20
|
+
relationship_urls.key?('resume')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def resume
|
|
24
|
+
unless has_resume?
|
|
25
|
+
raise Error.new("Candidate #{id} has no resume available for download")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
client.download(relationship_urls.fetch('resume'))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
has_one :employee, Employee
|
|
32
|
+
has_many :attachments, Attachment, singular: 'attachment'
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/taleo/client.rb
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/cursor'
|
|
4
|
+
require 'taleo/activity'
|
|
5
|
+
require 'taleo/packet'
|
|
6
|
+
require 'taleo/candidate'
|
|
7
|
+
require 'taleo/employee'
|
|
8
|
+
|
|
9
|
+
module Taleo
|
|
10
|
+
# Base object for executing queries and wrapping HTTP requests.
|
|
11
|
+
class Client
|
|
12
|
+
attr_reader :org_code, :username, :password, :service_url
|
|
13
|
+
|
|
14
|
+
def initialize(org_code, username, password, service_url)
|
|
15
|
+
@org_code = org_code
|
|
16
|
+
@username = username
|
|
17
|
+
@password = password
|
|
18
|
+
@service_url = service_url
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def employee(id)
|
|
22
|
+
Employee.new(show('employee', id), self)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def packet(id)
|
|
26
|
+
Packet.new(show('packet', id), self)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def candidate(id)
|
|
30
|
+
Candidate.new(show('candidate', id), self)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def activity(id)
|
|
34
|
+
Activity.new(show('activity', id), self)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def employees
|
|
38
|
+
cursor('employee', Employee)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def cursor(resource, klass, start = 1, limit = 10)
|
|
42
|
+
res = connection.get do |req|
|
|
43
|
+
req.url "object/#{resource}/search"
|
|
44
|
+
req.params.merge!({
|
|
45
|
+
'start' => start,
|
|
46
|
+
'limit' => limit
|
|
47
|
+
})
|
|
48
|
+
end
|
|
49
|
+
data = JSON.parse(res.body)
|
|
50
|
+
pagination = data.dig('response', 'pagination')
|
|
51
|
+
results = data.dig('response', 'searchResults')
|
|
52
|
+
Cursor.new(pagination, results, resource, klass, self)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def show(resource, id)
|
|
56
|
+
res = connection.get do |req|
|
|
57
|
+
req.url "object/#{resource}/#{id}"
|
|
58
|
+
end
|
|
59
|
+
data = JSON.parse(res.body)
|
|
60
|
+
data.dig('response', resource)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def login
|
|
64
|
+
params = {
|
|
65
|
+
orgCode: org_code,
|
|
66
|
+
userName: username,
|
|
67
|
+
password: password
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
conn = Faraday.new(url: api_url) do |c|
|
|
71
|
+
c.use Faraday::Response::RaiseError
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
res = conn.post do |req|
|
|
75
|
+
req.url 'login'
|
|
76
|
+
req.params.merge!(params)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
data = JSON.parse(res.body)
|
|
80
|
+
@auth_token = data.dig('response', 'authToken')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def logout
|
|
84
|
+
connection.post do |req|
|
|
85
|
+
req.url 'logout'
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def api_url
|
|
90
|
+
return @api_url if !@api_url.nil?
|
|
91
|
+
|
|
92
|
+
api_url!
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def connection
|
|
96
|
+
Faraday.new(url: api_url) do |conn|
|
|
97
|
+
conn.use Faraday::Response::RaiseError
|
|
98
|
+
conn.headers['Cookie'] = "authToken=#{auth_token}"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def download(url)
|
|
103
|
+
io = StringIO.new
|
|
104
|
+
connection.get do |req|
|
|
105
|
+
req.url url
|
|
106
|
+
req.options.on_data = Proc.new do |chunk|
|
|
107
|
+
io << chunk
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
io.rewind
|
|
111
|
+
io
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def api_url!
|
|
115
|
+
conn = Faraday.new(url: "#{service_url}/#{org_code}") do |c|
|
|
116
|
+
c.use Faraday::Response::RaiseError
|
|
117
|
+
end
|
|
118
|
+
res = conn.get
|
|
119
|
+
data = JSON.parse(res.body)
|
|
120
|
+
@api_url = data.dig('response', 'URL')
|
|
121
|
+
@api_url
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private
|
|
125
|
+
|
|
126
|
+
def auth_token
|
|
127
|
+
@auth_token
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
data/lib/taleo/cursor.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Taleo
|
|
4
|
+
# Pages through results of a search query
|
|
5
|
+
class Cursor
|
|
6
|
+
attr_reader :pagination, :results, :resource, :klass, :client
|
|
7
|
+
|
|
8
|
+
def initialize(pagination, results, resource, klass, client)
|
|
9
|
+
@pagination = pagination
|
|
10
|
+
@results = results
|
|
11
|
+
@resource = resource
|
|
12
|
+
@klass = klass
|
|
13
|
+
@client = client
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def items
|
|
17
|
+
results.map do |i|
|
|
18
|
+
klass.new(i.fetch(resource), client)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def has_next?
|
|
23
|
+
pagination.key?('next')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def has_previous?
|
|
27
|
+
pagination.key?('previous')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def next_page
|
|
31
|
+
raise Taleo::Error.new('No further results') unless has_next?
|
|
32
|
+
|
|
33
|
+
res = client.connection.get do |req|
|
|
34
|
+
req.url pagination.fetch('next')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
new_cursor(res)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def previous_page
|
|
41
|
+
raise Taleo::Error.new('No prior results') unless has_previous?
|
|
42
|
+
|
|
43
|
+
res = client.connection.get do |req|
|
|
44
|
+
req.url pagination.fetch('previous')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
new_cursor(res)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def new_cursor(res)
|
|
53
|
+
data = JSON.parse(res.body)
|
|
54
|
+
pagination = data.dig('response', 'pagination')
|
|
55
|
+
results = data.dig('response', 'searchResults')
|
|
56
|
+
Cursor.new(pagination, results, client)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/resource'
|
|
4
|
+
require 'taleo/candidate'
|
|
5
|
+
require 'taleo/packet'
|
|
6
|
+
|
|
7
|
+
module Taleo
|
|
8
|
+
# Stub for Packet resource class
|
|
9
|
+
class Packet < Resource; end
|
|
10
|
+
|
|
11
|
+
class Employee < Resource
|
|
12
|
+
def id
|
|
13
|
+
data.fetch('employeeId')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
has_one :candidate, Candidate
|
|
17
|
+
has_many :packets, Packet, singular: 'packet', plural: 'activityPackets'
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/taleo/packet.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'taleo/resource'
|
|
4
|
+
require 'taleo/activity'
|
|
5
|
+
|
|
6
|
+
module Taleo
|
|
7
|
+
# Stub for Employee resource class
|
|
8
|
+
class Employee < Resource; end
|
|
9
|
+
|
|
10
|
+
# A collection of activities to complete for onboarding.
|
|
11
|
+
class Packet < Resource
|
|
12
|
+
def id
|
|
13
|
+
data.fetch('activityPacketId')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def employee_id
|
|
17
|
+
data.fetch('employeeId')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
has_one :employee, Employee, through: 'employeeId'
|
|
21
|
+
has_many :activities, Activity, singular: 'activity'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Taleo
|
|
4
|
+
class Resource
|
|
5
|
+
attr_reader :data, :client
|
|
6
|
+
|
|
7
|
+
def initialize(data, client)
|
|
8
|
+
@data = data
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Define a has-one relationship with another resource
|
|
13
|
+
def self.has_one(name, type, through: name, identifier: name)
|
|
14
|
+
define_method(:"has_#{name}?") do
|
|
15
|
+
relationship_urls.key?(through.to_s)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
define_method(name) do
|
|
19
|
+
related_resource(name.to_s, through, identifier, type)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Define a has-many relationship with another resource
|
|
24
|
+
def self.has_many(name, type, through: name, singular: name, plural: name)
|
|
25
|
+
define_method(:"has_#{name}?") do
|
|
26
|
+
relationship_urls.key?(through.to_s)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
define_method(name) do
|
|
30
|
+
related_resources(name.to_s, type, through, singular, plural)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Retrieve a related resource's data
|
|
35
|
+
def related_resource(name, through, identifier, type)
|
|
36
|
+
unless self.send(:"has_#{name}?")
|
|
37
|
+
raise Taleo::Error.new("No such relationship: #{name}")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
res = client.connection.get do |req|
|
|
41
|
+
req.url relationship_urls.fetch(through.to_s)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
data = JSON.parse(res.body)
|
|
45
|
+
type.new(data.dig('response', identifier.to_s), client)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Retrieve a set of related resources' data
|
|
49
|
+
def related_resources(name, type, through, singular, plural)
|
|
50
|
+
unless self.send(:"has_#{name}?")
|
|
51
|
+
raise Taleo::Error.new("No such relationship: #{name}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
res = client.connection.get do |req|
|
|
55
|
+
req.url relationship_urls.fetch(through.to_s)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
data = JSON.parse(res.body)
|
|
59
|
+
data.dig('response', plural.to_s).map do |item|
|
|
60
|
+
type.new(item.fetch(singular.to_s), client)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Get URLs for related resources
|
|
65
|
+
def relationship_urls
|
|
66
|
+
data.fetch('relationshipUrls')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/taleo.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/taleo/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'taleo'
|
|
7
|
+
spec.version = Taleo::VERSION
|
|
8
|
+
spec.authors = ['Paul Holden']
|
|
9
|
+
spec.email = ['paul@codelunker.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'A library for using the Taleo REST API'
|
|
12
|
+
spec.description = 'A library for using the Taleo REST API'
|
|
13
|
+
spec.homepage = 'https://github.com/paulholden2/taleo'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
|
16
|
+
|
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
18
|
+
|
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/paulholden2/taleo'
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
|
24
|
+
# into git.
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = 'exe'
|
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ['lib']
|
|
33
|
+
|
|
34
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
|
35
|
+
|
|
36
|
+
spec.add_development_dependency 'sinatra', '~> 2.0'
|
|
37
|
+
spec.add_development_dependency 'sinatra-contrib'
|
|
38
|
+
spec.add_development_dependency 'webmock', '~> 3.6'
|
|
39
|
+
spec.add_development_dependency 'yard'
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: taleo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Paul Holden
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-10-21 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: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: sinatra
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: sinatra-contrib
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: webmock
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.6'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.6'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: yard
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: A library for using the Taleo REST API
|
|
84
|
+
email:
|
|
85
|
+
- paul@codelunker.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".github/workflows/checks.yml"
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".rspec"
|
|
93
|
+
- ".travis.yml"
|
|
94
|
+
- Gemfile
|
|
95
|
+
- Gemfile.lock
|
|
96
|
+
- LICENSE.txt
|
|
97
|
+
- README.md
|
|
98
|
+
- Rakefile
|
|
99
|
+
- bin/console
|
|
100
|
+
- bin/setup
|
|
101
|
+
- lib/taleo.rb
|
|
102
|
+
- lib/taleo/activity.rb
|
|
103
|
+
- lib/taleo/attachment.rb
|
|
104
|
+
- lib/taleo/candidate.rb
|
|
105
|
+
- lib/taleo/client.rb
|
|
106
|
+
- lib/taleo/cursor.rb
|
|
107
|
+
- lib/taleo/employee.rb
|
|
108
|
+
- lib/taleo/packet.rb
|
|
109
|
+
- lib/taleo/resource.rb
|
|
110
|
+
- lib/taleo/version.rb
|
|
111
|
+
- taleo.gemspec
|
|
112
|
+
homepage: https://github.com/paulholden2/taleo
|
|
113
|
+
licenses:
|
|
114
|
+
- MIT
|
|
115
|
+
metadata:
|
|
116
|
+
allowed_push_host: https://rubygems.org
|
|
117
|
+
homepage_uri: https://github.com/paulholden2/taleo
|
|
118
|
+
source_code_uri: https://github.com/paulholden2/taleo
|
|
119
|
+
post_install_message:
|
|
120
|
+
rdoc_options: []
|
|
121
|
+
require_paths:
|
|
122
|
+
- lib
|
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: 2.3.0
|
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
requirements: []
|
|
134
|
+
rubygems_version: 3.0.8
|
|
135
|
+
signing_key:
|
|
136
|
+
specification_version: 4
|
|
137
|
+
summary: A library for using the Taleo REST API
|
|
138
|
+
test_files: []
|