teamtailor 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2149b16c38eaf624c87c2f06eec2acea93d0cd3e92d6b7a6322f43809c20816f
4
- data.tar.gz: 1250d366f8bb782a3909a10768219d938d411d6ede3222153ab9873cd3c6167f
3
+ metadata.gz: 9c57341c9921c00f3071776c738524eb9a117066bd62d530bf580c5ee9fb5c3d
4
+ data.tar.gz: 8c4272a54dceb9c87d7d3e8008a313eb1a90737035dc467bc035123e1e0d71fd
5
5
  SHA512:
6
- metadata.gz: 2f0da415942f37cc09fd8f8ea914ca78001305be8c3b9de66b9a2a215a12a489f13e0f13133661129042603d8c055428e2062b1dcabad230b7ed84be2125b937
7
- data.tar.gz: 323f5bdd970d9bf602d87fd8822cb1c99141b0d0ae7ad9a903e639c09a078d6b03748f975ec717228818ca0728d440bd81f9104bb3676005e5859a397eb522d8
6
+ metadata.gz: '096700846b1ef8b90ac22f506d54ddfc00cbab59b083f1573b0a17967add35e9ef7fb01fc7f908e62c46379e5b431e5ee8c7c2e07a46f5e9e5dac44d3c7786a2'
7
+ data.tar.gz: 52e0e41220eb03eced02c1a9fc841c68ed14139ad9778de5601ebb3e5713a0400f909a9b7fc53725e41771f1a4c6241041211c17bcd031cab1bfa3c6681aceab
@@ -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,6 +1,24 @@
1
1
  ## Unreleased
2
2
 
3
- ## v0.3.0 - 2020-05-18
3
+ ## v0.4.0 - 2021-09-06
4
+
5
+ - Added `Client#create_upload`
6
+
7
+ ## v0.3.3 - 2021-03-10
8
+
9
+ - Added `Client#create_candidate`
10
+ - Added `Client#create_job_application`
11
+ - Fix accessing `Client#jobs` without filters
12
+
13
+ ## v0.3.2 - 2021-02-03
14
+
15
+ - Add support for `CustomField::Select` and `CustomField::MultiSelect`
16
+
17
+ ## v0.3.1 - 2020-11-13
18
+
19
+ - Update metadata in the `teamtailor.gemspec`
20
+
21
+ ## v0.3.0 - 2020-06-30
4
22
 
5
23
  - [BREAKING] Update `Teamtailor::Relationship` to always return multiple records
6
24
  - Add `Teamtailor::Requisition` and `Client#requisitions`
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.3.0)
4
+ teamtailor (0.4.0)
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
- ethon (0.12.0)
18
- ffi (>= 1.3.0)
19
- ffi (1.13.1)
17
+ ethon (0.14.0)
18
+ ffi (>= 1.15.0)
19
+ ffi (1.15.4)
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__)
@@ -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,59 @@ 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_upload(attributes:, relationships:)
87
+ Teamtailor::Request.new(
88
+ base_url: base_url,
89
+ api_token: api_token,
90
+ api_version: api_version,
91
+ path: "/v1/uploads",
92
+ method: :post,
93
+ body: {
94
+ data: {
95
+ type: "uploads",
96
+ attributes: attributes.transform_keys { |k| k.to_s.gsub("_", "-") },
97
+ relationships: relationships,
98
+ },
99
+ }
100
+ ).call
101
+ end
102
+
103
+ def create_job_application(attributes:, relationships:)
104
+ Teamtailor::Request.new(
105
+ base_url: base_url,
106
+ api_token: api_token,
107
+ api_version: api_version,
108
+ path: "/v1/job-applications",
109
+ method: :post,
110
+ body: {
111
+ data: {
112
+ type: "job-applications",
113
+ attributes: attributes.transform_keys { |k| k.to_s.gsub("_", "-") },
114
+ relationships: relationships,
115
+ },
116
+ }
117
+ ).call
118
+ end
119
+
71
120
  def users(page: 1, include: [])
72
121
  Teamtailor::Request.new(
73
122
  base_url: base_url,
74
123
  api_token: api_token,
75
124
  api_version: api_version,
76
- path: '/v1/users',
125
+ path: "/v1/users",
77
126
  params: {
78
- 'page[number]' => page,
79
- 'page[size]' => 30,
80
- 'include' => include.join(',')
127
+ "page[number]" => page,
128
+ "page[size]" => 30,
129
+ "include" => include.join(","),
81
130
  }
82
131
  ).call
83
132
  end
@@ -87,11 +136,11 @@ module Teamtailor
87
136
  base_url: base_url,
88
137
  api_token: api_token,
89
138
  api_version: api_version,
90
- path: '/v1/stages',
139
+ path: "/v1/stages",
91
140
  params: {
92
- 'page[number]' => page,
93
- 'page[size]' => 30,
94
- 'include' => include.join(',')
141
+ "page[number]" => page,
142
+ "page[size]" => 30,
143
+ "include" => include.join(","),
95
144
  }
