smartrecruiters 0.1.0

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +33 -0
  3. data/.github/workflows/release.yml +36 -0
  4. data/.gitignore +8 -0
  5. data/.rubocop.yml +6 -0
  6. data/CHANGELOG.md +8 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +10 -0
  9. data/Gemfile.lock +68 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +142 -0
  12. data/Rakefile +12 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/lib/smartrecruiters/client.rb +67 -0
  16. data/lib/smartrecruiters/collection.rb +26 -0
  17. data/lib/smartrecruiters/error.rb +5 -0
  18. data/lib/smartrecruiters/object.rb +20 -0
  19. data/lib/smartrecruiters/objects/access_group.rb +6 -0
  20. data/lib/smartrecruiters/objects/attachment.rb +6 -0
  21. data/lib/smartrecruiters/objects/candidate.rb +6 -0
  22. data/lib/smartrecruiters/objects/interview.rb +6 -0
  23. data/lib/smartrecruiters/objects/job.rb +6 -0
  24. data/lib/smartrecruiters/objects/offer.rb +6 -0
  25. data/lib/smartrecruiters/objects/report.rb +6 -0
  26. data/lib/smartrecruiters/objects/review.rb +6 -0
  27. data/lib/smartrecruiters/objects/system_role.rb +6 -0
  28. data/lib/smartrecruiters/objects/user.rb +6 -0
  29. data/lib/smartrecruiters/resource.rb +52 -0
  30. data/lib/smartrecruiters/resources/access_groups.rb +9 -0
  31. data/lib/smartrecruiters/resources/candidates.rb +49 -0
  32. data/lib/smartrecruiters/resources/interview_types.rb +19 -0
  33. data/lib/smartrecruiters/resources/interviews.rb +25 -0
  34. data/lib/smartrecruiters/resources/jobs.rb +19 -0
  35. data/lib/smartrecruiters/resources/offers.rb +19 -0
  36. data/lib/smartrecruiters/resources/reports.rb +15 -0
  37. data/lib/smartrecruiters/resources/reviews.rb +28 -0
  38. data/lib/smartrecruiters/resources/system_roles.rb +9 -0
  39. data/lib/smartrecruiters/resources/users.rb +38 -0
  40. data/lib/smartrecruiters/version.rb +5 -0
  41. data/lib/smartrecruiters.rb +34 -0
  42. data/smartrecruiters.gemspec +47 -0
  43. metadata +156 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44b39ecc3ecdd78c5fa8ee62cac3fbb6b03bc35f8bd19c352f3203150c85bc86
