icims 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b628fb625d9fb38ab0447e3ed58a4beec30fdf27
4
+ data.tar.gz: 5ca56ef7f805e2e7a6231190197b946597a28269
5
+ SHA512:
6
+ metadata.gz: 3a68d0aefb3a4d201cc6d07a8c495652889a8730c88afc91f3da6ed76db90b40a47b75e59a77a6ce6c91e1499c87de1b1871461cb9148181d32f3ef27ca8ab71
7
+ data.tar.gz: 089c78f4279dcc152b1458a04b0fd972da159f0abc78fed58c1d47df7c2735d181159d6d79f131fd4b98e77e9369ede484ad7d78261510a4b800e88e17f8d033
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # iCIMS API Integration
2
+
3
+ Simple wrapper around iCIMS API to avoid technicalities around their workflow.
4
+
5
+ Read more on iCIMS API here: [http://developer.icims.com/REST-API/Object-Types-Commands/Search-API](http://developer.icims.com/REST-API/Object-Types-Commands/Search-API)
6
+
7
+ ## Getting Started
8
+
9
+ Create an initializer file to setup iCIMS credentials. I suggest using DotEnv to keep it secret.
10
+
11
+ ```
12
+ # config/initializers/icims.rb
13
+ ICIMS.setup do |config|
14
+ config.username = ENV['ICIMS_API_USER']
15
+ config.password = ENV['ICIMS_API_PASS']
16
+ config.customer_id = ENV['ICIMS_API_CUSTOMER']
17
+
18
+ # Value for job.postedto to fetch approved job offers only
19
+ # You may want to include more than one portal. This number changes from one implementation to another.
20
+ config.portal_ids = ['1']
21
+ end
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Find single record
27
+
28
+ `ICIMS::Job.find(123)` where 123 is iCIMS record id and will return a ICIMS::Job instance.
29
+ Optional `fields` parameter
30
+
31
+ ### Approved jobs
32
+
33
+ `ICIMS::Job.approved` returns approved and posted jobs
34
+
35
+ ### Search for jobs
36
+
37
+ `ICIMS::Job.search(fields)` relies on iCIMS query interface to define filters.
38
+
39
+ ```
40
+ filters = [
41
+ {
42
+ name: "job.folder",
43
+ value: ['C14567'],
44
+ operator: "="
45
+ },
46
+ {
47
+ name: "job.postedto",
48
+ value: ['3'],
49
+ operator: "="
50
+ }
51
+ ]
52
+ ICIMS::Job.search(filters)
53
+ ```
54
+
55
+ ## Contributing
56
+
57
+ Once you've made your great commits:
58
+
59
+ - Fork icims
60
+ - Create a topic branch - git checkout -b my_branch
61
+ - Push to your branch - git push origin my_branch
62
+ - Create an Issue with a link to your branch
63
+ - That's it!
64
+
65
+
66
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Icims'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,30 @@
1
+ require 'icims/requestable'
2
+ require 'icims/get_request'
3
+ require 'icims/search_request'
4
+ require 'icims/job'
5
+
6
+ module ICIMS
7
+ require 'net/https'
8
+ require 'uri'
9
+ require 'openssl'
10
+ require 'json'
11
+ require 'httparty'
12
+ require 'active_support/all'
13
+
14
+ mattr_accessor :username
15
+ mattr_accessor :password
16
+ mattr_accessor :customer_id
17
+ mattr_accessor :portal_ids
18
+
19
+ def self.setup
20
+ yield self
21
+ end
22
+
23
+ def self.logger
24
+ @logger ||= begin
25
+ log_file = defined?(Rails) ? [Rails.root, 'log', 'icims.log'].join('/') : 'icims.log'
26
+ Logger.new(log_file)
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,47 @@
1
+ module ICIMS
2
+ class GetRequest
3
+
4
+ include Requestable
5
+
6
+ def initialize url
7
+ @url = url
8
+ end
9
+
10
+ def call
11
+ request = get_request_object
12
+ ICIMS.logger.info "#{request.method} #{uri.to_s}"
13
+ response = ssl_connection.request(request)
14
+ parsed_response = JSON.parse(response.body)
15
+ ICIMS.logger.info parsed_response
16
+ parsed_response
17
+ end
18
+
19
+ class << self
20
+
21
+ def perform(url)
22
+ new(url).call
23
+ end
24
+
25
+ end
26
+
27
+ private
28
+
29
+ def uri
30
+ URI.parse(customer_url + @url)
31
+ end
32
+
33
+ def ssl_connection
34
+ connection = Net::HTTP.new(uri.host, uri.port)
35
+ connection.use_ssl = true
36
+ connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
37
+ connection
38
+ end
39
+
40
+ def get_request_object
41
+ request_object = Net::HTTP::Get.new(uri.request_uri)
42
+ request_object.basic_auth(ICIMS.username, ICIMS.password)
43
+ request_object
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,59 @@
1
+ module ICIMS
2
+
3
+ require 'ostruct'
4
+
5
+ class Job < OpenStruct
6
+
7
+ DEFAULT_FIELDS = %w(id updateddate folder jobtitle positioncategory positiontype joblocation additionallocations overview)
8
+
9
+ class << self
10
+
11
+ def find job_id, fields: []
12
+ fields = DEFAULT_FIELDS unless fields.any?
13
+ if job_id.is_a?(Array)
14
+ fetch_records(job_id, fields)
15
+ else
16
+ fetch_single(job_id, fields)
17
+ end
18
+ end
19
+
20
+ def search filters, fields: []
21
+ fields = DEFAULT_FIELDS unless fields.any?
22
+ ids = fetch_ids(filters)
23
+ fetch_records(ids, fields)
24
+ end
25
+
26
+ def approved portal_ids: [], fields: []
27
+ portal_ids = ICIMS.portal_ids unless portal_ids.any?
28
+ portal_ids.map do |id|
29
+ search([
30
+ { name: "job.folder", value: ['D31001'], operator: "=" },
31
+ { name: "job.postedto", value: [id], operator: "=" }
32
+ ], fields: fields)
33
+ end.flatten
34
+ end
35
+
36
+ private
37
+
38
+ def fetch_ids filters
39
+ params = {filters: filters}
40
+ response = ICIMS::SearchRequest.perform(:jobs, params)
41
+ return [] unless response['searchResults'].present?
42
+ response['searchResults'].map{|job_hash| job_hash['id']}
43
+ end
44
+
45
+ def fetch_records ids, fields
46
+ ids.map{|id| fetch_single(id, fields)}
47
+ end
48
+
49
+ def fetch_single id, fields
50
+ url = "/jobs/#{id}"
51
+ url << "?fields=#{fields.join(',')}"
52
+ attributes = ICIMS::GetRequest.perform(url)
53
+ new(attributes)
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,13 @@
1
+ module ICIMS
2
+ module Requestable
3
+
4
+ BASE_URL = "https://api.icims.com/customers/"
5
+
6
+ private
7
+
8
+ def customer_url
9
+ BASE_URL + ICIMS.customer_id
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ module ICIMS
2
+ class SearchRequest
3
+
4
+ include Requestable
5
+
6
+ def initialize endpoint, filters
7
+ @body = filters.to_json
8
+ @url = customer_url + "/search/#{endpoint}"
9
+ end
10
+
11
+ def call
12
+ ICIMS.logger.info "POST #{@url} #{@body}"
13
+ response = post_request
14
+ ICIMS.logger.info response
15
+ if response['errors'].present?
16
+ raise Net::HTTPBadResponse, response['errors']
17
+ end
18
+ response
19
+ end
20
+
21
+ class << self
22
+ def perform(endpoint, filters)
23
+ new(endpoint, filters).call
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def post_request
30
+ HTTParty.post(@url, body: @body, verify: false, basic_auth: {username: ICIMS.username, password: ICIMS.password}, headers: {'Content-Type' => 'application/json'})
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Icims
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icims
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mathieu Gagné
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.1'
41
+ description: Ruby library for API requests with iCIMS Applicant Tracking System
42
+ email:
43
+ - gagne.mathieu@hotmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/icims.rb
52
+ - lib/icims/get_request.rb
53
+ - lib/icims/job.rb
54
+ - lib/icims/requestable.rb
55
+ - lib/icims/search_request.rb
56
+ - lib/icims/version.rb
57
+ homepage: https://github.com/mathieugagne/icims
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.4.5
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: iCIMS API Integration
81
+ test_files: []