teamtailor 0.2.5 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d95d0a6e7de8bb4c59685b5eb62f3c17a3d12a85b5f26dc9604da58c71ba4943
4
- data.tar.gz: c98e3cdef79a200769756818ba0e6513a7f260c8c8f91677773cd05951b1b995
3
+ metadata.gz: 16e2ef81d1b5db75ba273ea7d0b38d689488c57f6da278dc12eda7052136bbd0
4
+ data.tar.gz: f7e0304fcc2951427ba15037bc1d6345f0afa665976537821efba7ccbbb0ded2
5
5
  SHA512:
6
- metadata.gz: 71caa179004d33e18cd4cbae5a0877e1bb8fe37b8f6b4e45f23c69692d7037188b29c42346deb0cc654d54f27aac4a97cd49d6d83af8d8af3a75b4d75e9ffd96
7
- data.tar.gz: ff55550860c52977f6a039a771eb0df325366f15cb0cd847f73a03ed448dee184dffccbd56d1f123eea390d33949a637a543c0ca4b8f3fad930107606c3ccbf1
6
+ metadata.gz: 8edcd6a598a1bf8298b0f47778a571652f3abb113c4952435a2f156f65650a10cf0385ac2bf5448c45dce7a5b1ab3acaddae10c287cad6a130fa2441e1421122
7
+ data.tar.gz: 9b845638fef4753da98486f892ee4e35aa2eb9a37a34cf2ff63b5c571bd59f9299c6c6a322ec6d194ecd7c4223cd7969f26a9fa2f4b262047c0cbd790ea191f0
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+ on: [push, pull_request]
3
+ jobs:
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
+
19
+ lint:
20
+ runs-on: ubuntu-latest
21
+ steps:
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,33 @@
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
+
9
+ ## v0.3.2 - 2021-02-03
10
+
11
+ - Add support for `CustomField::Select` and `CustomField::MultiSelect`
12
+
13
+ ## v0.3.1 - 2020-11-13
14
+
15
+ - Update metadata in the `teamtailor.gemspec`
16
+
17
+ ## v0.3.0 - 2020-06-30
18
+
19
+ - [BREAKING] Update `Teamtailor::Relationship` to always return multiple records
20
+ - Add `Teamtailor::Requisition` and `Client#requisitions`
21
+ - Add `Teamtailor::RequisitionStepVerdict`
22
+ - Fix accessing nested relationships on `Relationship`
23
+
24
+ ## v0.2.6 - 2020-05-18
25
+
26
+ - Add `Teamtailor::PartnerResult` and `Client#partner_results`
27
+ - Add `Teamtailor::Referral` and `Client#referrals`
28
+ - Add `Teamtailor::CustomField` and `Teamtailor::CustomFieldValue`
29
+ - Add `Client#custom_fields` and `Client#custom_field_values`
30
+
3
31
  ## v0.2.5 - 2020-05-15
4
32
 
5
33
  - Add `filters:` as an argument to `Client#jobs`
data/Gemfile CHANGED
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in teamtailor.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 12.0'
8
+ gem "rake", "~> 12.0"
9
9
 
10
10
  group :test do
11
- gem 'rspec', '~> 3.0'
12
- gem 'rubocop'
13
- gem 'webmock', '~> 3.4', '>= 3.4.2'
14
- gem 'simplecov', require: false
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.2.5)
4
+ teamtailor (0.3.3)
5
5
  typhoeus (~> 1.3.1)
6
6
 
7
7
  GEM
@@ -9,22 +9,22 @@ GEM
9
9
  specs:
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.0)
12
+ ast (2.4.2)
13
13
  crack (0.4.3)
14
14
  safe_yaml (~> 1.0.0)
15
15
  diff-lcs (1.3)
16
16
  docile (1.3.2)
17
17
  ethon (0.12.0)
18
18
  ffi (>= 1.3.0)
19
- ffi (1.12.2)
19
+ ffi (1.13.1)
20
20
  hashdiff (1.0.1)
