greenhouse_io-gitlab 2.5.3 → 2.5.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51f9bbfcc363d99b8b8f920ff67c4141eb410e66809cd76ee1238e595ef7da02
4
- data.tar.gz: 6a715a12268273408527ed832fe17e4327407ae9042a02d815aae449d46ff178
3
+ metadata.gz: 9cab2766ea46a0929a7e1bb415005df363686b4d0c4ccc084d58d8232757b25f
4
+ data.tar.gz: 7c296d1ea1ac9ebdc9564f4ab454dd13dbb04a2f65631bc7e97e955e30e1e969
5
5
  SHA512:
6
- metadata.gz: 2a379e7d14cd34c4f48064197c54d35ef581ba578553108e4a1ce739b72f4bbde670133846b6f38c49e0fa3a299385add1ed75ac092e601a312b8d47428e2343
7
- data.tar.gz: adc5a9436b3becd331dfac6ba3cf1506dc82c7d67fd69ab3a9efaef8b2ec9f384d17e7cf85c93e0def5129c8fec1e2876861d75ec87a7bd7c44133b9fb887332
6
+ metadata.gz: b8aadda45efd3fa7f3a4726aec81bc346af80838bd3f6aa112695a91050e3bd8994b3beed6b298ddceecc94602372003a6fdd29e4a306b7ec6b353b74545b267
7
+ data.tar.gz: 51b232adb0ba740f35c70391d4e2aa1685aa25523f2d03ef6a05bac280d02995f593de4d6ba82e6ba95b4959c6019f2b7c469f0a7eb1910e9e791f5f82668f67
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'byebug'
4
+
3
5
  group :development do
4
6
  gem 'pry'
5
7
  end
data/bin/console ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require_relative '../lib/greenhouse_io'
6
+
7
+ def reload!(print: true)
8
+ puts 'Reloading ...' if print
9
+ # Main project directory.
10
+ root_dir = File.expand_path('..', __dir__)
11
+ # Directories within the project that should be reloaded.
12
+ reload_dirs = %w[lib]
13
+ # Loop through and reload every file in all relevant project directories.
14
+ reload_dirs.each do |dir|
15
+ Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
16
+ end
17
+ # Return true when complete.
18
+ true
19
+ end
20
+
21
+ # (If you use this, don't forget to add pry to your Gemfile!)
22
+ # require "pry"
23
+ # Pry.start
24
+
25
+ require 'irb'
26
+ 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
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency('httmultiparty', '~> 0.3.16')
21
+ spec.add_runtime_dependency 'rest-client', '~> 2.0'
22
22
  spec.required_ruby_version = '>= 1.9.3'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.3"
25
24
  spec.add_development_dependency "rake"
26
25
  spec.add_development_dependency "rspec", "~> 3.4.0"
27
26
  spec.add_development_dependency "webmock", "~> 1.22.6"
data/lib/greenhouse_io.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'httmultiparty'
2
1
  require 'json'
3
2
 
4
3
  require "greenhouse_io/version"
@@ -1,19 +1,26 @@
1
+ require 'rest-client'
2
+ require 'base64'
3
+
1
4
  module GreenhouseIo
2
5
  module API
3
6
  def get_response(url, options)
4
- self.class.get(url, options)
7
+ headers = {}
8
+ if self.api_token
9
+ credential = Base64.strict_encode64(self.api_token + ':')
10
+ headers = { "Authorization" => "Basic " + credential }
11
+ end
12
+ headers.merge!({ params: options }) unless options.empty?
13
+ RestClient.get(url, headers)
5
14
  end
6
15
 
7
- def post_response(url, options)
8
- self.class.post(url, options)
16
+ def post_response(url, payload, headers)
17
+ credential = Base64.strict_encode64(self.api_token + ':')
18
+ headers.merge!({ "Authorization" => "Basic " + credential })
19
+ RestClient.post(url, payload[:body], headers)
9
20
  end
10
21
 
11
22
  def parse_json(response)
12
23
  JSON.parse(response.body, symbolize_names: GreenhouseIo.configuration.symbolize_keys)
13
24
  end
14
-
15
- def basic_auth
16
- { :username => self.api_token }
17
- end
18
25
  end
19
26
  end
@@ -1,6 +1,5 @@
1
1
  module GreenhouseIo
2
2
  class Client
3
- include HTTMultiParty
4
3
  include GreenhouseIo::API
5
4
 
6
5
  PERMITTED_OPTIONS = [:page, :per_page, :job_id]
@@ -10,82 +9,86 @@ module GreenhouseIo
10
9
  }
11
10
 
12
11
  attr_accessor :api_token, :rate_limit, :rate_limit_remaining, :link
13
- base_uri 'https://harvest.greenhouse.io/v1'
12
+ BASE_URL = 'https://harvest.greenhouse.io/v1'
14
13
 
15
14
  def initialize(api_token = nil)
