Skip to content

Commit 7204cd8

Browse files
authored
feat: Add support for postings (#18)
1 parent a182e30 commit 7204cd8

File tree

13 files changed

+351
-3
lines changed

13 files changed

+351
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ client.offers.retrieve(offer_id: "id", candidate_id: "id", job_id: "id")
9090
client.offers.retrieve_offers(candidate_id: "id", job_id: "id")
9191
```
9292

93+
### Postings
94+
95+
```ruby
96+
client.postings.list(company_id:)
97+
client.postings.list_departments(company_id:)
98+
client.postings.retrieve(company_id:, posting_id:)
99+
client.postings.create_candidate(posting_id:, {})
100+
client.postings.retrieve_candidate_status(posting_id:, candidate_id:)
101+
client.postings.retrieve_configuration(posting_id:)
102+
```
103+
93104
### Reports
94105

95106
```ruby

lib/smartrecruiters.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@ module SmartRecruiters
1313
autoload :Attachment, 'smartrecruiters/objects/attachment'
1414
autoload :CallbacksLog, 'smartrecruiters/objects/callbacks_log'
1515
autoload :Candidate, 'smartrecruiters/objects/candidate'
16+
autoload :Department, 'smartrecruiters/objects/department'
1617
autoload :Interview, 'smartrecruiters/objects/interview'
1718
autoload :Job, 'smartrecruiters/objects/job'
1819
autoload :Offer, 'smartrecruiters/objects/offer'
19-
autoload :User, 'smartrecruiters/objects/user'
20+
autoload :Posting, 'smartrecruiters/objects/posting'
2021
autoload :Report, 'smartrecruiters/objects/report'
2122
autoload :ReportFile, 'smartrecruiters/objects/report_file'
2223
autoload :Review, 'smartrecruiters/objects/review'
2324
autoload :SystemRole, 'smartrecruiters/objects/system_role'
25+
autoload :User, 'smartrecruiters/objects/user'
2426
autoload :Webhook, 'smartrecruiters/objects/webhook'
2527

2628
autoload :AccessGroupsResource, 'smartrecruiters/resources/access_groups'
2729
autoload :CandidatesResource, 'smartrecruiters/resources/candidates'
2830
autoload :InterviewsResource, 'smartrecruiters/resources/interviews'
2931
autoload :InterviewTypesResource, 'smartrecruiters/resources/interview_types'
30-
autoload :OffersResource, 'smartrecruiters/resources/offers'
3132
autoload :JobsResource, 'smartrecruiters/resources/jobs'
32-
autoload :UsersResource, 'smartrecruiters/resources/users'
33+
autoload :OffersResource, 'smartrecruiters/resources/offers'
34+
autoload :PostingsResource, 'smartrecruiters/resources/postings'
3335
autoload :ReportsResource, 'smartrecruiters/resources/reports'
3436
autoload :ReviewsResource, 'smartrecruiters/resources/reviews'
3537
autoload :SystemRolesResource, 'smartrecruiters/resources/system_roles'
38+
autoload :UsersResource, 'smartrecruiters/resources/users'
3639
autoload :WebhooksResource, 'smartrecruiters/resources/webhooks'
3740
end

lib/smartrecruiters/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def offers
5353
OffersResource.new(self)
5454
end
5555

56+
def postings
57+
PostingsResource.new(self)
58+
end
59+
5660
def reports
5761
ReportsResource.new(self)
5862
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
module SmartRecruiters
4+
class Department < Object
5+
end
6+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
module SmartRecruiters
4+
class Posting < Object
5+
end
6+
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
module SmartRecruiters
4+
class PostingsResource < Resource
5+
COMPANY_API = 'v1/companies'
6+
7+
def list(company_id:, **params)
8+
response = get_request("#{COMPANY_API}/#{company_id}/postings", params: params)
9+
Collection.from_response(response, type: Posting)
10+
end
11+
12+
def list_departments(company_id:, **params)
13+
response = get_request("#{COMPANY_API}/#{company_id}/departments", params: params)
14+
Collection.from_response(response, type: Department)
15+
end
16+
17+
def retrieve_posting(company_id:, posting_id:, **params)
18+
Posting.new get_request("#{COMPANY_API}/#{company_id}/postings/#{posting_id}", params: params).body
19+
end
20+
21+
def create_candidate(posting_id:, **attributes)
22+
Object.new post_request("postings/#{posting_id}/candidates", body: attributes).body
23+
end
24+
25+
def retrieve_candidate_status(posting_id:, candidate_id:)
26+
Object.new get_request("postings/#{posting_id}/candidates/#{candidate_id}/status").body
27+
end
28+
29+
def retrieve_configuration(posting_id:)
30+
Object.new get_request("postings/#{posting_id}/configuration").body
31+
end
32+
end
33+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "14b68c0a-de64-4638-b6d7-189a126a0891",
3+
"createdOn": "string",
4+
"candidatePortalUrl": "string"
5+
}

test/fixtures/postings/list.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"totalFound": 0,
3+
"limit": 0,
4+
"offset": 0,
5+
"content": [
6+
{
7+
"id": "string",
8+
"uuid": "string",
9+
"name": "string",
10+
"refNumber": "string",
11+
"company": {
12+
"identifier": "string",
13+
"name": "string"
14+
},
15+
"releasedDate": "2021-10-24T20:11:07.457Z",
16+
"location": {
17+
"country": "string",
18+
"region": "string",
19+
"city": "string",
20+
"remote": true
21+
},
22+
"industry": {
23+
"id": "string",
24+
"label": "string"
25+
},
26+
"department": {
27+
"id": "string",
28+
"label": "string",
29+
"description": "string"
30+
},
31+
"function": {
32+
"id": "string",
33+
"label": "string"
34+
},
35+
"typeOfEmployment": {
36+
"id": "string",
37+
"label": "string"
38+
},
39+
"experienceLevel": {
40+
"id": "associate",
41+
"name": "string"
42+
},
43+
"customField": [
44+
{
45+
"fieldId": "string",
46+
"fieldLabel": "string",
47+
"valueId": "string",
48+
"valueLabel": "string"
49+
}
50+
],
51+
"ref": "string",
52+
"creator": {
53+
"name": "string"
54+
},
55+
"language": {
56+
"code": "string",
57+
"label": "string",
58+
"labelNative": "string"
59+
}
60+
}
61+
]
62+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"totalFound": 0,
3+
"content": [
4+
{
5+
"id": "string",
6+
"label": "Product",
7+
"description": "Product"
8+
}
9+
]
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"status": "NEW"
3+
}

0 commit comments

Comments
 (0)