Skip to content

Commit

Permalink
feat: Add support for postings (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
davejcameron authored Oct 30, 2021
1 parent a182e30 commit 7204cd8
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ client.offers.retrieve(offer_id: "id", candidate_id: "id", job_id: "id")
client.offers.retrieve_offers(candidate_id: "id", job_id: "id")
```

### Postings

```ruby
client.postings.list(company_id:)
client.postings.list_departments(company_id:)
client.postings.retrieve(company_id:, posting_id:)
client.postings.create_candidate(posting_id:, {})
client.postings.retrieve_candidate_status(posting_id:, candidate_id:)
client.postings.retrieve_configuration(posting_id:)
```

### Reports

```ruby
Expand Down
9 changes: 6 additions & 3 deletions lib/smartrecruiters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@ module SmartRecruiters
autoload :Attachment, 'smartrecruiters/objects/attachment'
autoload :CallbacksLog, 'smartrecruiters/objects/callbacks_log'
autoload :Candidate, 'smartrecruiters/objects/candidate'
autoload :Department, 'smartrecruiters/objects/department'
autoload :Interview, 'smartrecruiters/objects/interview'
autoload :Job, 'smartrecruiters/objects/job'
autoload :Offer, 'smartrecruiters/objects/offer'
autoload :User, 'smartrecruiters/objects/user'
autoload :Posting, 'smartrecruiters/objects/posting'
autoload :Report, 'smartrecruiters/objects/report'
autoload :ReportFile, 'smartrecruiters/objects/report_file'
autoload :Review, 'smartrecruiters/objects/review'
autoload :SystemRole, 'smartrecruiters/objects/system_role'
autoload :User, 'smartrecruiters/objects/user'
autoload :Webhook, 'smartrecruiters/objects/webhook'

autoload :AccessGroupsResource, 'smartrecruiters/resources/access_groups'
autoload :CandidatesResource, 'smartrecruiters/resources/candidates'
autoload :InterviewsResource, 'smartrecruiters/resources/interviews'
autoload :InterviewTypesResource, 'smartrecruiters/resources/interview_types'
autoload :OffersResource, 'smartrecruiters/resources/offers'
autoload :JobsResource, 'smartrecruiters/resources/jobs'
autoload :UsersResource, 'smartrecruiters/resources/users'
autoload :OffersResource, 'smartrecruiters/resources/offers'
autoload :PostingsResource, 'smartrecruiters/resources/postings'
autoload :ReportsResource, 'smartrecruiters/resources/reports'
autoload :ReviewsResource, 'smartrecruiters/resources/reviews'
autoload :SystemRolesResource, 'smartrecruiters/resources/system_roles'
autoload :UsersResource, 'smartrecruiters/resources/users'
autoload :WebhooksResource, 'smartrecruiters/resources/webhooks'
end
4 changes: 4 additions & 0 deletions lib/smartrecruiters/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def offers
OffersResource.new(self)
end

def postings
PostingsResource.new(self)
end

def reports
ReportsResource.new(self)
end
Expand Down
6 changes: 6 additions & 0 deletions lib/smartrecruiters/objects/department.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module SmartRecruiters
class Department < Object
end
end
6 changes: 6 additions & 0 deletions lib/smartrecruiters/objects/posting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module SmartRecruiters
class Posting < Object
end
end
33 changes: 33 additions & 0 deletions lib/smartrecruiters/resources/postings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module SmartRecruiters
class PostingsResource < Resource
COMPANY_API = 'v1/companies'

def list(company_id:, **params)
response = get_request("#{COMPANY_API}/#{company_id}/postings", params: params)
Collection.from_response(response, type: Posting)
end

def list_departments(company_id:, **params)
response = get_request("#{COMPANY_API}/#{company_id}/departments", params: params)
Collection.from_response(response, type: Department)
end

def retrieve_posting(company_id:, posting_id:, **params)
Posting.new get_request("#{COMPANY_API}/#{company_id}/postings/#{posting_id}", params: params).body
end

def create_candidate(posting_id:, **attributes)
Object.new post_request("postings/#{posting_id}/candidates", body: attributes).body
end

def retrieve_candidate_status(posting_id:, candidate_id:)
Object.new get_request("postings/#{posting_id}/candidates/#{candidate_id}/status").body
end

def retrieve_configuration(posting_id:)
Object.new get_request("postings/#{posting_id}/configuration").body
end
end
end
5 changes: 5 additions & 0 deletions test/fixtures/postings/create_candidate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "14b68c0a-de64-4638-b6d7-189a126a0891",
"createdOn": "string",
"candidatePortalUrl": "string"
}
62 changes: 62 additions & 0 deletions test/fixtures/postings/list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"totalFound": 0,
"limit": 0,
"offset": 0,
"content": [
{
"id": "string",
"uuid": "string",
"name": "string",
"refNumber": "string",
"company": {
"identifier": "string",
"name": "string"
},
"releasedDate": "2021-10-24T20:11:07.457Z",
"location": {
"country": "string",
"region": "string",
"city": "string",
"remote": true
},
"industry": {
"id": "string",
"label": "string"
},
"department": {
"id": "string",
"label": "string",
"description": "string"
},
"function": {
"id": "string",
"label": "string"
},
"typeOfEmployment": {
"id": "string",
"label": "string"
},
"experienceLevel": {
"id": "associate",
"name": "string"
},
"customField": [
{
"fieldId": "string",
"fieldLabel": "string",
"valueId": "string",
"valueLabel": "string"
}
],
"ref": "string",
"creator": {
"name": "string"
},
"language": {
"code": "string",
"label": "string",
"labelNative": "string"
}
}
]
}
10 changes: 10 additions & 0 deletions test/fixtures/postings/list_departments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"totalFound": 0,
"content": [
{
"id": "string",
"label": "Product",
"description": "Product"
}
]
}
3 changes: 3 additions & 0 deletions test/fixtures/postings/retrieve_candidate_status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"status": "NEW"
}
33 changes: 33 additions & 0 deletions test/fixtures/postings/retrieve_configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"questions": [
{
"id": "string",
"label": "string",
"repeatable": true,
"fields": [
{
"id": "string",
"label": "string",
"type": "INPUT_TEXT",
"required": true,
"complianceType": "DIVERSITY",
"values": [
{
"id": "string",
"label": "string"
}
]
}
]
}
],
"settings": {
"avatarUploadAvailable": true
},
"privacyPolicies": [
{
"url": "string",
"orgName": "string"
}
]
}
81 changes: 81 additions & 0 deletions test/fixtures/postings/retrieve_posting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"id": "string",
"uuid": "string",
"name": "string",
"jobAdId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"applyUrl": "string",
"postingUrl": "string",
"referralUrl": "string",
"refNumber": "string",
"company": {
"identifier": "string",
"name": "string"
},
"releasedDate": "2021-10-24T19:57:22.832Z",
"location": {
"country": "string",
"region": "string",
"city": "string",
"remote": true
},
"industry": {
"id": "string",
"label": "string"
},
"department": {
"id": "string",
"label": "string",
"description": "string"
},
"function": {
"id": "string",
"label": "string"
},
"typeOfEmployment": {
"id": "string",
"label": "string"
},
"experienceLevel": {
"id": "associate",
"name": "string"
},
"customField": [
{
"fieldId": "string",
"fieldLabel": "string",
"valueId": "string",
"valueLabel": "string"
}
],
"ref": "string",
"creator": {
"name": "string"
},
"jobAd": {
"sections": {
"companyDescription": {
"title": "string",
"text": "string"
},
"jobDescription": {
"title": "string",
"text": "string"
},
"qualifications": {
"title": "string",
"text": "string"
},
"additionalInformation": {
"title": "string",
"text": "string"
},
"videos": {
"title": "string",
"urls": [
"string"
]
}
}
},
"active": true
}
Loading

0 comments on commit 7204cd8

Please sign in to comment.