16
15
  @api_token = api_token || GreenhouseIo.configuration.api_token
17
16
  end
18
17
 
19
18
  def offices(id = nil, options = {})
20
- get_from_harvest_api "/offices#{path_id(id)}", options
19
+ get_from_harvest_api "#{BASE_URL}/offices#{path_id(id)}", options
21
20
  end
22
21
 
23
22
  def offers(id = nil, options = {})
24
- get_from_harvest_api "/offers#{path_id(id)}", options, "offers"
23
+ get_from_harvest_api "#{BASE_URL}/offers#{path_id(id)}", options, "offers"
25
24
  end
26
25
 
27
26
  def departments(id = nil, options = {})
28
- get_from_harvest_api "/departments#{path_id(id)}", options
27
+ get_from_harvest_api "#{BASE_URL}/departments#{path_id(id)}", options
29
28
  end
30
29
 
31
30
  def candidates(id = nil, options = {})
32
- get_from_harvest_api "/candidates#{path_id(id)}", options, "candidates"
31
+ get_from_harvest_api "#{BASE_URL}/candidates#{path_id(id)}", options, "candidates"
33
32
  end
34
33
 
35
34
  def activity_feed(id, options = {})
36
- get_from_harvest_api "/candidates/#{id}/activity_feed", options
35
+ get_from_harvest_api "#{BASE_URL}/candidates/#{id}/activity_feed", options
37
36
  end
38
37
 
39
38
  def create_candidate_note(candidate_id, note_hash, on_behalf_of)
40
39
  post_to_harvest_api(
41
- "/candidates/#{candidate_id}/activity_feed/notes",
40
+ "#{BASE_URL}/candidates/#{candidate_id}/activity_feed/notes",
42
41
  note_hash,
43
42
  { 'On-Behalf-Of' => on_behalf_of.to_s }
44
43
  )
45
44
  end
46
45
 
47
46
  def applications(id = nil, options = {})
48
- get_from_harvest_api "/applications#{path_id(id)}", options
47
+ get_from_harvest_api "#{BASE_URL}/applications#{path_id(id)}", options
49
48
  end
50
49
 
51
50
  def offers_for_application(id, options = {})
52
- get_from_harvest_api "/applications/#{id}/offers", options
51
+ get_from_harvest_api "#{BASE_URL}/applications/#{id}/offers", options
53
52
  end
54
53
 
55
54
  def current_offer_for_application(id, options = {})
56
- get_from_harvest_api "/applications/#{id}/offers/current_offer", options
55
+ get_from_harvest_api "#{BASE_URL}/applications/#{id}/offers/current_offer", options
57
56
  end
58
57
 
59
58
  def scorecards(id, options = {})
60
- get_from_harvest_api "/applications/#{id}/scorecards", options
59
+ get_from_harvest_api "#{BASE_URL}/applications/#{id}/scorecards", options
61
60
  end
62
61
 
63
62
  def all_scorecards(id = nil, options = {})
64
- get_from_harvest_api "/scorecards/#{id}", options
63
+ get_from_harvest_api "#{BASE_URL}/scorecards/#{id}", options
65
64
  end
66
65
 
67
66
  def scheduled_interviews(id, options = {})
68
- get_from_harvest_api "/applications/#{id}/scheduled_interviews", options
67
+ get_from_harvest_api "#{BASE_URL}/applications/#{id}/scheduled_interviews", options
69
68
  end
70
69
 
71
70
  def jobs(id = nil, options = {})
72
- get_from_harvest_api "/jobs#{path_id(id)}", options
71
+ get_from_harvest_api "#{BASE_URL}/jobs#{path_id(id)}", options
73
72
  end
74
73
 
75
74
  def stages(id, options = {})
76
- get_from_harvest_api "/jobs/#{id}/stages", options
75
+ get_from_harvest_api "#{BASE_URL}/jobs/#{id}/stages", options
77
76
  end
78
77
 
79
78
  def job_post(id, options = {})
80
- get_from_harvest_api "/jobs/#{id}/job_post", options
79
+ get_from_harvest_api "#{BASE_URL}/jobs/#{id}/job_post", options
80
+ end
81
+
82
+ def job_posts(options = {})
83
+ get_from_harvest_api "#{BASE_URL}/job_posts", options
81
84
  end
82
85
 
83
86
  def users(id = nil, options = {})
84
- get_from_harvest_api "/users#{path_id(id)}", options
87
+ get_from_harvest_api "#{BASE_URL}/users#{path_id(id)}", options
85
88
  end
86
89
 
87
90
  def sources(id = nil, options = {})
88
- get_from_harvest_api "/sources#{path_id(id)}", options
91
+ get_from_harvest_api "#{BASE_URL}/sources#{path_id(id)}", options
89
92
  end
90
93
 
91
94
  private
@@ -106,12 +109,7 @@ module GreenhouseIo
106
109
  all_permitted_options = permitted_options(options)
