smartrecruiters 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 +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +20 -1
- data/lib/smartrecruiters/client.rb +26 -2
- data/lib/smartrecruiters/collection.rb +15 -7
- data/lib/smartrecruiters/objects/callbacks_log.rb +6 -0
- data/lib/smartrecruiters/objects/webhook.rb +6 -0
- data/lib/smartrecruiters/resources/access_groups.rb +11 -1
- data/lib/smartrecruiters/resources/reports.rb +17 -0
- data/lib/smartrecruiters/resources/webhooks.rb +41 -0
- data/lib/smartrecruiters/version.rb +1 -1
- data/lib/smartrecruiters.rb +3 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30883b1307e170148c8183e487414ec7cee6bf1072a6c9ad3bac5132f97e647b
|
4
|
+
data.tar.gz: 6d0bd970d76244e299beea567b59e7ee6177d33a7562f6a3e2a65bdd955e2035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dbca1f2930a6dc92ebb19be2aa3f6b9e028ad1280683bed78f77b6446db653ec803cfe6411dd4e3e20185d5c69aa423ffb24cde9a08f722e5711daa0ad5b4e8
|
7
|
+
data.tar.gz: 69439dcf5fa3791ca0f93fcc69d58ea889cb284f5f9c691fe18c7d6c9ba9cc56f5167cc859dffce01dbdc0076239a8f0ef56984a27edf4f08a4cf7f8bae8325a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.2.0](https://www.github.com/davejcameron/smartrecruiters/compare/v0.1.0...v0.2.0) (2021-10-13)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Add access groups routes ([#7](https://www.github.com/davejcameron/smartrecruiters/issues/7)) ([81d6a34](https://www.github.com/davejcameron/smartrecruiters/commit/81d6a34e4466309f493f65aeeab6173d610b8dfb))
|
9
|
+
* add reports apis ([#5](https://www.github.com/davejcameron/smartrecruiters/issues/5)) ([343814b](https://www.github.com/davejcameron/smartrecruiters/commit/343814b8d1fd0d14c062030b958d67b307204c69))
|
10
|
+
* Add timeout and retry ([2d0d8f2](https://www.github.com/davejcameron/smartrecruiters/commit/2d0d8f23c57d522ea657e32b06b3da40a1822930))
|
11
|
+
* Add webhooks routes ([#6](https://www.github.com/davejcameron/smartrecruiters/issues/6)) ([b37bcda](https://www.github.com/davejcameron/smartrecruiters/commit/b37bcda13d43f96bf6ac4fac285dd87200b3a877))
|
12
|
+
|
3
13
|
## 0.1.0 (2021-10-09)
|
4
14
|
|
5
15
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,9 @@ client = SmartRecruiters::Client.new(api_key: ENV["SMARTRECRUITERS_API_KEY"], en
|
|
37
37
|
### Access Groups
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
client.access_groups
|
40
|
+
client.access_groups.list
|
41
|
+
client.access_groups.assign_users(group_id: "id", user_ids: ["user_id"])
|
42
|
+
client.access_groups.remove_user(group_id: "id", user_id: "id")
|
41
43
|
```
|
42
44
|
|
43
45
|
### Candidates
|
@@ -93,6 +95,10 @@ client.offers.retrieve_offers(candidate_id: "id", job_id: "id")
|
|
93
95
|
```ruby
|
94
96
|
client.reports.list
|
95
97
|
client.reports.retrieve(report_id: "id")
|
98
|
+
client.reports.retrieve_files(report_id: "id")
|
99
|
+
client.reports.generate_report(report_id: "id")
|
100
|
+
client.reports.retrieve_recent_file(report_id: "id")
|
101
|
+
client.reports.retrieve_recent_file_data(report_id: "id")
|
96
102
|
```
|
97
103
|
|
98
104
|
### Reviews
|
@@ -123,6 +129,19 @@ client.users.activation_email(user_id: "id")
|
|
123
129
|
client.users.deactivate(user_id: "id")
|
124
130
|
```
|
125
131
|
|
132
|
+
### Webhooks
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
client.webhooks.list
|
136
|
+
client.webhooks.create({})
|
137
|
+
client.webhooks.retrieve(webhook_id: "id")
|
138
|
+
client.webhooks.delete(webhook_id: "id")
|
139
|
+
client.webhooks.activate(webhook_id: "id")
|
140
|
+
client.webhooks.callbacks_log(webhook_id: "id")
|
141
|
+
client.webhooks.generate_secret(webhook_id: "id")
|
142
|
+
client.webhooks.retrieve_secret(webhook_id: "id")
|
143
|
+
```
|
144
|
+
|
126
145
|
## Development
|
127
146
|
|
128
147
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -2,9 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday_middleware'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
module SmartRecruiters
|
7
8
|
class Client
|
9
|
+
SMART_RECRUITERS_TIMEOUT = 128
|
10
|
+
SMART_RECRUITERS_RETRIES = 3
|
11
|
+
|
8
12
|
SMART_RECRUITERS_BASE_PATHS = {
|
9
13
|
'production' => 'https://api.smartrecruiters.com',
|
10
14
|
'sandbox' => 'https://api.sandbox.smartrecruiters.com'
|
@@ -12,11 +16,16 @@ module SmartRecruiters
|
|
12
16
|
|
13
17
|
attr_reader :api_key, :adapter
|
14
18
|
|
15
|
-
def initialize(
|
19
|
+
def initialize(
|
20
|
+
api_key:,
|
21
|
+
adapter: Faraday.default_adapter,
|
22
|
+
stubs: nil,
|
23
|
+
environment: 'production'
|
24
|
+
)
|
16
25
|
@api_key = api_key
|
17
|
-
@adapter = adapter
|
18
26
|
@environment = environment
|
19
27
|
|
28
|
+
@adapter = adapter
|
20
29
|
@stubs = stubs
|
21
30
|
end
|
22
31
|
|
@@ -52,16 +61,31 @@ module SmartRecruiters
|
|
52
61
|
UsersResource.new(self)
|
53
62
|
end
|
54
63
|
|
64
|
+
def webhooks
|
65
|
+
WebhooksResource.new(self)
|
66
|
+
end
|
67
|
+
|
55
68
|
def connection
|
56
69
|
@connection ||= Faraday.new do |conn|
|
57
70
|
conn.url_prefix = SMART_RECRUITERS_BASE_PATHS[@environment]
|
58
71
|
conn.headers['X-SmartToken'] = api_key
|
59
72
|
conn.request :json
|
73
|
+
conn.request :retry, retry_options
|
60
74
|
|
61
75
|
conn.response :json, content_type: 'application/json'
|
62
76
|
|
77
|
+
conn.options.timeout = SMART_RECRUITERS_TIMEOUT
|
63
78
|
conn.adapter adapter, @stubs
|
64
79
|
end
|
65
80
|
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def retry_options
|
85
|
+
{
|
86
|
+
max: SMART_RECRUITERS_RETRIES,
|
87
|
+
retry_statuses: [429]
|
88
|
+
}
|
89
|
+
end
|
66
90
|
end
|
67
91
|
end
|
@@ -6,13 +6,21 @@ module SmartRecruiters
|
|
6
6
|
|
7
7
|
def self.from_response(response, type:)
|
8
8
|
body = response.body
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
|
10
|
+
if body.is_a?(Array)
|
11
|
+
new(
|
12
|
+
content: body.map { |attrs| type.new(attrs) },
|
13
|
+
limit: nil, offset: nil, next_page_id: nil, total_found: nil
|
14
|
+
)
|
15
|
+
else
|
16
|
+
new(
|
17
|
+
content: body['content'].map { |attrs| type.new(attrs) },
|
18
|
+
limit: body['limit'],
|
19
|
+
offset: body['offset'],
|
20
|
+
next_page_id: body['nextPageId'],
|
21
|
+
total_found: body['totalFound']
|
22
|
+
)
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
def initialize(content:, limit:, offset:, next_page_id:, total_found:)
|
@@ -2,8 +2,18 @@
|
|
2
2
|
|
3
3
|
module SmartRecruiters
|
4
4
|
class AccessGroupsResource < Resource
|
5
|
+
ACCESS_GROUP_API = 'user-api/v201804/access-groups'
|
6
|
+
|
5
7
|
def list
|
6
|
-
Collection.from_response get_request(
|
8
|
+
Collection.from_response get_request(ACCESS_GROUP_API.to_s), type: AccessGroup
|
9
|
+
end
|
10
|
+
|
11
|
+
def assign_users(group_id:, user_ids:)
|
12
|
+
Collection.from_response post_request("#{ACCESS_GROUP_API}/#{group_id}/users", body: user_ids), type: User
|
13
|
+
end
|
14
|
+
|
15
|
+
def remove_user(group_id:, user_id:)
|
16
|
+
delete_request("#{ACCESS_GROUP_API}/#{group_id}/users/#{user_id}")
|
7
17
|
end
|
8
18
|
end
|
9
19
|
end
|
@@ -11,5 +11,22 @@ module SmartRecruiters
|
|
11
11
|
def retrieve(report_id:)
|
12
12
|
Report.new get_request("#{REPORT_API}/reports/#{report_id}").body
|
13
13
|
end
|
14
|
+
|
15
|
+
def retrieve_files(report_id:)
|
16
|
+
Object.new get_request("#{REPORT_API}/reports/#{report_id}/files").body
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_report(report_id:)
|
20
|
+
Report.new post_request("#{REPORT_API}/reports/#{report_id}").body
|
21
|
+
end
|
22
|
+
|
23
|
+
def retrieve_recent_file(report_id:)
|
24
|
+
Report.new get_request("#{REPORT_API}/reports/#{report_id}/files/recent").body
|
25
|
+
end
|
26
|
+
|
27
|
+
def retrieve_recent_file_data(report_id:)
|
28
|
+
response = get_request("#{REPORT_API}/reports/#{report_id}/files/recent/data").body
|
29
|
+
Object.new JSON.parse(response)
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SmartRecruiters
|
4
|
+
class WebhooksResource < Resource
|
5
|
+
WEBHOOK_API = 'webhooks-api/v201907'
|
6
|
+
|
7
|
+
def list(**params)
|
8
|
+
response = get_request("#{WEBHOOK_API}/subscriptions", params: params)
|
9
|
+
Collection.from_response(response, type: Webhook)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(**attributes)
|
13
|
+
Webhook.new post_request("#{WEBHOOK_API}/subscriptions", body: attributes).body
|
14
|
+
end
|
15
|
+
|
16
|
+
def retrieve(webhook_id:)
|
17
|
+
Webhook.new get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}").body
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(webhook_id:)
|
21
|
+
delete_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def activate(webhook_id:, **attributes)
|
25
|
+
put_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/activation", body: attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def callbacks_log(webhook_id:, **params)
|
29
|
+
response = get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/callbacks-log", params: params)
|
30
|
+
Collection.from_response(response, type: CallbacksLog)
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate_secret(webhook_id:, **attributes)
|
34
|
+
Object.new post_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/secret-key", body: attributes).body
|
35
|
+
end
|
36
|
+
|
37
|
+
def retrieve_secret(webhook_id:)
|
38
|
+
Object.new get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/secret-key").body
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/smartrecruiters.rb
CHANGED
@@ -11,15 +11,16 @@ module SmartRecruiters
|
|
11
11
|
|
12
12
|
autoload :AccessGroup, 'smartrecruiters/objects/access_group'
|
13
13
|
autoload :Attachment, 'smartrecruiters/objects/attachment'
|
14
|
+
autoload :CallbacksLog, 'smartrecruiters/objects/callbacks_log'
|
14
15
|
autoload :Candidate, 'smartrecruiters/objects/candidate'
|
15
16
|
autoload :Interview, 'smartrecruiters/objects/interview'
|
16
|
-
|
17
17
|
autoload :Job, 'smartrecruiters/objects/job'
|
18
18
|
autoload :Offer, 'smartrecruiters/objects/offer'
|
19
19
|
autoload :User, 'smartrecruiters/objects/user'
|
20
20
|
autoload :Report, 'smartrecruiters/objects/report'
|
21
21
|
autoload :Review, 'smartrecruiters/objects/review'
|
22
22
|
autoload :SystemRole, 'smartrecruiters/objects/system_role'
|
23
|
+
autoload :Webhook, 'smartrecruiters/objects/webhook'
|
23
24
|
|
24
25
|
autoload :AccessGroupsResource, 'smartrecruiters/resources/access_groups'
|
25
26
|
autoload :CandidatesResource, 'smartrecruiters/resources/candidates'
|
@@ -31,4 +32,5 @@ module SmartRecruiters
|
|
31
32
|
autoload :ReportsResource, 'smartrecruiters/resources/reports'
|
32
33
|
autoload :ReviewsResource, 'smartrecruiters/resources/reviews'
|
33
34
|
autoload :SystemRolesResource, 'smartrecruiters/resources/system_roles'
|
35
|
+
autoload :WebhooksResource, 'smartrecruiters/resources/webhooks'
|
34
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartrecruiters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cameron
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/smartrecruiters/object.rb
|
108
108
|
- lib/smartrecruiters/objects/access_group.rb
|
109
109
|
- lib/smartrecruiters/objects/attachment.rb
|
110
|
+
- lib/smartrecruiters/objects/callbacks_log.rb
|
110
111
|
- lib/smartrecruiters/objects/candidate.rb
|
111
112
|
- lib/smartrecruiters/objects/interview.rb
|
112
113
|
- lib/smartrecruiters/objects/job.rb
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- lib/smartrecruiters/objects/review.rb
|
116
117
|
- lib/smartrecruiters/objects/system_role.rb
|
117
118
|
- lib/smartrecruiters/objects/user.rb
|
119
|
+
- lib/smartrecruiters/objects/webhook.rb
|
118
120
|
- lib/smartrecruiters/resource.rb
|
119
121
|
- lib/smartrecruiters/resources/access_groups.rb
|
120
122
|
- lib/smartrecruiters/resources/candidates.rb
|
@@ -126,6 +128,7 @@ files:
|
|
126
128
|
- lib/smartrecruiters/resources/reviews.rb
|
127
129
|
- lib/smartrecruiters/resources/system_roles.rb
|
128
130
|
- lib/smartrecruiters/resources/users.rb
|
131
|
+
- lib/smartrecruiters/resources/webhooks.rb
|
129
132
|
- lib/smartrecruiters/version.rb
|
130
133
|
- smartrecruiters.gemspec
|
131
134
|
homepage: https://github.com/davejcameron/smartrecruiters
|