teamtailor 0.1.0 → 0.2.4
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 +4 -4
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +1 -1
- data/README.md +35 -0
- data/lib/teamtailor/client.rb +91 -6
- data/lib/teamtailor/error.rb +2 -0
- data/lib/teamtailor/parser.rb +20 -4
- data/lib/teamtailor/parser/candidate.rb +5 -25
- data/lib/teamtailor/parser/company.rb +11 -0
- data/lib/teamtailor/parser/department.rb +8 -0
- data/lib/teamtailor/parser/job.rb +5 -25
- data/lib/teamtailor/parser/job_application.rb +8 -0
- data/lib/teamtailor/parser/location.rb +8 -0
- data/lib/teamtailor/parser/reject_reason.rb +8 -0
- data/lib/teamtailor/parser/stage.rb +8 -0
- data/lib/teamtailor/parser/user.rb +4 -23
- data/lib/teamtailor/record.rb +44 -0
- data/lib/teamtailor/relationship.rb +37 -0
- data/lib/teamtailor/version.rb +1 -1
- data/teamtailor.gemspec +2 -2
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d5517a7804ca23cfab37e186ce9a3a8e6fd834d19142f1639bd43a713f0cad
|
4
|
+
data.tar.gz: 1ce95b3c0f5734a5a75d7e735a2938396e66b1c6a66ecb636f11951e99cb16b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: befca1d520b6e38edde324a89a5ed7e2e45df37a08037c2ea466703e558d3a88c4401878c33e3021b38408ea5567616c5d67cc5ebeaac60eeaff289b29b6954c
|
7
|
+
data.tar.gz: c03ff827ea515229c96f4380a3aea14e5989060ffa1bf9c8146149135475040591179aad9444aee343bb81903a0f119dba9b5302589dde5dded132865c981654
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## v0.2.4 - 2020-04-07
|
4
|
+
|
5
|
+
- Add `Teamtailor::Location` and `Client#locations`
|
6
|
+
- Add `Teamtailor::Department` and `Client#departments`
|
7
|
+
- Add `Teamtailor::RejectReason` and `Client#reject_reasons`
|
8
|
+
- Add `Teamtailor::Stage` and `Client#stages` for fetching it (`2179b1`)
|
9
|
+
|
10
|
+
## v0.2.3 - 2020-04-06
|
11
|
+
|
12
|
+
- Add `Teamtailor::Company` and `Client#company` for fetching it (`05dde0`)
|
13
|
+
|
14
|
+
## v0.2.2 - 2020-03-31
|
15
|
+
|
16
|
+
- Move serialization logic in the `Teamtailor::Record` base class (`9ec63a0`)
|
17
|
+
- Fix serializing/deserializing loaded relationships for
|
18
|
+
`Teamtailor::JobApplication` (`428e2d`)
|
19
|
+
|
20
|
+
## v0.2.1 - 2020-03-31
|
21
|
+
|
22
|
+
- Add `Teamtailor::JobApplication` and `Client#job_applications` (`062fa7`)
|
23
|
+
|
24
|
+
## v0.2.0 - 2020-03-31
|
25
|
+
|
26
|
+
- Add support for accessing relationships on records (`1218aa`)
|
27
|
+
- Add support for including relationships when querying the API (`90f25d`)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -65,6 +65,41 @@ irb(main):041:0> jobs.map &:title
|
|
65
65
|
=> ["EmberJS Developer", "Ruby on Rails developer"]
|
66
66
|
```
|
67
67
|
|
68
|
+
### Relationships
|
69
|
+
|
70
|
+
The API allows you to include associated data when requesting data to help
|
71
|
+
you load associations without having to make any additional requests.
|
72
|
+
To do this, you can pass what you want to include when making the request.
|
73
|
+
|
74
|
+
To fetch jobs with all associated `user`s loaded, you can call `Client#jobs`
|
75
|
+
like this:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
irb(main):006:0> page_result = @client.jobs(page: 1, include: [:user])
|
79
|
+
irb(main):007:0> page_result.records.first.user.record.login_email
|
80
|
+
=> "admin@teamtailor.localhost"
|
81
|
+
```
|
82
|
+
|
83
|
+
If you try to access a relationship, without having included it when loading it
|
84
|
+
from the server, it'll raise a `Teamtailor::UnloadedRelationError`:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
irb(main):010:0> page_result = @client.jobs(page: 1, include: [])
|
88
|
+
irb(main):011:0> page_result.records.first.user.record
|
89
|
+
Traceback (most recent call last):
|
90
|
+
...
|
91
|
+
1: from ~/teamtailor/lib/teamtailor/relationship.rb:16:in `record'
|
92
|
+
Teamtailor::UnloadedRelationError (Teamtailor::UnloadedRelationError)
|
93
|
+
```
|
94
|
+
|
95
|
+
To check if a relation has been loaded or not you can use the
|
96
|
+
`Relationship#loaded?` method to check before calling it:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
irb(main):012:0> page_result = @client.jobs(page: 1, include: [:user])
|
100
|
+
irb(main):013:0> page_result.records.first.user.loaded?
|
101
|
+
=> true
|
102
|
+
```
|
68
103
|
|
69
104
|
## Development
|
70
105
|
|
data/lib/teamtailor/client.rb
CHANGED
@@ -10,7 +10,19 @@ module Teamtailor
|
|
10
10
|
@api_version = api_version
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def company(include: [])
|
14
|
+
Teamtailor::Request.new(
|
15
|
+
base_url: base_url,
|
16
|
+
api_token: api_token,
|
17
|
+
api_version: api_version,
|
18
|
+
path: '/v1/company',
|
19
|
+
params: {
|
20
|
+
'include' => include.join(',')
|
21
|
+
}
|
22
|
+
).call
|
23
|
+
end
|
24
|
+
|
25
|
+
def candidates(page: 1, include: [])
|
14
26
|
Teamtailor::Request.new(
|
15
27
|
base_url: base_url,
|
16
28
|
api_token: api_token,
|
@@ -18,12 +30,13 @@ module Teamtailor
|
|
18
30
|
path: '/v1/candidates',
|
19
31
|
params: {
|
20
32
|
'page[number]' => page,
|
21
|
-
'page[size]' => 30
|
33
|
+
'page[size]' => 30,
|
34
|
+
'include' => include.join(',')
|
22
35
|
}
|
23
36
|
).call
|
24
37
|
end
|
25
38
|
|
26
|
-
def jobs(page: 1)
|
39
|
+
def jobs(page: 1, include: [])
|
27
40
|
Teamtailor::Request.new(
|
28
41
|
base_url: base_url,
|
29
42
|
api_token: api_token,
|
@@ -31,12 +44,27 @@ module Teamtailor
|
|
31
44
|
path: '/v1/jobs',
|
32
45
|
params: {
|
33
46
|
'page[number]' => page,
|
34
|
-
'page[size]' => 30
|
47
|
+
'page[size]' => 30,
|
48
|
+
'include' => include.join(',')
|
49
|
+
}
|
50
|
+
).call
|
51
|
+
end
|
52
|
+
|
53
|
+
def job_applications(page: 1, include: [])
|
54
|
+
Teamtailor::Request.new(
|
55
|
+
base_url: base_url,
|
56
|
+
api_token: api_token,
|
57
|
+
api_version: api_version,
|
58
|
+
path: '/v1/job-applications',
|
59
|
+
params: {
|
60
|
+
'page[number]' => page,
|
61
|
+
'page[size]' => 30,
|
62
|
+
'include' => include.join(',')
|
35
63
|
}
|
36
64
|
).call
|
37
65
|
end
|
38
66
|
|
39
|
-
def users(page: 1)
|
67
|
+
def users(page: 1, include: [])
|
40
68
|
Teamtailor::Request.new(
|
41
69
|
base_url: base_url,
|
42
70
|
api_token: api_token,
|
@@ -44,7 +72,64 @@ module Teamtailor
|
|
44
72
|
path: '/v1/users',
|
45
73
|
params: {
|
46
74
|
'page[number]' => page,
|
47
|
-
'page[size]' => 30
|
75
|
+
'page[size]' => 30,
|
76
|
+
'include' => include.join(',')
|
77
|
+
}
|
78
|
+
).call
|
79
|
+
end
|
80
|
+
|
81
|
+
def stages(page: 1, include: [])
|
82
|
+
Teamtailor::Request.new(
|
83
|
+
base_url: base_url,
|
84
|
+
api_token: api_token,
|
85
|
+
api_version: api_version,
|
86
|
+
path: '/v1/stages',
|
87
|
+
params: {
|
88
|
+
'page[number]' => page,
|
89
|
+
'page[size]' => 30,
|
90
|
+
'include' => include.join(',')
|
91
|
+
}
|
92
|
+
).call
|
93
|
+
end
|
94
|
+
|
95
|
+
def reject_reasons(page: 1, include: [])
|
96
|
+
Teamtailor::Request.new(
|
97
|
+
base_url: base_url,
|
98
|
+
api_token: api_token,
|
99
|
+
api_version: api_version,
|
100
|
+
path: '/v1/reject-reasons',
|
101
|
+
params: {
|
102
|
+
'page[number]' => page,
|
103
|
+
'page[size]' => 30,
|
104
|
+
'include' => include.join(',')
|
105
|
+
}
|
106
|
+
).call
|
107
|
+
end
|
108
|
+
|
109
|
+
def departments(page: 1, include: [])
|
110
|
+
Teamtailor::Request.new(
|
111
|
+
base_url: base_url,
|
112
|
+
api_token: api_token,
|
113
|
+
api_version: api_version,
|
114
|
+
path: '/v1/departments',
|
115
|
+
params: {
|
116
|
+
'page[number]' => page,
|
117
|
+
'page[size]' => 30,
|
118
|
+
'include' => include.join(',')
|
119
|
+
}
|
120
|
+
).call
|
121
|
+
end
|
122
|
+
|
123
|
+
def locations(page: 1, include: [])
|
124
|
+
Teamtailor::Request.new(
|
125
|
+
base_url: base_url,
|
126
|
+
api_token: api_token,
|
127
|
+
api_version: api_version,
|
128
|
+
path: '/v1/locations',
|
129
|
+
params: {
|
130
|
+
'page[number]' => page,
|
131
|
+
'page[size]' => 30,
|
132
|
+
'include' => include.join(',')
|
48
133
|
}
|
49
134
|
).call
|
50
135
|
end
|
data/lib/teamtailor/error.rb
CHANGED
data/lib/teamtailor/parser.rb
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
require 'teamtailor/parser/candidate'
|
4
4
|
require 'teamtailor/parser/job'
|
5
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'
|
6
12
|
|
7
13
|
module Teamtailor
|
8
14
|
class Parser
|
@@ -13,12 +19,18 @@ module Teamtailor
|
|
13
19
|
def parse
|
14
20
|
data.map do |record|
|
15
21
|
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)
|
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)
|
19
31
|
|
20
32
|
else
|
21
|
-
raise Teamtailor::UnknownResponseTypeError
|
33
|
+
raise Teamtailor::UnknownResponseTypeError, record&.dig('type')
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
@@ -34,5 +46,9 @@ module Teamtailor
|
|
34
46
|
def data
|
35
47
|
[payload&.dig('data')].flatten
|
36
48
|
end
|
49
|
+
|
50
|
+
def included
|
51
|
+
payload&.dig('included')
|
52
|
+
end
|
37
53
|
end
|
38
54
|
end
|
@@ -1,31 +1,11 @@
|
|
1
|
-
|
2
|
-
class Candidate
|
3
|
-
def initialize(payload)
|
4
|
-
@payload = payload
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.deserialize(value)
|
8
|
-
new(value)
|
9
|
-
end
|
10
|
-
|
11
|
-
def serialize
|
12
|
-
payload
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
14
2
|
|
15
|
-
|
16
|
-
payload.dig('id').to_i
|
17
|
-
end
|
3
|
+
require 'teamtailor/record'
|
18
4
|
|
5
|
+
module Teamtailor
|
6
|
+
class Candidate < Record
|
19
7
|
def connected?
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def method_missing(m)
|
24
|
-
payload.dig('attributes', m.to_s.gsub('_', '-'))
|
8
|
+
data.dig('attributes', 'connected')
|
25
9
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :payload
|
30
10
|
end
|
31
11
|
end
|
@@ -1,31 +1,11 @@
|
|
1
|
-
|
2
|
-
class Job
|
3
|
-
def initialize(payload)
|
4
|
-
@payload = payload
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.deserialize(value)
|
8
|
-
new(value)
|
9
|
-
end
|
10
|
-
|
11
|
-
def serialize
|
12
|
-
payload
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
14
2
|
|
15
|
-
|
16
|
-
payload.dig('id').to_i
|
17
|
-
end
|
3
|
+
require 'teamtailor/record'
|
18
4
|
|
5
|
+
module Teamtailor
|
6
|
+
class Job < Record
|
19
7
|
def careersite_job_url
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def method_missing(m)
|
24
|
-
payload.dig('attributes', m.to_s.gsub('_', '-'))
|
8
|
+
data.dig('links', 'careersite-job-url')
|
25
9
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :payload
|
30
10
|
end
|
31
11
|
end
|
@@ -1,27 +1,8 @@
|
|
1
|
-
|
2
|
-
class User
|
3
|
-
def initialize(payload)
|
4
|
-
@payload = payload
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.deserialize(value)
|
8
|
-
new(value)
|
9
|
-
end
|
10
|
-
|
11
|
-
def serialize
|
12
|
-
payload
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
14
2
|
|
15
|
-
|
16
|
-
payload.dig('id').to_i
|
17
|
-
end
|
3
|
+
require 'teamtailor/record'
|
18
4
|
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :payload
|
5
|
+
module Teamtailor
|
6
|
+
class User < Record
|
26
7
|
end
|
27
8
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'teamtailor/relationship'
|
2
|
+
|
3
|
+
module Teamtailor
|
4
|
+
class Record
|
5
|
+
def initialize(data, included = {})
|
6
|
+
@data = data
|
7
|
+
@included = included
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.deserialize(value)
|
11
|
+
payload = JSON.parse value
|
12
|
+
new(payload['data'], payload['included'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def serialize
|
16
|
+
{
|
17
|
+
data: data,
|
18
|
+
included: included
|
19
|
+
}.to_json
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(m)
|
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('_', '-'))
|
27
|
+
else
|
28
|
+
data.dig('attributes', m.to_s.gsub('_', '-'))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :data, :included
|
35
|
+
|
36
|
+
def build_relationship(name)
|
37
|
+
Teamtailor::Relationship.new(name, data.dig('relationships'), included)
|
38
|
+
end
|
39
|
+
|
40
|
+
def relationship_keys
|
41
|
+
data.dig('relationships')&.keys || {}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.4
|
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-
|
11
|
+
date: 2020-04-07 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
|
@@ -61,8 +62,16 @@ files:
|
|
61
62
|
- lib/teamtailor/page_result.rb
|
62
63
|
- lib/teamtailor/parser.rb
|
63
64
|
- lib/teamtailor/parser/candidate.rb
|
65
|
+
- lib/teamtailor/parser/company.rb
|
66
|
+
- lib/teamtailor/parser/department.rb
|
64
67
|
- lib/teamtailor/parser/job.rb
|
68
|
+
- lib/teamtailor/parser/job_application.rb
|
69
|
+
- lib/teamtailor/parser/location.rb
|
70
|
+
- lib/teamtailor/parser/reject_reason.rb
|
71
|
+
- lib/teamtailor/parser/stage.rb
|
65
72
|
- lib/teamtailor/parser/user.rb
|
73
|
+
- lib/teamtailor/record.rb
|
74
|
+
- lib/teamtailor/relationship.rb
|
66
75
|
- lib/teamtailor/request.rb
|
67
76
|
- lib/teamtailor/version.rb
|
68
77
|
- teamtailor.gemspec
|
@@ -71,8 +80,8 @@ licenses:
|
|
71
80
|
- MIT
|
72
81
|
metadata:
|
73
82
|
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-
|
83
|
+
source_code_uri: https://github.com/bzf/teamtailor-rb
|
84
|
+
changelog_uri: https://github.com/bzf/teamtailor-rb/master/CHANGELOG.md
|
76
85
|
post_install_message:
|
77
86
|
rdoc_options: []
|
78
87
|
require_paths:
|