107
110
  all_permitted_options.merge!(permitted_options_for_endpoint(options, endpoint)) if endpoint
108
111
 
109
- response = get_response(url, {
110
- :query => all_permitted_options,
111
- :basic_auth => basic_auth
112
- })
113
-
114
- set_headers_info(response.headers)
112
+ response = get_response(url, all_permitted_options)
115
113
 
116
114
  if response.code == 200
117
115
  parse_json(response)
@@ -121,13 +119,7 @@ module GreenhouseIo
121
119
  end
122
120
 
123
121
  def post_to_harvest_api(url, body, headers)
124
- response = post_response(url, {
125
- :body => JSON.dump(body),
126
- :basic_auth => basic_auth,
127
- :headers => headers
128
- })
129
-
130
- set_headers_info(response.headers)
122
+ response = post_response(url, {:body => JSON.dump(body)}, headers)
131
123
 
132
124
  if response.code == 200
133
125
  parse_json(response)
@@ -135,11 +127,5 @@ module GreenhouseIo
135
127
  raise GreenhouseIo::Error.new(response.code)
136
128
  end
137
129
  end
138
-
139
- def set_headers_info(headers)
140
- self.rate_limit = headers['x-ratelimit-limit'].to_i
141
- self.rate_limit_remaining = headers['x-ratelimit-remaining'].to_i
142
- self.link = headers['link'].to_s
143
- end
144
130
  end
145
131
  end
@@ -1,9 +1,8 @@
1
1
  module GreenhouseIo
2
2
  class JobBoard
3
- include HTTMultiParty
4
3
  include GreenhouseIo::API
5
4
  attr_accessor :api_token, :organization
6
- base_uri 'https://api.greenhouse.io/v1'
5
+ BASE_URL = 'https://api.greenhouse.io/v1'
7
6
 
8
7
  def initialize(api_token = nil, default_options = {})
9
8
  @api_token = api_token || GreenhouseIo.configuration.api_token
@@ -11,31 +10,31 @@ module GreenhouseIo
11
10
  end
12
11
 
13
12
  def offices(options = {})
14
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/offices")
13
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/offices")
15
14
  end
16
15
 
17
16
  def office(id, options = {})
18
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/office", query: { id: id })
17
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/office", { id: id })
19
18
  end
20
19
 
21
20
  def departments(options = {})
22
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/departments")
21
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/departments")
23
22
  end
24
23
 
25
24
  def department(id, options = {})
26
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/department", query: { id: id })
25
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/department", { id: id })
27
26
  end
28
27
 
29
28
  def jobs(options = {})
30
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/jobs", query: { content: options[:content] })
29
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/jobs", { content: options[:content] })
31
30
  end
32
31
 
33
32
  def job(id, options = {})
34
- get_from_job_board_api("/boards/#{ query_organization(options) }/embed/job", query: { id: id, questions: options[:questions] })
33
+ get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/job", { id: id, questions: options[:questions] })
35
34
  end
36
35
 
37
36
  def apply_to_job(job_form_hash)
38
- post_to_job_board_api('/applications', { :body => job_form_hash, :basic_auth => basic_auth })
37
+ post_to_job_board_api("#{BASE_URL}/applications", { :body => job_form_hash, :basic_auth => basic_auth })
39
38
  end
40
39
 
41
40
  private
@@ -1,3 +1,3 @@
1
1
  module GreenhouseIo
2
- VERSION = "2.5.3"
2
+ VERSION = "2.5.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greenhouse_io-gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greenhouse Software
@@ -9,36 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-02 00:00:00.000000000 Z
12
+ date: 2021-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: httmultiparty
15
+ name: rest-client
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.3.16
20
+ version: '2.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.3.16
28
- - !ruby/object:Gem::Dependency
29
- name: bundler
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '1.3'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.3'
27
+ version: '2.0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rake
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -99,7 +85,9 @@ description: Ruby bindings for the greenhouse.io Harvest API and Job Board API
99
85
  email:
100
86
  - support@greenhouse.io
101
87
  - adrianbautista8@gmail.com
102
- executables: []
88
+ executables:
89
+ - console
90
+ - setup
103
91
  extensions: []
104
92
  extra_rdoc_files: []
105
93
  files:
@@ -110,6 +98,8 @@ files:
110
98
  - LICENSE.txt
111
99
  - README.md
112
100
  - Rakefile
101
+ - bin/console
102
+ - bin/setup
113
103
  - greenhouse_io.gemspec
114
104
  - lib/greenhouse_io.rb
115
105
  - lib/greenhouse_io/api.rb
@@ -186,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
176
  - !ruby/object:Gem::Version
187
177
  version: '0'
188
178
  requirements: []
189
- rubygems_version: 3.0.3
179
+ rubygems_version: 3.0.1
190
180
  signing_key:
191
181
  specification_version: 4
192
182
  summary: Ruby bindings for the greenhouse.io Harvest API and Job Board API