teamtailor 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/teamtailor/client.rb +9 -6
- data/lib/teamtailor/error.rb +2 -0
- data/lib/teamtailor/parser/candidate.rb +8 -16
- data/lib/teamtailor/parser/job.rb +7 -19
- data/lib/teamtailor/parser/user.rb +7 -15
- data/lib/teamtailor/parser.rb +9 -4
- data/lib/teamtailor/record.rb +30 -0
- data/lib/teamtailor/relationship.rb +37 -0
- data/lib/teamtailor/version.rb +1 -1
- data/teamtailor.gemspec +2 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca640f45eb147f4845e8f8416728ca7037d827c1e4bcb297cb7f02e15182805a
|
4
|
+
data.tar.gz: 89dacf02df2d3e7030ae54a700a7f85e5394930d5e773cc586ba639d4ab176fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff38baf2344ed08916fc5f8e46f3a58ba19a7fceb335d8abd73ab8a155a769c36a8ee18ec9d94044ffe0e64a61d357680e5a933791743d4831e5b960e61f1070
|
7
|
+
data.tar.gz: b1cf2365d600ea53d6998faef1ef9d4ac884c63f109b16d91af58b2166e6fce817f316d53c7e026179f0ff16ef14c5695b32f9982548b8464bcc1988c6cf89e3
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/lib/teamtailor/client.rb
CHANGED
@@ -10,7 +10,7 @@ module Teamtailor
|
|
10
10
|
@api_version = api_version
|
11
11
|
end
|
12
12
|
|
13
|
-
def candidates(page: 1)
|
13
|
+
def candidates(page: 1, include: [])
|
14
14
|
Teamtailor::Request.new(
|
15
15
|
base_url: base_url,
|
16
16
|
api_token: api_token,
|
@@ -18,12 +18,13 @@ module Teamtailor
|
|
18
18
|
path: '/v1/candidates',
|
19
19
|
params: {
|
20
20
|
'page[number]' => page,
|
21
|
-
'page[size]' => 30
|
21
|
+
'page[size]' => 30,
|
22
|
+
'include' => include.join(',')
|
22
23
|
}
|
23
24
|
).call
|
24
25
|
end
|
25
26
|
|
26
|
-
def jobs(page: 1)
|
27
|
+
def jobs(page: 1, include: [])
|
27
28
|
Teamtailor::Request.new(
|
28
29
|
base_url: base_url,
|
29
30
|
api_token: api_token,
|
@@ -31,12 +32,13 @@ module Teamtailor
|
|
31
32
|
path: '/v1/jobs',
|
32
33
|
params: {
|
33
34
|
'page[number]' => page,
|
34
|
-
'page[size]' => 30
|
35
|
+
'page[size]' => 30,
|
36
|
+
'include' => include.join(',')
|
35
37
|
}
|
36
38
|
).call
|
37
39
|
end
|
38
40
|
|
39
|
-
def users(page: 1)
|
41
|
+
def users(page: 1, include: [])
|
40
42
|
Teamtailor::Request.new(
|
41
43
|
base_url: base_url,
|
42
44
|
api_token: api_token,
|
@@ -44,7 +46,8 @@ module Teamtailor
|
|
44
46
|
path: '/v1/users',
|
45
47
|
params: {
|
46
48
|
'page[number]' => page,
|
47
|
-
'page[size]' => 30
|
49
|
+
'page[size]' => 30,
|
50
|
+
'include' => include.join(',')
|
48
51
|
}
|
49
52
|
).call
|
50
53
|
end
|
data/lib/teamtailor/error.rb
CHANGED
@@ -1,31 +1,23 @@
|
|
1
|
-
|
2
|
-
class Candidate
|
3
|
-
def initialize(payload)
|
4
|
-
@payload = payload
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
3
|
+
require 'teamtailor/record'
|
4
|
+
|
5
|
+
module Teamtailor
|
6
|
+
class Candidate < Record
|
7
7
|
def self.deserialize(value)
|
8
8
|
new(value)
|
9
9
|
end
|
10
10
|
|
11
11
|
def serialize
|
12
|
-
|
12
|
+
data
|
13
13
|
end
|
14
14
|
|
15
15
|
def id
|
16
|
-
|
16
|
+
data.dig('id').to_i
|
17
17
|
end
|
18
18
|
|
19
19
|
def connected?
|
20
|
-
|
20
|
+
data.dig('attributes', 'connected')
|
21
21
|
end
|
22
|
-
|
23
|
-
def method_missing(m)
|
24
|
-
payload.dig('attributes', m.to_s.gsub('_', '-'))
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :payload
|
30
22
|
end
|
31
23
|
end
|
@@ -1,31 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
@payload = payload
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'teamtailor/record'
|
6
4
|
|
5
|
+
module Teamtailor
|
6
|
+
class Job < Record
|
7
7
|
def self.deserialize(value)
|
8
8
|
new(value)
|
9
9
|
end
|
10
10
|
|
11
11
|
def serialize
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def id
|
16
|
-
payload.dig('id').to_i
|
12
|
+
data
|
17
13
|
end
|
18
14
|
|
19
15
|
def careersite_job_url
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def method_missing(m)
|
24
|
-
payload.dig('attributes', m.to_s.gsub('_', '-'))
|
16
|
+
data.dig('links', 'careersite-job-url')
|
25
17
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :payload
|
30
18
|
end
|
31
19
|
end
|
@@ -1,27 +1,19 @@
|
|
1
|
-
|
2
|
-
class User
|
3
|
-
def initialize(payload)
|
4
|
-
@payload = payload
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
3
|
+
require 'teamtailor/record'
|
4
|
+
|
5
|
+
module Teamtailor
|
6
|
+
class User < Record
|
7
7
|
def self.deserialize(value)
|
8
8
|
new(value)
|
9
9
|
end
|
10
10
|
|
11
11
|
def serialize
|
12
|
-
|
12
|
+
data
|
13
13
|
end
|
14
14
|
|
15
15
|
def id
|
16
|
-
|
16
|
+
data.dig('id').to_i
|
17
17
|
end
|
18
|
-
|
19
|
-
def method_missing(m)
|
20
|
-
payload.dig('attributes', m.to_s.gsub('_', '-'))
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :payload
|
26
18
|
end
|
27
19
|
end
|
data/lib/teamtailor/parser.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'teamtailor/relationship'
|
3
4
|
require 'teamtailor/parser/candidate'
|
4
5
|
require 'teamtailor/parser/job'
|
5
6
|
require 'teamtailor/parser/user'
|
@@ -13,12 +14,12 @@ module Teamtailor
|
|
13
14
|
def parse
|
14
15
|
data.map do |record|
|
15
16
|
case record&.dig('type')
|
16
|
-
when 'candidates' then Teamtailor::Candidate.new(record)
|
17
|
-
when 'jobs' then Teamtailor::Job.new(record)
|
18
|
-
when 'users' then Teamtailor::User.new(record)
|
17
|
+
when 'candidates' then Teamtailor::Candidate.new(record, included)
|
18
|
+
when 'jobs' then Teamtailor::Job.new(record, included)
|
19
|
+
when 'users' then Teamtailor::User.new(record, included)
|
19
20
|
|
20
21
|
else
|
21
|
-
raise Teamtailor::UnknownResponseTypeError
|
22
|
+
raise Teamtailor::UnknownResponseTypeError, record&.dig('type')
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -34,5 +35,9 @@ module Teamtailor
|
|
34
35
|
def data
|
35
36
|
[payload&.dig('data')].flatten
|
36
37
|
end
|
38
|
+
|
39
|
+
def included
|
40
|
+
payload&.dig('included')
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Teamtailor
|
2
|
+
class Record
|
3
|
+
def initialize(data, included = {})
|
4
|
+
@data = data
|
5
|
+
@included = included
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(m)
|
9
|
+
if m == :id
|
10
|
+
data.dig('id').to_i
|
11
|
+
elsif relationship_keys.include?(m.to_s.gsub('_', '-'))
|
12
|
+
build_relationship(m.to_s.gsub('_', '-'))
|
13
|
+
else
|
14
|
+
data.dig('attributes', m.to_s.gsub('_', '-'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :data, :included
|
21
|
+
|
22
|
+
def build_relationship(name)
|
23
|
+
Teamtailor::Relationship.new(name, data.dig('relationships'), included)
|
24
|
+
end
|
25
|
+
|
26
|
+
def relationship_keys
|
27
|
+
data.dig('relationships')&.keys || {}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Teamtailor
|
4
|
+
class Relationship
|
5
|
+
def initialize(relation_name, relationships = {}, included = {})
|
6
|
+
@relation_name = relation_name
|
7
|
+
@relationships = relationships
|
8
|
+
@included = included
|
9
|
+
end
|
10
|
+
|
11
|
+
def loaded?
|
12
|
+
!record_id.nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def record
|
16
|
+
raise Teamtailor::UnloadedRelationError unless loaded?
|
17
|
+
|
18
|
+
record_json = included.find do |k|
|
19
|
+
k['id'] == record_id && k['type'] == record_type
|
20
|
+
end
|
21
|
+
|
22
|
+
Teamtailor::Parser.parse({ 'data' => record_json }).first
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def record_id
|
28
|
+
relationships&.dig(relation_name, 'data', 'id')
|
29
|
+
end
|
30
|
+
|
31
|
+
def record_type
|
32
|
+
relationships&.dig(relation_name, 'data', 'type')
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :relation_name, :relationships, :included
|
36
|
+
end
|
37
|
+
end
|
data/lib/teamtailor/version.rb
CHANGED
data/teamtailor.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
15
15
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
-
spec.metadata['source_code_uri'] = 'https://github.com/bzf/teamtailor-
|
18
|
-
spec.metadata['changelog_uri'] = 'https://github.com/bzf/teamtailor-
|
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'
|
19
19
|
|
20
20
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
21
21
|
spec.add_dependency 'typhoeus', '~> 1.3.1'
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Ligné
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
50
50
|
- ".travis.yml"
|
51
|
+
- CHANGELOG.md
|
51
52
|
- Gemfile
|
52
53
|
- Gemfile.lock
|
53
54
|
- LICENSE.txt
|
@@ -63,6 +64,8 @@ files:
|
|
63
64
|
- lib/teamtailor/parser/candidate.rb
|
64
65
|
- lib/teamtailor/parser/job.rb
|
65
66
|
- lib/teamtailor/parser/user.rb
|
67
|
+
- lib/teamtailor/record.rb
|
68
|
+
- lib/teamtailor/relationship.rb
|
66
69
|
- lib/teamtailor/request.rb
|
67
70
|
- lib/teamtailor/version.rb
|
68
71
|
- teamtailor.gemspec
|
@@ -71,8 +74,8 @@ licenses:
|
|
71
74
|
- MIT
|
72
75
|
metadata:
|
73
76
|
homepage_uri: https://github.com/bzf/teamtailor-gem
|
74
|
-
source_code_uri: https://github.com/bzf/teamtailor-
|
75
|
-
changelog_uri: https://github.com/bzf/teamtailor-
|
77
|
+
source_code_uri: https://github.com/bzf/teamtailor-rb
|
78
|
+
changelog_uri: https://github.com/bzf/teamtailor-rb/master/CHANGELOG.md
|
76
79
|
post_install_message:
|
77
80
|
rdoc_options: []
|
78
81
|
require_paths:
|