21
- jaro_winkler (1.5.4)
22
- parallel (1.19.1)
23
- parser (2.7.0.5)
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 (0.80.1)
43
- jaro_winkler (~> 1.5.1)
42
+ rubocop (1.9.1)
44
43
  parallel (~> 1.10)
45
- parser (>= 2.7.0.1)
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, < 1.7)
50
- ruby-progressbar (1.10.1)
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 (1.6.1)
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/README.md CHANGED
@@ -117,7 +117,7 @@ git commits and tags, and push the `.gem` file to
117
117
  ## Contributing
118
118
 
119
119
  Bug reports and pull requests are welcome on GitHub at
120
- https://github.com/bzf/teamtailor-rb.
120
+ https://github.com/teamtailor/teamtailor-rb.
121
121
 
122
122
 
123
123
  ## License
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'teamtailor'
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 'irb'
14
+ require "irb"
15
15
  IRB.start(__FILE__)
data/lib/teamtailor.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/error'
4
- require 'teamtailor/client'
5
- require 'teamtailor/version'
3
+ require "teamtailor/error"
4
+ require "teamtailor/client"
5
+ require "teamtailor/version"
6
6
 
7
7
  module Teamtailor
8
8
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/request'
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: '/v1/company',
18
+ path: "/v1/company",
19
19
  params: {
20
- 'include' => include.join(',')
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: '/v1/candidates',
30
+ path: "/v1/candidates",
31
31
  params: {
32
- 'page[number]' => page,
33
- 'page[size]' => 30,
34
- 'include' => include.join(',')
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.keys.map do |key|
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: '/v1/jobs',
63
+ path: "/v1/jobs",
49
64
  params: {
50
- 'page[number]' => page,
51
- 'page[size]' => 30,
52
- 'include' => include.join(','),
53
- }.merge(*filter_params)
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: '/v1/job-applications',
77
+ path: "/v1/job-applications",
63
78
  params: {
64
- 'page[number]' => page,
65
- 'page[size]' => 30,
66
- 'include' => include.join(',')
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: '/v1/users',
108
+ path: "/v1/users",
77
109
  params: {
78
- 'page[number]' => page,
79
- 'page[size]' => 30,
80
- 'include' => include.join(',')
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: '/v1/stages',
122
+ path: "/v1/stages",
91
123
  params: {
92
- 'page[number]' => page,
93
- 'page[size]' => 30,
94
- 'include' => include.join(',')
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: '/v1/reject-reasons',
136
+ path: "/v1/reject-reasons",
105
137
  params: {
106
- 'page[number]' => page,
107
- 'page[size]' => 30,
108
- 'include' => include.join(',')
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: '/v1/departments',
150
+ path: "/v1/departments",
119
151
  params: {
120
- 'page[number]' => page,
121
- 'page[size]' => 30,
122
- 'include' => include.join(',')
152
+ "page[number]" => page,
153
+ "page[size]" => 30,
154
+ "include" => include.join(","),
123
155
  }
124
156
  ).call
125
157
  end
@@ -129,11 +161,81 @@ module Teamtailor
129
161
  base_url: base_url,
130
162
  api_token: api_token,
131
163
  api_version: api_version,
132
- path: '/v1/locations',
164
+ path: "/v1/locations",
165
+ params: {
166
+ "page[number]" => page,
167
+ "page[size]" => 30,
168
+ "include" => include.join(","),
169
+ }
170
+ ).call
171
+ end
172
+
173
+ def custom_fields(page: 1, include: [])
174
+ Teamtailor::Request.new(
175
+ base_url: base_url,
176
+ api_token: api_token,
177
+ api_version: api_version,
178
+ path: "/v1/custom-fields",
179
+ params: {
180
+ "page[number]" => page,
181
+ "page[size]" => 30,
182
+ "include" => include.join(","),
183
+ }
184
+ ).call
185
+ end
186
+
187
+ def custom_field_values(page: 1, include: [])
188
+ Teamtailor::Request.new(
189
+ base_url: base_url,
190
+ api_token: api_token,
191
+ api_version: api_version,
192
+ path: "/v1/custom-field-values",
193
+ params: {
194
+ "page[number]" => page,
195
+ "page[size]" => 30,
196
+ "include" => include.join(","),
197
+ }
198
+ ).call
199
+ end
200
+
201
+ def referrals(page: 1, include: [])
202
+ Teamtailor::Request.new(
203
+ base_url: base_url,
204
+ api_token: api_token,
205
+ api_version: api_version,
206
+ path: "/v1/referrals",
207
+ params: {
208
+ "page[number]" => page,
209
+ "page[size]" => 30,
210
+ "include" => include.join(","),
211
+ }
212
+ ).call
213
+ end
214
+
215
+ def partner_results(page: 1, include: [])
216
+ Teamtailor::Request.new(
217
+ base_url: base_url,
218
+ api_token: api_token,
219
+ api_version: api_version,
220
+ path: "/v1/partner-results",
221
+ params: {
222
+ "page[number]" => page,
223
+ "page[size]" => 30,
224
+ "include" => include.join(","),
225
+ }
226
+ ).call
227
+ end
228
+
229
+ def requisitions(page: 1, include: [])
230
+ Teamtailor::Request.new(
231
+ base_url: base_url,
232
+ api_token: api_token,
233
+ api_version: api_version,
234
+ path: "/v1/requisitions",
133
235
  params: {
134
- 'page[number]' => page,
135
- 'page[size]' => 30,
136
- 'include' => include.join(',')
236
+ "page[number]" => page,
237
+ "page[size]" => 30,
238
+ "include" => include.join(","),
137
239
  }
138
240
  ).call
139
241
  end
@@ -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('errors', 'detail')
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 'teamtailor/parser'
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('data')
16
+ json_response.dig("data")
17
17
  end
18
18
 
19
19
  def page_count
20
- json_response.dig('meta', 'page-count')
20
+ json_response.dig("meta", "page-count")
21
21
  end
22
22
 
23
23
  def record_count
24
- json_response.dig('meta', 'record-count')
24
+ json_response.dig("meta", "record-count")
25
25
  end
26
26
 
27
27
  def next_page_url
28
- json_response.dig('links', 'next')
28
+ json_response.dig("links", "next")
29
29
  end
30
30
 
31
31
  def first_page_url
32
- json_response.dig('links', 'first')
32
+ json_response.dig("links", "first")
33
33
  end
34
34
 
35
35
  def last_page_url
36
- json_response.dig('links', 'last')
36
+ json_response.dig("links", "last")
37
37
  end
38
38
 
39
39
  def has_next_page?
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
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'
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"
12
18
 
13
19
  module Teamtailor
14
20
  class Parser
@@ -18,19 +24,26 @@ module Teamtailor
18
24
 
19
25
  def parse
20
26
  data.map do |record|
21
- case record&.dig('type')
22
- when 'candidates' then Teamtailor::Candidate.new(record, included)
23
- when 'jobs' then Teamtailor::Job.new(record, included)
24
- when 'users' then Teamtailor::User.new(record, included)
25
- when 'job-applications' then Teamtailor::JobApplication.new(record, included)
26
- when 'companies' then Teamtailor::Company.new(record, included)
27
- when 'stages' then Teamtailor::Stage.new(record, included)
28
- when 'reject-reasons' then Teamtailor::RejectReason.new(record, included)
29
- when 'departments' then Teamtailor::Department.new(record, included)
30
- when 'locations' then Teamtailor::Location.new(record, included)
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)
31
44
 
32
45
  else
33
- raise Teamtailor::UnknownResponseTypeError, record&.dig('type')
46
+ raise Teamtailor::UnknownResponseTypeError, record&.dig("type")
34
47
  end
35
48
  end
36
49
  end
@@ -44,11 +57,11 @@ module Teamtailor
44
57
  end
45
58
 
46
59
  def data
47
- [payload&.dig('data')].flatten
60
+ [payload&.dig("data")].flatten
48
61
  end
49
62
 
50
63
  def included
51
- payload&.dig('included')
64
+ payload&.dig("included")
52
65
  end
53
66
  end
54
67
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Candidate < Record
7
7
  def connected?
8
- data.dig('attributes', 'connected')
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 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Company < Record
7
7
  def id
8
- data.dig('id')
8
+ data.dig("id")
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class CustomField < Record
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class CustomFieldValue < Record
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Department < Record
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Job < Record
7
7
  def careersite_job_url
8
- data.dig('links', 'careersite-job-url')
8
+ data.dig("links", "careersite-job-url")
9
9
  end
10
10
  end
11
11
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class JobApplication < Record
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Location < Record
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class PartnerResult < Record
7
+ def id
8
+ data.dig("id")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class Referral < Record
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class RejectReason < Record
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class Requisition < Record
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class RequisitionStepVerdict < Record
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class Stage < Record
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'teamtailor/record'
3
+ require "teamtailor/record"
4
4
 
5
5
  module Teamtailor
6
6
  class User < Record
@@ -1,4 +1,4 @@
1
- require 'teamtailor/relationship'
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['data'], payload['included'])
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('id').to_i
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('attributes', m.to_s.gsub('_', '-'))
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('relationships'), included)
37
+ Teamtailor::Relationship.new(name, data.dig("relationships"), included)
38
38
  end
39
39
 
40
40
  def relationship_keys
41
- data.dig('relationships')&.keys || {}
41
+ data.dig("relationships")&.keys || {}
42
42
  end
43
43
  end
44
44
  end
@@ -9,27 +9,29 @@ module Teamtailor
9
9
  end
10
10
 
11
11
  def loaded?
12
- !record_id.nil?
12
+ !record_ids.empty?
13
13
  end
14
14
 
15
- def record
15
+ def records
16
16
  raise Teamtailor::UnloadedRelationError unless loaded?
17
17
 
18
- record_json = included.find do |k|
19
- k['id'] == record_id && k['type'] == record_type
18
+ record_json = included.select do |k|
19
+ record_ids.include?(k["id"]) && k["type"] == record_type
20
20
  end
21
21
 
22
- Teamtailor::Parser.parse({ 'data' => record_json }).first
22
+ Teamtailor::Parser.parse({ "data" => record_json, "included" => included })
23
23
  end
24
24
 
25
25
  private
26
26
 
27
- def record_id
28
- relationships&.dig(relation_name, 'data', 'id')
27
+ def record_ids
28
+ data = [relationships&.dig(relation_name, "data")].flatten.compact
29
+ data.map { |row| row["id"] }
29
30
  end
30
31
 
31
32
  def record_type
32
- relationships&.dig(relation_name, 'data', 'type')
33
+ data = [relationships&.dig(relation_name, "data")].flatten
34
+ data.map { |row| row["type"] }.first
33
35
  end
34
36
 
35
37
  attr_reader :relation_name, :relationships, :included
@@ -1,29 +1,34 @@
1
- require 'typhoeus'
2
- require 'json'
1
+ require "typhoeus"
2
+ require "json"
3
3
 
4
- require 'teamtailor/page_result'
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: :get,
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
- 'X-Api-Version' => api_version,
43
- 'User-Agent' => "teamtailor-rb v#{Teamtailor::VERSION}",
44
- 'Content-Type' => 'application/vnd.api+json; charset=utf-8'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teamtailor
4
- VERSION = '0.2.5'
4
+ VERSION = "0.3.3"
5
5
  end
data/teamtailor.gemspec CHANGED
@@ -1,24 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/teamtailor/version'
3
+ require_relative "lib/teamtailor/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'teamtailor'
6
+ spec.name = "teamtailor"
7
7
  spec.version = Teamtailor::VERSION
8
- spec.authors = ['André Ligné']
9
- spec.email = ['hi@andreligne.se']
8
+ spec.authors = ["André Ligné"]
9
+ spec.email = ["hi@andreligne.se"]
10
10
 
11
- spec.summary = 'Library for interacting with the Teamtailor API'
12
- spec.homepage = 'https://github.com/bzf/teamtailor-gem'
13
- spec.license = 'MIT'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
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['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/master/CHANGELOG.md'
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.add_development_dependency 'rspec', '~> 3.2'
21
- spec.add_dependency 'typhoeus', '~> 1.3.1'
20
+ spec.extra_rdoc_files = ["README.md"]
21
+
22
+ spec.add_development_dependency "rspec", "~> 3.2"
23
+ spec.add_dependency "typhoeus", "~> 1.3.1"
22
24
 
23
25
  # Specify which files should be added to the gem when it is released.
24
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added
@@ -28,7 +30,7 @@ Gem::Specification.new do |spec|
28
30
  f.match(%r{^(test|spec|features)/})
29
31
  end
30
32
  end
31
- spec.bindir = 'exe'
33
+ spec.bindir = "exe"
32
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = ['lib']
35
+ spec.require_paths = ["lib"]
34
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.2.5
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Ligné
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,15 +38,18 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.1
41
- description:
41
+ description:
42
42
  email:
43
43
  - hi@andreligne.se
44
44
  executables: []
45
45
  extensions: []
46
- extra_rdoc_files: []
46
+ extra_rdoc_files:
47
+ - README.md
47
48
  files:
49
+ - ".github/workflows/ruby.yml"
48
50
  - ".gitignore"
49
51
  - ".rspec"
52
+ - ".rubocop.yml"
50
53
  - ".travis.yml"
51
54
  - CHANGELOG.md
52
55
  - Gemfile
@@ -63,11 +66,17 @@ files:
63
66
  - lib/teamtailor/parser.rb
64
67
  - lib/teamtailor/parser/candidate.rb
65
68
  - lib/teamtailor/parser/company.rb
69
+ - lib/teamtailor/parser/custom_field.rb
70
+ - lib/teamtailor/parser/custom_field_value.rb
66
71
  - lib/teamtailor/parser/department.rb
67
72
  - lib/teamtailor/parser/job.rb
68
73
  - lib/teamtailor/parser/job_application.rb
69
74
  - lib/teamtailor/parser/location.rb
75
+ - lib/teamtailor/parser/partner_result.rb
76
+ - lib/teamtailor/parser/referral.rb
70
77
  - lib/teamtailor/parser/reject_reason.rb
78
+ - lib/teamtailor/parser/requisition.rb
79
+ - lib/teamtailor/parser/requisition_step_verdict.rb
71
80
  - lib/teamtailor/parser/stage.rb
72
81
  - lib/teamtailor/parser/user.rb
73
82
  - lib/teamtailor/record.rb
@@ -75,14 +84,14 @@ files:
75
84
  - lib/teamtailor/request.rb
76
85
  - lib/teamtailor/version.rb
77
86
  - teamtailor.gemspec
78
- homepage: https://github.com/bzf/teamtailor-gem
87
+ homepage: https://github.com/teamtailor/teamtailor-gem
79
88
  licenses:
80
89
  - MIT
81
90
  metadata:
82
- homepage_uri: https://github.com/bzf/teamtailor-gem
91
+ homepage_uri: https://github.com/teamtailor/teamtailor-gem
83
92
  source_code_uri: https://github.com/bzf/teamtailor-rb
84
- changelog_uri: https://github.com/bzf/teamtailor-rb/master/CHANGELOG.md
85
- post_install_message:
93
+ changelog_uri: https://github.com/bzf/teamtailor-rb/main/CHANGELOG.md
94
+ post_install_message:
86
95
  rdoc_options: []
87
96
  require_paths:
88
97
  - lib
@@ -97,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
106
  - !ruby/object:Gem::Version
98
107
  version: '0'
99
108
  requirements: []
100
- rubygems_version: 3.0.3
101
- signing_key:
109
+ rubygems_version: 3.1.4
110
+ signing_key:
102
111
  specification_version: 4
103
112
  summary: Library for interacting with the Teamtailor API
104
113
  test_files: []