96
145
  ).call
97
146
  end
@@ -101,11 +150,11 @@ module Teamtailor
101
150
  base_url: base_url,
102
151
  api_token: api_token,
103
152
  api_version: api_version,
104
- path: '/v1/reject-reasons',
153
+ path: "/v1/reject-reasons",
105
154
  params: {
106
- 'page[number]' => page,
107
- 'page[size]' => 30,
108
- 'include' => include.join(',')
155
+ "page[number]" => page,
156
+ "page[size]" => 30,
157
+ "include" => include.join(","),
109
158
  }
110
159
  ).call
111
160
  end
@@ -115,11 +164,11 @@ module Teamtailor
115
164
  base_url: base_url,
116
165
  api_token: api_token,
117
166
  api_version: api_version,
118
- path: '/v1/departments',
167
+ path: "/v1/departments",
119
168
  params: {
120
- 'page[number]' => page,
121
- 'page[size]' => 30,
122
- 'include' => include.join(',')
169
+ "page[number]" => page,
170
+ "page[size]" => 30,
171
+ "include" => include.join(","),
123
172
  }
124
173
  ).call
125
174
  end
@@ -129,11 +178,11 @@ module Teamtailor
129
178
  base_url: base_url,
130
179
  api_token: api_token,
131
180
  api_version: api_version,
132
- path: '/v1/locations',
181
+ path: "/v1/locations",
133
182
  params: {
134
- 'page[number]' => page,
135
- 'page[size]' => 30,
136
- 'include' => include.join(',')
183
+ "page[number]" => page,
184
+ "page[size]" => 30,
185
+ "include" => include.join(","),
137
186
  }
138
187
  ).call
139
188
  end
@@ -143,11 +192,11 @@ module Teamtailor
143
192
  base_url: base_url,
144
193
  api_token: api_token,
145
194
  api_version: api_version,
146
- path: '/v1/custom-fields',
195
+ path: "/v1/custom-fields",
147
196
  params: {
148
- 'page[number]' => page,
149
- 'page[size]' => 30,
150
- 'include' => include.join(',')
197
+ "page[number]" => page,
198
+ "page[size]" => 30,
199
+ "include" => include.join(","),
151
200
  }
152
201
  ).call
153
202
  end
@@ -157,11 +206,11 @@ module Teamtailor
157
206
  base_url: base_url,
158
207
  api_token: api_token,
159
208
  api_version: api_version,
160
- path: '/v1/custom-field-values',
209
+ path: "/v1/custom-field-values",
161
210
  params: {
162
- 'page[number]' => page,
163
- 'page[size]' => 30,
164
- 'include' => include.join(',')
211
+ "page[number]" => page,
212
+ "page[size]" => 30,
213
+ "include" => include.join(","),
165
214
  }
166
215
  ).call
167
216
  end
@@ -171,11 +220,11 @@ module Teamtailor
171
220
  base_url: base_url,
172
221
  api_token: api_token,
173
222
  api_version: api_version,
174
- path: '/v1/referrals',
223
+ path: "/v1/referrals",
175
224
  params: {
176
- 'page[number]' => page,
177
- 'page[size]' => 30,
178
- 'include' => include.join(',')
225
+ "page[number]" => page,
226
+ "page[size]" => 30,
227
+ "include" => include.join(","),
179
228
  }
180
229
  ).call
181
230
  end
@@ -185,11 +234,11 @@ module Teamtailor
185
234
  base_url: base_url,
186
235
  api_token: api_token,
187
236
  api_version: api_version,
188
- path: '/v1/partner-results',
237
+ path: "/v1/partner-results",
189
238
  params: {
190
- 'page[number]' => page,
191
- 'page[size]' => 30,
192
- 'include' => include.join(',')
239
+ "page[number]" => page,
240
+ "page[size]" => 30,
241
+ "include" => include.join(","),
193
242
  }
194
243
  ).call
195
244
  end
@@ -199,11 +248,11 @@ module Teamtailor
199
248
  base_url: base_url,
200
249
  api_token: api_token,
201
250
  api_version: api_version,
202
- path: '/v1/requisitions',
251
+ path: "/v1/requisitions",
203
252
  params: {
204
- 'page[number]' => page,
205
- 'page[size]' => 30,
206
- 'include' => include.join(',')
253
+ "page[number]" => page,
254
+ "page[size]" => 30,
255
+ "include" => include.join(","),
207
256
  }
208
257
  ).call
209
258
  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,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
@@ -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 CustomField < 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 CustomFieldValue < 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 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
@@ -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 PartnerResult < Record
7
7
  def id
8
- data.dig('id')
8
+ data.dig("id")
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 Referral < 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 RejectReason < 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 Requisition < 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 RequisitionStepVerdict < 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 Stage < Record
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "teamtailor/record"
4
+
5
+ module Teamtailor
6
+ class Upload < 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 User < Record
@@ -1,20 +1,21 @@
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'
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'
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
+ require "teamtailor/parser/upload"
18
19
 
19
20
  module Teamtailor
