teamtailor 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -27
- data/.rubocop.yml +129 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +8 -6
- data/Gemfile.lock +22 -12
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/teamtailor.rb +3 -3
- data/lib/teamtailor/client.rb +91 -59
- data/lib/teamtailor/error.rb +8 -1
- data/lib/teamtailor/page_result.rb +7 -7
- data/lib/teamtailor/parser.rb +35 -35
- data/lib/teamtailor/parser/candidate.rb +2 -2
- data/lib/teamtailor/parser/company.rb +2 -2
- data/lib/teamtailor/parser/custom_field.rb +1 -1
- data/lib/teamtailor/parser/custom_field_value.rb +1 -1
- data/lib/teamtailor/parser/department.rb +1 -1
- data/lib/teamtailor/parser/job.rb +2 -2
- data/lib/teamtailor/parser/job_application.rb +1 -1
- data/lib/teamtailor/parser/location.rb +1 -1
- data/lib/teamtailor/parser/partner_result.rb +2 -2
- data/lib/teamtailor/parser/referral.rb +1 -1
- data/lib/teamtailor/parser/reject_reason.rb +1 -1
- data/lib/teamtailor/parser/requisition.rb +1 -1
- data/lib/teamtailor/parser/requisition_step_verdict.rb +1 -1
- data/lib/teamtailor/parser/stage.rb +1 -1
- data/lib/teamtailor/parser/user.rb +1 -1
- data/lib/teamtailor/record.rb +9 -9
- data/lib/teamtailor/relationship.rb +6 -6
- data/lib/teamtailor/request.rb +15 -10
- data/lib/teamtailor/version.rb +1 -1
- data/teamtailor.gemspec +16 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16e2ef81d1b5db75ba273ea7d0b38d689488c57f6da278dc12eda7052136bbd0
|
4
|
+
data.tar.gz: f7e0304fcc2951427ba15037bc1d6345f0afa665976537821efba7ccbbb0ded2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8edcd6a598a1bf8298b0f47778a571652f3abb113c4952435a2f156f65650a10cf0385ac2bf5448c45dce7a5b1ab3acaddae10c287cad6a130fa2441e1421122
|
7
|
+
data.tar.gz: 9b845638fef4753da98486f892ee4e35aa2eb9a37a34cf2ff63b5c571bd59f9299c6c6a322ec6d194ecd7c4223cd7969f26a9fa2f4b262047c0cbd790ea191f0
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,33 +1,27 @@
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
2
|
-
# They are provided by a third-party and are governed by
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
1
|
name: Ruby
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ main ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ main ]
|
15
|
-
|
2
|
+
on: [push, pull_request]
|
16
3
|
jobs:
|
17
4
|
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: true
|
7
|
+
matrix:
|
8
|
+
os: [ubuntu-latest]
|
9
|
+
ruby: [2.6, 2.7]
|
10
|
+
runs-on: ${{ matrix.os }}
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
16
|
+
bundler-cache: true
|
17
|
+
- run: bundle exec rake
|
18
18
|
|
19
|
+
lint:
|
19
20
|
runs-on: ubuntu-latest
|
20
|
-
|
21
21
|
steps:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
with:
|
29
|
-
ruby-version: 2.6
|
30
|
-
- name: Install dependencies
|
31
|
-
run: bundle install
|
32
|
-
- name: Run tests
|
33
|
-
run: bundle exec rake
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: 2.7
|
26
|
+
bundler-cache: true
|
27
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.7
|
7
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
8
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
9
|
+
DisabledByDefault: true
|
10
|
+
|
11
|
+
# Prefer &&/|| over and/or.
|
12
|
+
Style/AndOr:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
# Align `when` with `case`.
|
16
|
+
Layout/CaseIndentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
# Align comments with method definitions.
|
20
|
+
Layout/CommentIndentation:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
# No extra empty lines.
|
24
|
+
Layout/EmptyLines:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
# In a regular class definition, no empty lines around the body.
|
28
|
+
Layout/EmptyLinesAroundClassBody:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
# In a regular method definition, no empty lines around the body.
|
32
|
+
Layout/EmptyLinesAroundMethodBody:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
# In a regular module definition, no empty lines around the body.
|
36
|
+
Layout/EmptyLinesAroundModuleBody:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
40
|
+
Style/HashSyntax:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
44
|
+
# extra level of indentation.
|
45
|
+
Layout/IndentationConsistency:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Two spaces, no tabs (for indentation).
|
49
|
+
Layout/IndentationWidth:
|
50
|
+
Enabled: true
|
51
|
+
|
52
|
+
Layout/SpaceAfterColon:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
Layout/SpaceAfterComma:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Layout/SpaceAroundKeyword:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Layout/EmptyLinesAroundBlockBody:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Layout/SpaceAroundOperators:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Layout/SpaceBeforeFirstArg:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
# Defining a method with parameters needs parentheses.
|
74
|
+
Style/MethodDefParentheses:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
# Use `foo {}` not `foo{}`.
|
78
|
+
Layout/SpaceBeforeBlockBraces:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
# Use `foo { bar }` not `foo {bar}`.
|
82
|
+
Layout/SpaceInsideBlockBraces:
|
83
|
+
Enabled: true
|
84
|
+
|
85
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
86
|
+
Layout/SpaceInsideHashLiteralBraces:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
Layout/SpaceInsideParens:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
# Check quotes usage according to lint rule below.
|
93
|
+
Style/StringLiterals:
|
94
|
+
Enabled: true
|
95
|
+
EnforcedStyle: double_quotes
|
96
|
+
|
97
|
+
# Detect hard tabs, no hard tabs.
|
98
|
+
Layout/IndentationStyle:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
# Blank lines should not have any spaces.
|
102
|
+
Layout/TrailingEmptyLines:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
# No trailing whitespace.
|
106
|
+
Layout/TrailingWhitespace:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
# Use quotes for string literals when they are enough.
|
110
|
+
Style/RedundantPercentQ:
|
111
|
+
Enabled: true
|
112
|
+
|
113
|
+
# Align `end` with the matching keyword or starting expression except for
|
114
|
+
# assignments, where it should be aligned with the LHS.
|
115
|
+
Layout/EndAlignment:
|
116
|
+
Enabled: true
|
117
|
+
EnforcedStyleAlignWith: variable
|
118
|
+
|
119
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
120
|
+
Lint/RequireParentheses:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
Style/TrailingCommaInArrayLiteral:
|
124
|
+
Enabled: true
|
125
|
+
EnforcedStyleForMultiline: consistent_comma
|
126
|
+
|
127
|
+
Style/TrailingCommaInHashLiteral:
|
128
|
+
Enabled: true
|
129
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## v0.3.3 - 2021-03-11
|
4
|
+
|
5
|
+
- Added `Client#create_candidate`
|
6
|
+
- Added `Client#create_job_application`
|
7
|
+
- Fix accessing `Client#jobs` without filters
|
8
|
+
|
3
9
|
## v0.3.2 - 2021-02-03
|
4
10
|
|
5
11
|
- Add support for `CustomField::Select` and `CustomField::MultiSelect`
|
data/Gemfile
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in teamtailor.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem "rake", "~> 12.0"
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
11
|
+
gem "rspec", "~> 3.0"
|
12
|
+
gem "rubocop"
|
13
|
+
gem "rubocop-rake"
|
14
|
+
gem "rubocop-rspec"
|
15
|
+
gem "webmock", "~> 3.4", ">= 3.4.2"
|
16
|
+
gem "simplecov", require: false
|
15
17
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
teamtailor (0.3.
|
4
|
+
teamtailor (0.3.3)
|
5
5
|
typhoeus (~> 1.3.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
addressable (2.7.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
|
-
ast (2.4.
|
12
|
+
ast (2.4.2)
|
13
13
|
crack (0.4.3)
|
14
14
|
safe_yaml (~> 1.0.0)
|
15
15
|
diff-lcs (1.3)
|
@@ -18,13 +18,13 @@ GEM
|
|
18
18
|
ffi (>= 1.3.0)
|
19
19
|
ffi (1.13.1)
|
20
20
|
hashdiff (1.0.1)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ast (~> 2.4.0)
|
21
|
+
parallel (1.20.1)
|
22
|
+
parser (3.0.0.0)
|
23
|
+
ast (~> 2.4.1)
|
25
24
|
public_suffix (4.0.3)
|
26
25
|
rainbow (3.0.0)
|
27
26
|
rake (12.3.3)
|
27
|
+
regexp_parser (2.0.3)
|
28
28
|
rexml (3.2.4)
|
29
29
|
rspec (3.9.0)
|
30
30
|
rspec-core (~> 3.9.0)
|
@@ -39,15 +39,23 @@ GEM
|
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
40
|
rspec-support (~> 3.9.0)
|
41
41
|
rspec-support (3.9.2)
|
42
|
-
rubocop (
|
43
|
-
jaro_winkler (~> 1.5.1)
|
42
|
+
rubocop (1.9.1)
|
44
43
|
parallel (~> 1.10)
|
45
|
-
parser (>=
|
44
|
+
parser (>= 3.0.0.0)
|
46
45
|
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
47
|
rexml
|
48
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
48
49
|
ruby-progressbar (~> 1.7)
|
49
|
-
unicode-display_width (>= 1.4.0, <
|
50
|
-
|
50
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.4.1)
|
52
|
+
parser (>= 2.7.1.5)
|
53
|
+
rubocop-rake (0.5.1)
|
54
|
+
rubocop
|
55
|
+
rubocop-rspec (2.2.0)
|
56
|
+
rubocop (~> 1.0)
|
57
|
+
rubocop-ast (>= 1.1.0)
|
58
|
+
ruby-progressbar (1.11.0)
|
51
59
|
safe_yaml (1.0.5)
|
52
60
|
simplecov (0.18.5)
|
53
61
|
docile (~> 1.1)
|
@@ -55,7 +63,7 @@ GEM
|
|
55
63
|
simplecov-html (0.12.2)
|
56
64
|
typhoeus (1.3.1)
|
57
65
|
ethon (>= 0.9.0)
|
58
|
-
unicode-display_width (
|
66
|
+
unicode-display_width (2.0.0)
|
59
67
|
webmock (3.8.3)
|
60
68
|
addressable (>= 2.3.6)
|
61
69
|
crack (>= 0.3.2)
|
@@ -68,6 +76,8 @@ DEPENDENCIES
|
|
68
76
|
rake (~> 12.0)
|
69
77
|
rspec (~> 3.0)
|
70
78
|
rubocop
|
79
|
+
rubocop-rake
|
80
|
+
rubocop-rspec
|
71
81
|
simplecov
|
72
82
|
teamtailor!
|
73
83
|
webmock (~> 3.4, >= 3.4.2)
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "teamtailor"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require 'teamtailor'
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require "irb"
|
15
15
|
IRB.start(__FILE__)
|
data/lib/teamtailor.rb
CHANGED
data/lib/teamtailor/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "teamtailor/request"
|
4
4
|
|
5
5
|
module Teamtailor
|
6
6
|
class Client
|
@@ -15,9 +15,9 @@ module Teamtailor
|
|
15
15
|
base_url: base_url,
|
16
16
|
api_token: api_token,
|
17
17
|
api_version: api_version,
|
18
|
-
path:
|
18
|
+
path: "/v1/company",
|
19
19
|
params: {
|
20
|
-
|
20
|
+
"include" => include.join(","),
|
21
21
|
}
|
22
22
|
).call
|
23
23
|
end
|
@@ -27,30 +27,45 @@ module Teamtailor
|
|
27
27
|
base_url: base_url,
|
28
28
|
api_token: api_token,
|
29
29
|
api_version: api_version,
|
30
|
-
path:
|
30
|
+
path: "/v1/candidates",
|
31
31
|
params: {
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
"page[number]" => page,
|
33
|
+
"page[size]" => 30,
|
34
|
+
"include" => include.join(","),
|
35
35
|
}
|
36
36
|
).call
|
37
37
|
end
|
38
38
|
|
39
|
+
def create_candidate(attributes:, relationships:)
|
40
|
+
Teamtailor::Request.new(
|
41
|
+
base_url: base_url,
|
42
|
+
api_token: api_token,
|
43
|
+
api_version: api_version,
|
44
|
+
path: "/v1/candidates",
|
45
|
+
method: :post,
|
46
|
+
body: {
|
47
|
+
data: {
|
48
|
+
type: "candidates",
|
49
|
+
attributes: attributes.transform_keys { |k| k.to_s.gsub("_", "-") },
|
50
|
+
relationships: relationships,
|
51
|
+
},
|
52
|
+
}
|
53
|
+
).call
|
54
|
+
end
|
55
|
+
|
39
56
|
def jobs(page: 1, include: [], filters: {})
|
40
|
-
filter_params = filters.
|
41
|
-
{ "filter[#{key}]" => filters[key] }
|
42
|
-
end
|
57
|
+
filter_params = filters.transform_keys { |key| "filter[#{key}]" }
|
43
58
|
|
44
59
|
Teamtailor::Request.new(
|
45
60
|
base_url: base_url,
|
46
61
|
api_token: api_token,
|
47
62
|
api_version: api_version,
|
48
|
-
path:
|
63
|
+
path: "/v1/jobs",
|
49
64
|
params: {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}.merge(
|
65
|
+
"page[number]" => page,
|
66
|
+
"page[size]" => 30,
|
67
|
+
"include" => include.join(","),
|
68
|
+
}.merge(filter_params)
|
54
69
|
).call
|
55
70
|
end
|
56
71
|
|
@@ -59,25 +74,42 @@ module Teamtailor
|
|
59
74
|
base_url: base_url,
|
60
75
|
api_token: api_token,
|
61
76
|
api_version: api_version,
|
62
|
-
path:
|
77
|
+
path: "/v1/job-applications",
|
63
78
|
params: {
|
64
|
-
|
65
|
-
|
66
|
-
|
79
|
+
"page[number]" => page,
|
80
|
+
"page[size]" => 30,
|
81
|
+
"include" => include.join(","),
|
67
82
|
}
|
68
83
|
).call
|
69
84
|
end
|
70
85
|
|
86
|
+
def create_job_application(attributes:, relationships:)
|
87
|
+
Teamtailor::Request.new(
|
88
|
+
base_url: base_url,
|
89
|
+
api_token: api_token,
|
90
|
+
api_version: api_version,
|
91
|
+
path: "/v1/job-applications",
|
92
|
+
method: :post,
|
93
|
+
body: {
|
94
|
+
data: {
|
95
|
+
type: "job-applications",
|
96
|
+
attributes: attributes.transform_keys { |k| k.to_s.gsub("_", "-") },
|
97
|
+
relationships: relationships,
|
98
|
+
},
|
99
|
+
}
|
100
|
+
).call
|
101
|
+
end
|
102
|
+
|
71
103
|
def users(page: 1, include: [])
|
72
104
|
Teamtailor::Request.new(
|
73
105
|
base_url: base_url,
|
74
106
|
api_token: api_token,
|
75
107
|
api_version: api_version,
|
76
|
-
path:
|
108
|
+
path: "/v1/users",
|
77
109
|
params: {
|
78
|
-
|
79
|
-
|
80
|
-
|
110
|
+
"page[number]" => page,
|
111
|
+
"page[size]" => 30,
|
112
|
+
"include" => include.join(","),
|
81
113
|
}
|
82
114
|
).call
|
83
115
|
end
|
@@ -87,11 +119,11 @@ module Teamtailor
|
|
87
119
|
base_url: base_url,
|
88
120
|
api_token: api_token,
|
89
121
|
api_version: api_version,
|
90
|
-
path:
|
122
|
+
path: "/v1/stages",
|
91
123
|
params: {
|
92
|
-
|
93
|
-
|
94
|
-
|
124
|
+
"page[number]" => page,
|
125
|
+
"page[size]" => 30,
|
126
|
+
"include" => include.join(","),
|
95
127
|
}
|
96
128
|
).call
|
97
129
|
end
|
@@ -101,11 +133,11 @@ module Teamtailor
|
|
101
133
|
base_url: base_url,
|
102
134
|
api_token: api_token,
|
103
135
|
api_version: api_version,
|
104
|
-
path:
|
136
|
+
path: "/v1/reject-reasons",
|
105
137
|
params: {
|
106
|
-
|
107
|
-
|
108
|
-
|
138
|
+
"page[number]" => page,
|
139
|
+
"page[size]" => 30,
|
140
|
+
"include" => include.join(","),
|
109
141
|
}
|
110
142
|
).call
|
111
143
|
end
|
@@ -115,11 +147,11 @@ module Teamtailor
|
|
115
147
|
base_url: base_url,
|
116
148
|
api_token: api_token,
|
117
149
|
api_version: api_version,
|
118
|
-
path:
|
150
|
+
path: "/v1/departments",
|
119
151
|
params: {
|
120
|
-
|
121
|
-
|
122
|
-
|
152
|
+
"page[number]" => page,
|
153
|
+
"page[size]" => 30,
|
154
|
+
"include" => include.join(","),
|
123
155
|
}
|
124
156
|
).call
|
125
157
|
end
|
@@ -129,11 +161,11 @@ module Teamtailor
|
|
129
161
|
base_url: base_url,
|
130
162
|
api_token: api_token,
|
131
163
|
api_version: api_version,
|
132
|
-
path:
|
164
|
+
path: "/v1/locations",
|
133
165
|
params: {
|
134
|
-
|
135
|
-
|
136
|
-
|
166
|
+
"page[number]" => page,
|
167
|
+
"page[size]" => 30,
|
168
|
+
"include" => include.join(","),
|
137
169
|
}
|
138
170
|
).call
|
139
171
|
end
|
@@ -143,11 +175,11 @@ module Teamtailor
|
|
143
175
|
base_url: base_url,
|
144
176
|
api_token: api_token,
|
145
177
|
api_version: api_version,
|
146
|
-
path:
|
178
|
+
path: "/v1/custom-fields",
|
147
179
|
params: {
|
148
|
-
|
149
|
-
|
150
|
-
|
180
|
+
"page[number]" => page,
|
181
|
+
"page[size]" => 30,
|
182
|
+
"include" => include.join(","),
|
151
183
|
}
|
152
184
|
).call
|
153
185
|
end
|
@@ -157,11 +189,11 @@ module Teamtailor
|
|
157
189
|
base_url: base_url,
|
158
190
|
api_token: api_token,
|
159
191
|
api_version: api_version,
|
160
|
-
path:
|
192
|
+
path: "/v1/custom-field-values",
|
161
193
|
params: {
|
162
|
-
|
163
|
-
|
164
|
-
|
194
|
+
"page[number]" => page,
|
195
|
+
"page[size]" => 30,
|
196
|
+
"include" => include.join(","),
|
165
197
|
}
|
166
198
|
).call
|
167
199
|
end
|
@@ -171,11 +203,11 @@ module Teamtailor
|
|
171
203
|
base_url: base_url,
|
172
204
|
api_token: api_token,
|
173
205
|
api_version: api_version,
|
174
|
-
path:
|
206
|
+
path: "/v1/referrals",
|
175
207
|
params: {
|
176
|
-
|
177
|
-
|
178
|
-
|
208
|
+
"page[number]" => page,
|
209
|
+
"page[size]" => 30,
|
210
|
+
"include" => include.join(","),
|
179
211
|
}
|
180
212
|
).call
|
181
213
|
end
|
@@ -185,11 +217,11 @@ module Teamtailor
|
|
185
217
|
base_url: base_url,
|
186
218
|
api_token: api_token,
|
187
219
|
api_version: api_version,
|
188
|
-
path:
|
220
|
+
path: "/v1/partner-results",
|
189
221
|
params: {
|
190
|
-
|
191
|
-
|
192
|
-
|
222
|
+
"page[number]" => page,
|
223
|
+
"page[size]" => 30,
|
224
|
+
"include" => include.join(","),
|
193
225
|
}
|
194
226
|
).call
|
195
227
|
end
|
@@ -199,11 +231,11 @@ module Teamtailor
|
|
199
231
|
base_url: base_url,
|
200
232
|
api_token: api_token,
|
201
233
|
api_version: api_version,
|
202
|
-
path:
|
234
|
+
path: "/v1/requisitions",
|
203
235
|
params: {
|
204
|
-
|
205
|
-
|
206
|
-
|
236
|
+
"page[number]" => page,
|
237
|
+
"page[size]" => 30,
|
238
|
+
"include" => include.join(","),
|
207
239
|
}
|
208
240
|
).call
|
209
241
|
end
|
data/lib/teamtailor/error.rb
CHANGED
@@ -9,7 +9,12 @@ module Teamtailor
|
|
9
9
|
when 406
|
10
10
|
json_response = JSON.parse(body)
|
11
11
|
Teamtailor::InvalidApiVersionError.new(
|
12
|
-
json_response.dig(
|
12
|
+
json_response.dig("errors", "detail")
|
13
|
+
)
|
14
|
+
when 422
|
15
|
+
json_response = JSON.parse(body)
|
16
|
+
Teamtailor::UnprocessableEntityError.new(
|
17
|
+
json_response.dig("errors", 0, "detail")
|
13
18
|
)
|
14
19
|
end
|
15
20
|
end
|
@@ -26,4 +31,6 @@ module Teamtailor
|
|
26
31
|
class UnknownResponseTypeError < ClientError; end
|
27
32
|
|
28
33
|
class UnloadedRelationError < ClientError; end
|
34
|
+
|
35
|
+
class UnprocessableEntityError < ClientError; end
|
29
36
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "teamtailor/parser"
|
4
4
|
|
5
5
|
module Teamtailor
|
6
6
|
class PageResult
|
@@ -13,27 +13,27 @@ module Teamtailor
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def data
|
16
|
-
json_response.dig(
|
16
|
+
json_response.dig("data")
|
17
17
|
end
|
18
18
|
|
19
19
|
def page_count
|
20
|
-
json_response.dig(
|
20
|
+
json_response.dig("meta", "page-count")
|
21
21
|
end
|
22
22
|
|
23
23
|
def record_count
|
24
|
-
json_response.dig(
|
24
|
+
json_response.dig("meta", "record-count")
|
25
25
|
end
|
26
26
|
|
27
27
|
def next_page_url
|
28
|
-
json_response.dig(
|
28
|
+
json_response.dig("links", "next")
|
29
29
|
end
|
30
30
|
|
31
31
|
def first_page_url
|
32
|
-
json_response.dig(
|
32
|
+
json_response.dig("links", "first")
|
33
33
|
end
|
34
34
|
|
35
35
|
def last_page_url
|
36
|
-
json_response.dig(
|
36
|
+
json_response.dig("links", "last")
|
37
37
|
end
|
38
38
|
|
39
39
|
def has_next_page?
|
data/lib/teamtailor/parser.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
3
|
+
require "teamtailor/parser/candidate"
|
4
|
+
require "teamtailor/parser/job"
|
5
|
+
require "teamtailor/parser/user"
|
6
|
+
require "teamtailor/parser/job_application"
|
7
|
+
require "teamtailor/parser/company"
|
8
|
+
require "teamtailor/parser/stage"
|
9
|
+
require "teamtailor/parser/reject_reason"
|
10
|
+
require "teamtailor/parser/department"
|
11
|
+
require "teamtailor/parser/location"
|
12
|
+
require "teamtailor/parser/custom_field"
|
13
|
+
require "teamtailor/parser/custom_field_value"
|
14
|
+
require "teamtailor/parser/referral"
|
15
|
+
require "teamtailor/parser/partner_result"
|
16
|
+
require "teamtailor/parser/requisition"
|
17
|
+
require "teamtailor/parser/requisition_step_verdict"
|
18
18
|
|
19
19
|
module Teamtailor
|
20
20
|
class Parser
|
@@ -24,26 +24,26 @@ module Teamtailor
|
|
24
24
|
|
25
25
|
def parse
|
26
26
|
data.map do |record|
|
27
|
-
case record&.dig(
|
28
|
-
when
|
29
|
-
when
|
30
|
-
when
|
31
|
-
when
|
32
|
-
when
|
33
|
-
when
|
34
|
-
when
|
35
|
-
when
|
36
|
-
when
|
37
|
-
when
|
38
|
-
when
|
39
|
-
when
|
40
|
-
when
|
41
|
-
when
|
42
|
-
when
|
43
|
-
when
|
27
|
+
case record&.dig("type")
|
28
|
+
when "candidates" then Teamtailor::Candidate.new(record, included)
|
29
|
+
when "jobs" then Teamtailor::Job.new(record, included)
|
30
|
+
when "users" then Teamtailor::User.new(record, included)
|
31
|
+
when "job-applications" then Teamtailor::JobApplication.new(record, included)
|
32
|
+
when "companies" then Teamtailor::Company.new(record, included)
|
33
|
+
when "stages" then Teamtailor::Stage.new(record, included)
|
34
|
+
when "reject-reasons" then Teamtailor::RejectReason.new(record, included)
|
35
|
+
when "departments" then Teamtailor::Department.new(record, included)
|
36
|
+
when "locations" then Teamtailor::Location.new(record, included)
|
37
|
+
when "custom-fields" then Teamtailor::CustomField.new(record, included)
|
38
|
+
when "custom-field-selects" then Teamtailor::CustomField.new(record, included)
|
39
|
+
when "custom-field-values" then Teamtailor::CustomFieldValue.new(record, included)
|
40
|
+
when "referrals" then Teamtailor::Referral.new(record, included)
|
41
|
+
when "partner-results" then Teamtailor::PartnerResult.new(record, included)
|
42
|
+
when "requisitions" then Teamtailor::Requisition.new(record, included)
|
43
|
+
when "requisition-step-verdicts" then Teamtailor::RequisitionStepVerdict.new(record, included)
|
44
44
|
|
45
45
|
else
|
46
|
-
raise Teamtailor::UnknownResponseTypeError, record&.dig(
|
46
|
+
raise Teamtailor::UnknownResponseTypeError, record&.dig("type")
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -57,11 +57,11 @@ module Teamtailor
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def data
|
60
|
-
[payload&.dig(
|
60
|
+
[payload&.dig("data")].flatten
|
61
61
|
end
|
62
62
|
|
63
63
|
def included
|
64
|
-
payload&.dig(
|
64
|
+
payload&.dig("included")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "teamtailor/record"
|
4
4
|
|
5
5
|
module Teamtailor
|
6
6
|
class Candidate < Record
|
7
7
|
def connected?
|
8
|
-
data.dig(
|
8
|
+
data.dig("attributes", "connected")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "teamtailor/record"
|
4
4
|
|
5
5
|
module Teamtailor
|
6
6
|
class Job < Record
|
7
7
|
def careersite_job_url
|
8
|
-
data.dig(
|
8
|
+
data.dig("links", "careersite-job-url")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/teamtailor/record.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "teamtailor/relationship"
|
2
2
|
|
3
3
|
module Teamtailor
|
4
4
|
class Record
|
@@ -9,23 +9,23 @@ module Teamtailor
|
|
9
9
|
|
10
10
|
def self.deserialize(value)
|
11
11
|
payload = JSON.parse value
|
12
|
-
new(payload[
|
12
|
+
new(payload["data"], payload["included"])
|
13
13
|
end
|
14
14
|
|
15
15
|
def serialize
|
16
16
|
{
|
17
17
|
data: data,
|
18
|
-
included: included
|
18
|
+
included: included,
|
19
19
|
}.to_json
|
20
20
|
end
|
21
21
|
|
22
22
|
def method_missing(m)
|
23
23
|
if m == :id
|
24
|
-
data.dig(
|
25
|
-
elsif relationship_keys.include?(m.to_s.gsub(
|
26
|
-
build_relationship(m.to_s.gsub(
|
24
|
+
data.dig("id").to_i
|
25
|
+
elsif relationship_keys.include?(m.to_s.gsub("_", "-"))
|
26
|
+
build_relationship(m.to_s.gsub("_", "-"))
|
27
27
|
else
|
28
|
-
data.dig(
|
28
|
+
data.dig("attributes", m.to_s.gsub("_", "-"))
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -34,11 +34,11 @@ module Teamtailor
|
|
34
34
|
attr_reader :data, :included
|
35
35
|
|
36
36
|
def build_relationship(name)
|
37
|
-
Teamtailor::Relationship.new(name, data.dig(
|
37
|
+
Teamtailor::Relationship.new(name, data.dig("relationships"), included)
|
38
38
|
end
|
39
39
|
|
40
40
|
def relationship_keys
|
41
|
-
data.dig(
|
41
|
+
data.dig("relationships")&.keys || {}
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -16,22 +16,22 @@ module Teamtailor
|
|
16
16
|
raise Teamtailor::UnloadedRelationError unless loaded?
|
17
17
|
|
18
18
|
record_json = included.select do |k|
|
19
|
-
record_ids.include?(k[
|
19
|
+
record_ids.include?(k["id"]) && k["type"] == record_type
|
20
20
|
end
|
21
21
|
|
22
|
-
Teamtailor::Parser.parse({
|
22
|
+
Teamtailor::Parser.parse({ "data" => record_json, "included" => included })
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def record_ids
|
28
|
-
data = [relationships&.dig(relation_name,
|
29
|
-
data.map { |row| row[
|
28
|
+
data = [relationships&.dig(relation_name, "data")].flatten.compact
|
29
|
+
data.map { |row| row["id"] }
|
30
30
|
end
|
31
31
|
|
32
32
|
def record_type
|
33
|
-
data = [relationships&.dig(relation_name,
|
34
|
-
data.map { |row| row[
|
33
|
+
data = [relationships&.dig(relation_name, "data")].flatten
|
34
|
+
data.map { |row| row["type"] }.first
|
35
35
|
end
|
36
36
|
|
37
37
|
attr_reader :relation_name, :relationships, :included
|
data/lib/teamtailor/request.rb
CHANGED
@@ -1,29 +1,34 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "typhoeus"
|
2
|
+
require "json"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "teamtailor/page_result"
|
5
5
|
|
6
6
|
module Teamtailor
|
7
7
|
class Request
|
8
|
-
def initialize(base_url:, api_token:, api_version:, path:, params: {})
|
8
|
+
def initialize(base_url:, api_token:, api_version:, path:, params: {}, body: {}, method: :get)
|
9
9
|
@base_url = base_url
|
10
10
|
@api_token = api_token
|
11
11
|
@api_version = api_version
|
12
12
|
@path = path
|
13
13
|
@params = params
|
14
|
+
@method = method
|
15
|
+
@body = body
|
14
16
|
end
|
15
17
|
|
16
18
|
def call
|
17
19
|
request = Typhoeus::Request.new(
|
18
20
|
"#{base_url}#{path}",
|
19
|
-
method:
|
21
|
+
method: method,
|
20
22
|
params: params,
|
21
|
-
headers: request_headers
|
23
|
+
headers: request_headers,
|
24
|
+
body: body.to_json
|
22
25
|
)
|
23
26
|
response = request.run
|
24
27
|
|
25
28
|
if response.code == 200
|
26
29
|
Teamtailor::PageResult.new response.body
|
30
|
+
elsif response.code == 201
|
31
|
+
Teamtailor::Parser.parse(JSON.parse(response.body)).first
|
27
32
|
else
|
28
33
|
raise Teamtailor::Error.from_response(
|
29
34
|
body: response.body,
|
@@ -34,14 +39,14 @@ module Teamtailor
|
|
34
39
|
|
35
40
|
private
|
36
41
|
|
37
|
-
attr_reader :base_url, :path, :api_token, :api_version, :params
|
42
|
+
attr_reader :base_url, :path, :api_token, :api_version, :params, :method, :body
|
38
43
|
|
39
44
|
def request_headers
|
40
45
|
{
|
41
46
|
"Authorization": "Token token=#{api_token}",
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
"X-Api-Version" => api_version,
|
48
|
+
"User-Agent" => "teamtailor-rb v#{Teamtailor::VERSION}",
|
49
|
+
"Content-Type" => "application/vnd.api+json; charset=utf-8",
|
45
50
|
}
|
46
51
|
end
|
47
52
|
end
|
data/lib/teamtailor/version.rb
CHANGED
data/teamtailor.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "lib/teamtailor/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = "teamtailor"
|
7
7
|
spec.version = Teamtailor::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ["André Ligné"]
|
9
|
+
spec.email = ["hi@andreligne.se"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = "Library for interacting with the Teamtailor API"
|
12
|
+
spec.homepage = "https://github.com/teamtailor/teamtailor-gem"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
15
15
|
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/bzf/teamtailor-rb"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/bzf/teamtailor-rb/main/CHANGELOG.md"
|
19
19
|
|
20
|
-
spec.extra_rdoc_files = [
|
20
|
+
spec.extra_rdoc_files = ["README.md"]
|
21
21
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_dependency
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
23
|
+
spec.add_dependency "typhoeus", "~> 1.3.1"
|
24
24
|
|
25
25
|
# Specify which files should be added to the gem when it is released.
|
26
26
|
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
f.match(%r{^(test|spec|features)/})
|
31
31
|
end
|
32
32
|
end
|
33
|
-
spec.bindir =
|
33
|
+
spec.bindir = "exe"
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
-
spec.require_paths = [
|
35
|
+
spec.require_paths = ["lib"]
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamtailor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Ligné
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- ".github/workflows/ruby.yml"
|
50
50
|
- ".gitignore"
|
51
51
|
- ".rspec"
|
52
|
+
- ".rubocop.yml"
|
52
53
|
- ".travis.yml"
|
53
54
|
- CHANGELOG.md
|
54
55
|
- Gemfile
|