4
+ data.tar.gz: 0b55de968dc1c5f1142578505e59b13ebe39edd014703fcb964340a949aa75e1
5
+ SHA512:
6
+ metadata.gz: e794c63737ea81c0510440cc435b3df51a7b12cba1cf4e980a27b79435140c009b686d0901cf90175c5cdd17fe4560cf7da5dfca5bb035785ba677b321373527
7
+ data.tar.gz: 995acdd377323cff566c4cc11aed188ba0f67240bdc8da5c2261626f2e27707a28497efca2c344b28d09596564a6468ed962a00dd4435a0059a8ea786649c76b
@@ -0,0 +1,33 @@
1
+ on:
2
+ push:
3
+ branches: [ master ]
4
+ pull_request:
5
+ branches: [ "*" ]
6
+
7
+ jobs:
8
+ lint:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.7
17
+ - name: rubocop
18
+ run: bundle install && bundle exec rubocop
19
+ test:
20
+ runs-on: ubuntu-latest
21
+ strategy:
22
+ matrix:
23
+ ruby-version: [2.5, 2.6, 2.7, 3.0]
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler: default
31
+ bundler-cache: true
32
+ - name: test
33
+ run: bundle install && bundle exec rake test
@@ -0,0 +1,36 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ jobs:
8
+ release-please:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: GoogleCloudPlatform/release-please-action@v2
12
+ id: release
13
+ with:
14
+ release-type: ruby
15
+ package-name: smartrecruiters
16
+ bump-minor-pre-major: true
17
+ version-file: "lib/smartrecruiters/version.rb"
18
+ - uses: actions/checkout@v2
19
+ if: ${{ steps.release.outputs.release_created }}
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: 3.0.0
23
+ if: ${{ steps.release.outputs.release_created }}
24
+ - run: bundle install
25
+ if: ${{ steps.release.outputs.release_created }}
26
+ - name: publish gem
27
+ run: |
28
+ mkdir -p $HOME/.gem
29
+ touch $HOME/.gem/credentials
30
+ chmod 0600 $HOME/.gem/credentials
31
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
32
+ gem build *.gemspec
33
+ gem push *.gem
34
+ env:
35
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
36
+ if: ${{ steps.release.outputs.release_created }}
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+
2
+ Style/Documentation:
3
+ Enabled: false
4
+
5
+ Metrics/MethodLength:
6
+ Max: 20
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2021-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * initial release ([4d0effd](https://www.github.com/davejcameron/smartrecruiters/commit/4d0effd7e142dd74d6a8cfb9cd8b7af7a7bc116f))
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dave.j.cameron@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in smartrecruiters.gemspec
8
+ gemspec
9
+
10
+ gem 'rubocop', '1.22.1'
data/Gemfile.lock ADDED
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ smartrecruiters (0.1.0)
5
+ faraday (~> 1.8)
6
+ faraday_middleware (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ faraday (1.8.0)
13
+ faraday-em_http (~> 1.0)
14
+ faraday-em_synchrony (~> 1.0)
15
+ faraday-excon (~> 1.1)
16
+ faraday-httpclient (~> 1.0.1)
17
+ faraday-net_http (~> 1.0)
18
+ faraday-net_http_persistent (~> 1.1)
19
+ faraday-patron (~> 1.0)
20
+ faraday-rack (~> 1.0)
21
+ multipart-post (>= 1.2, < 3)
22
+ ruby2_keywords (>= 0.0.4)
23
+ faraday-em_http (1.0.0)
24
+ faraday-em_synchrony (1.0.0)
25
+ faraday-excon (1.1.0)
26
+ faraday-httpclient (1.0.1)
27
+ faraday-net_http (1.0.1)
28
+ faraday-net_http_persistent (1.2.0)
29
+ faraday-patron (1.0.0)
30
+ faraday-rack (1.0.0)
31
+ faraday_middleware (1.1.0)
32
+ faraday (~> 1.0)
33
+ minitest (5.14.4)
34
+ multipart-post (2.1.1)
35
+ parallel (1.21.0)
36
+ parser (3.0.2.0)
37
+ ast (~> 2.4.1)
38
+ rainbow (3.0.0)
39
+ rake (10.5.0)
40
+ regexp_parser (2.1.1)
41
+ rexml (3.2.5)
42
+ rubocop (1.22.1)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.0.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml
48
+ rubocop-ast (>= 1.12.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.12.0)
52
+ parser (>= 3.0.1.1)
53
+ ruby-progressbar (1.11.0)
54
+ ruby2_keywords (0.0.5)
55
+ unicode-display_width (2.1.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ bundler (~> 1.17)
62
+ minitest (~> 5.0)
63
+ rake (~> 10.0)
64
+ rubocop (= 1.22.1)
65
+ smartrecruiters!
66
+
67
+ BUNDLED WITH
68
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 David Cameron
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # SmartRecruiters
2
+
3
+ API wrapper for the SmartRecruiters API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'smartrecruiters'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install smartrecruiters
20
+
21
+ ## Usage
22
+
23
+ To access the API, you'll need to create a `SmartRecruiters::Client`
24
+
25
+ ```ruby
26
+ client = SmartRecruiters::Client.new(api_key: ENV["SMARTRECRUITERS_API_KEY"])
27
+ ```
28
+
29
+ To configure for the sandbox environment
30
+
31
+ ```ruby
32
+ client = SmartRecruiters::Client.new(api_key: ENV["SMARTRECRUITERS_API_KEY"], environment: "sandbox")
33
+ ```
34
+
35
+ ## Resources
36
+
37
+ ### Access Groups
38
+
39
+ ```ruby
40
+ client.access_groups
41
+ ```
42
+
43
+ ### Candidates
44
+
45
+ ```ruby
46
+ client.candidates.list
47
+ client.candidates.create({})
48
+ client.candidates.retrieve(candidate_id: "id")
49
+ client.candidates.update(candidate_id: "id", {})
50
+ client.candidates.delete(candidate_id: "id")
51
+ client.candidates.retrieve_consent(candidate_id: "id")
52
+ client.candidates.retrieve_consents(candidate_id: "id")
53
+ client.candidates.retrieve_application(candidate_id: "id", job_id: "id")
54
+ client.candidates.retrieve_application_attachments(candidate_id: "id", job_id: "id")
55
+ client.candidates.retrieve_status_history(candidate_id: "id", job_id: "id")
56
+ ```
57
+
58
+ ### Interviews
59
+
60
+ ```ruby
61
+ client.interviews.create({})
62
+ client.interviews.retrieve(interview_id: "id")
63
+ client.interviews.update(interview_id: "id", {})
64
+ client.interviews.delete(interview_id:)
65
+ ```
66
+
67
+ ### Interview Types
68
+
69
+ ```ruby
70
+ client.interview_types.list
71
+ client.interview_types.create(interview_types: ["type"])
72
+ client.interview_types.delete(interview_type: "type")
73
+ ```
74
+
75
+ ### Jobs
76
+
77
+ ```ruby
78
+ client.jobs.list
79
+ client.jobs.retrieve(job_id: "id")
80
+ client.jobs.list_hiring_team(job_id: "id")
81
+ ```
82
+
83
+ ### Offers
84
+
85
+ ```ruby
86
+ client.offers.list
87
+ client.offers.retrieve_offer(offer_id: "id", candidate_id: "id", job_id: "id")
88
+ client.offers.retrieve_offers(candidate_id: "id", job_id: "id")
89
+ ```
90
+
91
+ ### Reports
92
+
93
+ ```ruby
94
+ client.reports.list
95
+ client.reports.retrieve(report_id: "id")
96
+ ```
97
+
98
+ ### Reviews
99
+
100
+ ```ruby
101
+ client.reviews.list
102
+ client.reviews.create({})
103
+ client.reviews.retrieve(review_id: "id")
104
+ client.reviews.update(review_id: "id", {})
105
+ client.reviews.delete(review_id: "id", reviewer_id: "id")
106
+ ```
107
+
108
+ ### System Roles
109
+
110
+ ```ruby
111
+ client.system_roles.list
112
+ ```
113
+
114
+ ### Users
115
+
116
+ ```ruby
117
+ client.users.list
118
+ client.users.create({})
119
+ client.users.retrieve(user_id: "id")
120
+ client.users.update(user_id: "id", {})
121
+ client.users.activate(user_id: "id")
122
+ client.users.activation_email(user_id: "id")
123
+ client.users.deactivate(user_id: "id")
124
+ ```
125
+
126
+ ## Development
127
+
128
+ 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.
129
+
130
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
131
+
132
+ ## Contributing
133
+
134
+ Bug reports and pull requests are welcome on GitHub at https://github.com/davejcameron/smartrecruiters. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
135
+
136
+ ## License
137
+
138
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
139
+
140
+ ## Code of Conduct
141
+
142
+ Everyone interacting in the SmartRecruiters project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/smartrecruiters/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'smartrecruiters'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ module SmartRecruiters
7
+ class Client
8
+ SMART_RECRUITERS_BASE_PATHS = {
9
+ 'production' => 'https://api.smartrecruiters.com',
10
+ 'sandbox' => 'https://api.sandbox.smartrecruiters.com'
11
+ }.freeze
12
+
13
+ attr_reader :api_key, :adapter
14
+
15
+ def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil, environment: 'production')
16
+ @api_key = api_key
17
+ @adapter = adapter
18
+ @environment = environment
19
+
20
+ @stubs = stubs
21
+ end
22
+
23
+ def access_groups
24
+ AccessGroupsResource.new(self)
25
+ end
26
+
27
+ def candidates
28
+ CandidatesResource.new(self)
29
+ end
30
+
31
+ def interviews
32
+ InterviewsResource.new(self)
33
+ end
34
+
35
+ def jobs
36
+ JobsResource.new(self)
37
+ end
38
+
39
+ def reports
40
+ ReportsResource.new(self)
41
+ end
42
+
43
+ def reviews
44
+ ReviewsResource.new(self)
45
+ end
46
+
47
+ def system_roles
48
+ SystemRolesResource.new(self)
49
+ end
50
+
51
+ def users
52
+ UsersResource.new(self)
53
+ end
54
+
55
+ def connection
56
+ @connection ||= Faraday.new do |conn|
57
+ conn.url_prefix = SMART_RECRUITERS_BASE_PATHS[@environment]
58
+ conn.headers['X-SmartToken'] = api_key
59
+ conn.request :json
60
+
61
+ conn.response :json, content_type: 'application/json'
62
+
63
+ conn.adapter adapter, @stubs
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Collection
5
+ attr_reader :content, :limit, :offset, :next_page_id, :total_found
6
+
7
+ def self.from_response(response, type:)
8
+ body = response.body
9
+ new(
10
+ content: body['content'].map { |attrs| type.new(attrs) },
11
+ limit: body['limit'],
12
+ offset: body['offset'],
13
+ next_page_id: body['nextPageId'],
14
+ total_found: body['totalFound']
15
+ )
16
+ end
17
+
18
+ def initialize(content:, limit:, offset:, next_page_id:, total_found:)
19
+ @content = content
20
+ @limit = limit
21
+ @offset = offset
22
+ @next_page_id = next_page_id
23
+ @total_found = total_found
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+
5
+ module SmartRecruiters
6
+ class Object
7
+ def initialize(attributes)
8
+ @attributes = OpenStruct.new(attributes)
9
+ end
10
+
11
+ def method_missing(method, *args, &block)
12
+ attribute = @attributes.send(method, *args, &block)
13
+ attribute.is_a?(Hash) ? Object.new(attribute) : attribute
14
+ end
15
+
16
+ def respond_to_missing?(_method, _include_private = false)
17
+ true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class AccessGroup < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Attachment < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Candidate < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Interview < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Job < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Offer < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Report < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Review < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class SystemRole < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class User < Object
5
+ end
6
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class Resource
5
+ attr_reader :client
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ private
12
+
13
+ def get_request(url, params: {}, headers: {})
14
+ handle_response client.connection.get(url, params, headers)
15
+ end
16
+
17
+ def post_request(url, body:, headers: {})
18
+ handle_response client.connection.post(url, body, headers)
19
+ end
20
+
21
+ def patch_request(url, body:, headers: {})
22
+ handle_response client.connection.patch(url, body, headers)
23
+ end
24
+
25
+ def put_request(url, body:, headers: {})
26
+ handle_response client.connection.put(url, body, headers)
27
+ end
28
+
29
+ def delete_request(url, params: {}, headers: {})
30
+ handle_response client.connection.delete(url, params, headers)
31
+ end
32
+
33
+ def handle_response(response)
34
+ case response.status
35
+ when 400
36
+ raise Error, 'Bad request.'
37
+ when 401
38
+ raise Error, 'Unauthorized'
39
+ when 403
40
+ raise Error, 'Forbidden'
41
+ when 404
42
+ raise Error, 'Not Found'
43
+ when 429
44
+ raise Error, 'Too many requests'
45
+ when 500
46
+ raise Error, 'Internal Server Error'
47
+ end
48
+
49
+ response
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class AccessGroupsResource < Resource
5
+ def list
6
+ Collection.from_response get_request('user-api/v201804/access-groups'), type: AccessGroup
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class CandidatesResource < Resource
5
+ def list(**params)
6
+ response = get_request('candidates', params: params)
7
+ Collection.from_response(response, type: Candidate)
8
+ end
9
+
10
+ def retrieve(candidate_id:)
11
+ Candidate.new get_request("candidates/#{candidate_id}").body
12
+ end
13
+
14
+ def create(**attributes)
15
+ Candidate.new post_request('candidates', body: attributes).body
16
+ end
17
+
18
+ def update(candidate_id:, **attributes)
19
+ Candidate.new patch_request("candidates/#{candidate_id}", body: attributes).body
20
+ end
21
+
22
+ def delete(candidate_id:)
23
+ delete_request("candidates/#{candidate_id}")
24
+ true
25
+ end
26
+
27
+ def retrieve_consent(candidate_id:)
28
+ Object.new get_request("candidates/#{candidate_id}/consent").body
29
+ end
30
+
31
+ def retrieve_consents(candidate_id:)
32
+ response = get_request("candidates/#{candidate_id}/consents")
33
+ Collection.from_response(response, type: Object.new)
34
+ end
35
+
36
+ def retrieve_application(candidate_id:, job_id:)
37
+ Object.new get_request("candidates/#{candidate_id}/jobs/#{job_id}").body
38
+ end
39
+
40
+ def retrieve_application_attachments(candidate_id:, job_id:)
41
+ response = get_request("candidates/#{candidate_id}/jobs/#{job_id}/attachments")
42
+ Collection.from_response(response, type: Attachment)
43
+ end
44
+
45
+ def retrieve_status_history(candidate_id:, job_id:)
46
+ Object.new get_request("candidates/#{candidate_id}/jobs/#{job_id}/status/history").body
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class InterviewTypesResource < Resource
5
+ def list
6
+ Object.new get_request('interview-types').body
7
+ end
8
+
9
+ def create(interview_types:)
10
+ patch_request('interview-types', body: interview_types)
11
+ true
12
+ end
13
+
14
+ def delete(interview_type:)
15
+ delete_request("interview-types/#{interview_type}")
16
+ true
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class InterviewsResource < Resource
5
+ INTERVIEWS_API = 'interviews-api/v201904'
6
+
7
+ def create(**attributes)
8
+ Interview.new post_request("#{INTERVIEWS_API}/interviews", body: attributes).body
9
+ end
10
+
11
+ def retrieve(interview_id:)
12
+ Interview.new get_request("#{INTERVIEWS_API}/interviews/#{interview_id}").body
13
+ end
14
+
15
+ def update(interview_id:, **attributes)
16
+ put_request("#{INTERVIEWS_API}/interviews/#{interview_id}", body: attributes)
17
+ true
18
+ end
19
+
20
+ def delete(interview_id:)
21
+ delete_request("#{INTERVIEWS_API}/interviews/#{interview_id}")
22
+ true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class JobsResource < Resource
5
+ def list(**params)
6
+ response = get_request('jobs', params: params)
7
+ Collection.from_response(response, type: Job)
8
+ end
9
+
10
+ def retrieve(job_id:)
11
+ Job.new get_request("jobs/#{job_id}").body
12
+ end
13
+
14
+ def list_hiring_team(job_id:)
15
+ response = get_request("jobs/#{job_id}/hiring-team")
16
+ Collection.from_response(response, type: Object)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class OffersResource < Resource
5
+ def list(**params)
6
+ response = get_request('offers', params: params)
7
+ Collection.from_response(response, type: Offer)
8
+ end
9
+
10
+ def retrieve_offers(candidate_id:, job_id:)
11
+ response = get_request("candidates/#{candidate_id}/jobs/#{job_id}/offers")
12
+ Collection.from_response(response, type: Offer)
13
+ end
14
+
15
+ def retrieve_offer(offer_id:, candidate_id:, job_id:)
16
+ Offer.new get_request("candidates/#{candidate_id}/jobs/#{job_id}/offers/#{offer_id}")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class ReportsResource < Resource
5
+ REPORT_API = 'reporting-api/v201804'
6
+ def list(**params)
7
+ response = get_request("#{REPORT_API}/reports", params: params)
8
+ Collection.from_response(response, type: Report)
9
+ end
10
+
11
+ def retrieve(report_id:)
12
+ Report.new get_request("#{REPORT_API}/reports/#{report_id}").body
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class ReviewsResource < Resource
5
+ def list(candidate_id:, job_id:)
6
+ params = { candidateId: candidate_id, jobId: job_id }
7
+ Collection.from_response get_request('reviews', params), type: Review
8
+ end
9
+
10
+ def create(**attributes)
11
+ Review.new post_request('reviews', body: attributes).body
12
+ end
13
+
14
+ def retrieve(review_id:)
15
+ Review.new get_request("reviews/#{review_id}"), type: Review
16
+ end
17
+
18
+ def update(review_id:, **attributes)
19
+ patch_request("reviews/#{review_id}", body: attributes)
20
+ true
21
+ end
22
+
23
+ def delete(review_id:, reviewer_id:)
24
+ delete_request("reviews/#{review_id}", params: { reviewerId: reviewer_id })
25
+ true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class SystemRolesResource < Resource
5
+ def list
6
+ Collection.from_response get_request('user-api/v201804/system-roles'), type: SystemRole
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ class UsersResource < Resource
5
+ USER_API = 'user-api/v201804'
6
+
7
+ def list(**params)
8
+ Collection.from_response get_request("#{USER_API}/users", params: params), type: User
9
+ end
10
+
11
+ def create(**attributes)
12
+ User.new post_request("#{USER_API}/users", body: attributes).body
13
+ end
14
+
15
+ def retrieve(user_id:)
16
+ User.new get_request("#{USER_API}/users/#{user_id}").body
17
+ end
18
+
19
+ def update(user_id:, **attributes)
20
+ User.new patch_request("#{USER_API}/users/#{user_id}", body: attributes).body
21
+ end
22
+
23
+ def activate(user_id:)
24
+ put_request("#{USER_API}/users/#{user_id}/activation")
25
+ true
26
+ end
27
+
28
+ def activation_email(user_id:)
29
+ post_request("#{USER_API}/users/#{user_id}/activation-email")
30
+ true
31
+ end
32
+
33
+ def deactivate(user_id:)
34
+ delete_request("#{USER_API}/users/#{user_id}/activation")
35
+ true
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartRecruiters
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'smartrecruiters/version'
4
+
5
+ module SmartRecruiters
6
+ autoload :Client, 'smartrecruiters/client'
7
+ autoload :Collection, 'smartrecruiters/collection'
8
+ autoload :Error, 'smartrecruiters/error'
9
+ autoload :Object, 'smartrecruiters/object'
10
+ autoload :Resource, 'smartrecruiters/resource'
11
+
12
+ autoload :AccessGroup, 'smartrecruiters/objects/access_group'
13
+ autoload :Attachment, 'smartrecruiters/objects/attachment'
14
+ autoload :Candidate, 'smartrecruiters/objects/candidate'
15
+ autoload :Interview, 'smartrecruiters/objects/interview'
16
+
17
+ autoload :Job, 'smartrecruiters/objects/job'
18
+ autoload :Offer, 'smartrecruiters/objects/offer'
19
+ autoload :User, 'smartrecruiters/objects/user'
20
+ autoload :Report, 'smartrecruiters/objects/report'
21
+ autoload :Review, 'smartrecruiters/objects/review'
22
+ autoload :SystemRole, 'smartrecruiters/objects/system_role'
23
+
24
+ autoload :AccessGroupsResource, 'smartrecruiters/resources/access_groups'
25
+ autoload :CandidatesResource, 'smartrecruiters/resources/candidates'
26
+ autoload :InterviewsResource, 'smartrecruiters/resources/interviews'
27
+ autoload :InterviewTypesResource, 'smartrecruiters/resources/interview_types'
28
+ autoload :OffersResource, 'smartrecruiters/resources/offers'
29
+ autoload :JobsResource, 'smartrecruiters/resources/jobs'
30
+ autoload :UsersResource, 'smartrecruiters/resources/users'
31
+ autoload :ReportsResource, 'smartrecruiters/resources/reports'
32
+ autoload :ReviewsResource, 'smartrecruiters/resources/reviews'
33
+ autoload :SystemRolesResource, 'smartrecruiters/resources/system_roles'
34
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'smartrecruiters/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'smartrecruiters'
9
+ spec.version = SmartRecruiters::VERSION
10
+ spec.authors = ['David Cameron']
11
+ spec.email = ['dave.j.cameron@gmail.com']
12
+
13
+ spec.summary = 'API client for SmartRecruiters'
14
+ spec.description = 'API client for SmartRecruiters'
15
+ spec.homepage = 'https://github.com/davejcameron/smartrecruiters'
16
+ spec.license = 'MIT'
17
+
18
+ spec.required_ruby_version = '>= 2.5'
19
+
20
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
21
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
22
+ if spec.respond_to?(:metadata)
23
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
24
+
25
+ spec.metadata['homepage_uri'] = spec.homepage
26
+ spec.metadata['source_code_uri'] = 'https://github.com/davejcameron/smartrecruiters'
27
+ else
28
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
29
+ 'public gem pushes.'
30
+ end
31
+
32
+ # Specify which files should be added to the gem when it is released.
33
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
34
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
35
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
36
+ end
37
+ spec.bindir = 'exe'
38
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
+ spec.require_paths = ['lib']
40
+
41
+ spec.add_development_dependency 'bundler', '~> 1.17'
42
+ spec.add_development_dependency 'minitest', '~> 5.0'
43
+ spec.add_development_dependency 'rake', '~> 10.0'
44
+
45
+ spec.add_dependency 'faraday', '~> 1.8'
46
+ spec.add_dependency 'faraday_middleware', '~> 1.1'
47
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smartrecruiters
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Cameron
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ description: API client for SmartRecruiters
84
+ email:
85
+ - dave.j.cameron@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".github/workflows/ci.yml"
91
+ - ".github/workflows/release.yml"
92
+ - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - CHANGELOG.md
95
+ - CODE_OF_CONDUCT.md
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/smartrecruiters.rb
104
+ - lib/smartrecruiters/client.rb
105
+ - lib/smartrecruiters/collection.rb
106
+ - lib/smartrecruiters/error.rb
107
+ - lib/smartrecruiters/object.rb
108
+ - lib/smartrecruiters/objects/access_group.rb
109
+ - lib/smartrecruiters/objects/attachment.rb
110
+ - lib/smartrecruiters/objects/candidate.rb
111
+ - lib/smartrecruiters/objects/interview.rb
112
+ - lib/smartrecruiters/objects/job.rb
113
+ - lib/smartrecruiters/objects/offer.rb
114
+ - lib/smartrecruiters/objects/report.rb
115
+ - lib/smartrecruiters/objects/review.rb
116
+ - lib/smartrecruiters/objects/system_role.rb
117
+ - lib/smartrecruiters/objects/user.rb
118
+ - lib/smartrecruiters/resource.rb
119
+ - lib/smartrecruiters/resources/access_groups.rb
120
+ - lib/smartrecruiters/resources/candidates.rb
121
+ - lib/smartrecruiters/resources/interview_types.rb
122
+ - lib/smartrecruiters/resources/interviews.rb
123
+ - lib/smartrecruiters/resources/jobs.rb
124
+ - lib/smartrecruiters/resources/offers.rb
125
+ - lib/smartrecruiters/resources/reports.rb
126
+ - lib/smartrecruiters/resources/reviews.rb
127
+ - lib/smartrecruiters/resources/system_roles.rb
128
+ - lib/smartrecruiters/resources/users.rb
129
+ - lib/smartrecruiters/version.rb
130
+ - smartrecruiters.gemspec
131
+ homepage: https://github.com/davejcameron/smartrecruiters
132
+ licenses:
133
+ - MIT
134
+ metadata:
135
+ homepage_uri: https://github.com/davejcameron/smartrecruiters
136
+ source_code_uri: https://github.com/davejcameron/smartrecruiters
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '2.5'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubygems_version: 3.2.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: API client for SmartRecruiters
156
+ test_files: []