20
21
  class Parser
@@ -24,25 +25,27 @@ module Teamtailor
24
25
 
25
26
  def parse
26
27
  data.map do |record|
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-values' then Teamtailor::CustomFieldValue.new(record, included)
39
- when 'referrals' then Teamtailor::Referral.new(record, included)
40
- when 'partner-results' then Teamtailor::PartnerResult.new(record, included)
41
- when 'requisitions' then Teamtailor::Requisition.new(record, included)
42
- when 'requisition-step-verdicts' then Teamtailor::RequisitionStepVerdict.new(record, included)
28
+ case record&.dig("type")
29
+ when "candidates" then Teamtailor::Candidate.new(record, included)
30
+ when "jobs" then Teamtailor::Job.new(record, included)
31
+ when "users" then Teamtailor::User.new(record, included)
32
+ when "job-applications" then Teamtailor::JobApplication.new(record, included)
33
+ when "companies" then Teamtailor::Company.new(record, included)
34
+ when "stages" then Teamtailor::Stage.new(record, included)
35
+ when "reject-reasons" then Teamtailor::RejectReason.new(record, included)
36
+ when "departments" then Teamtailor::Department.new(record, included)
37
+ when "locations" then Teamtailor::Location.new(record, included)
38
+ when "custom-fields" then Teamtailor::CustomField.new(record, included)
39
+ when "custom-field-selects" then Teamtailor::CustomField.new(record, included)
40
+ when "custom-field-values" then Teamtailor::CustomFieldValue.new(record, included)
41
+ when "referrals" then Teamtailor::Referral.new(record, included)
42
+ when "partner-results" then Teamtailor::PartnerResult.new(record, included)
43
+ when "requisitions" then Teamtailor::Requisition.new(record, included)
44
+ when "requisition-step-verdicts" then Teamtailor::RequisitionStepVerdict.new(record, included)
45
+ when "uploads" then Teamtailor::Upload.new(record, included)
43
46
 
44
47
  else
45
- raise Teamtailor::UnknownResponseTypeError, record&.dig('type')
48
+ raise Teamtailor::UnknownResponseTypeError, record&.dig("type")
46
49
  end
47
50
  end
48
51
  end
@@ -56,11 +59,11 @@ module Teamtailor
56
59
  end
57
60
 
58
61
  def data
59
- [payload&.dig('data')].flatten
62
+ [payload&.dig("data")].flatten
60
63
  end
61
64
 
62
65
  def included
63
- payload&.dig('included')
66
+ payload&.dig("included")
64
67
  end
65
68
  end
66
69
  end
@@ -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
@@ -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['id']) && k['type'] == record_type
19
+ record_ids.include?(k["id"]) && k["type"] == record_type
20
20
  end
21
21
 
22
- Teamtailor::Parser.parse({ 'data' => record_json, 'included' => included })
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, 'data')].flatten.compact
29
- data.map { |row| row['id'] }
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, 'data')].flatten
34
- data.map { |row| row['type'] }.first
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
@@ -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.3.0'
4
+ VERSION = "0.4.0"
5
5
  end
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
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.3.0
4
+ version: 0.4.0
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-06-30 00:00:00.000000000 Z
11
+ date: 2021-09-06 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
@@ -75,20 +78,21 @@ files:
75
78
  - lib/teamtailor/parser/requisition.rb
76
79
  - lib/teamtailor/parser/requisition_step_verdict.rb
77
80
  - lib/teamtailor/parser/stage.rb
81
+ - lib/teamtailor/parser/upload.rb
78
82
  - lib/teamtailor/parser/user.rb
79
83
  - lib/teamtailor/record.rb
80
84
  - lib/teamtailor/relationship.rb
81
85
  - lib/teamtailor/request.rb
82
86
  - lib/teamtailor/version.rb
83
87
  - teamtailor.gemspec
84
- homepage: https://github.com/bzf/teamtailor-gem
88
+ homepage: https://github.com/teamtailor/teamtailor-gem
85
89
  licenses:
86
90
  - MIT
87
91
  metadata:
88
- homepage_uri: https://github.com/bzf/teamtailor-gem
92
+ homepage_uri: https://github.com/teamtailor/teamtailor-gem
89
93
  source_code_uri: https://github.com/bzf/teamtailor-rb
90
- changelog_uri: https://github.com/bzf/teamtailor-rb/master/CHANGELOG.md
91
- post_install_message:
94
+ changelog_uri: https://github.com/bzf/teamtailor-rb/main/CHANGELOG.md
95
+ post_install_message:
92
96
  rdoc_options: []
93
97
  require_paths:
94
98
  - lib
@@ -103,8 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
107
  - !ruby/object:Gem::Version
104
108
  version: '0'
105
109
  requirements: []
106
- rubygems_version: 3.1.2
107
- signing_key:
110
+ rubygems_version: 3.1.4
111
+ signing_key:
108
112
  specification_version: 4
109
113
  summary: Library for interacting with the Teamtailor API
110
114
  test_files: []