fountain 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c5e9a3a1b38cd8a1110f5898e134cc9df352309
4
- data.tar.gz: 0a946cb763f2a69b7c8a63285e783270906719b9
3
+ metadata.gz: b3f653218c512db55d5962968cd24d27ddd397d9
4
+ data.tar.gz: 4de91be1284cec1b666cff24fa6f125faf00f272
5
5
  SHA512:
6
- metadata.gz: 7f81069700b642aeb4ccdf5b867e5583bda22b60602d436f6f41b60fde84f55e877454e64e11bb41f4720f43538f5368ea777c4163a2631f8b0ecaaa370584fd
7
- data.tar.gz: 54c83583d1f8004b5752cae292b0b0c85e83325c790ffbcceeb8f2feda6f46d0978a5266a4809319d4ba69144602009002e1a3e1269a012c2ac69b0135611c46
6
+ metadata.gz: 134cd04804537aa3e18752ff099491bd99e92391eef01b95c10d9b02856ea7d514eca255cf412ddb9e611dcfd496b1d75513e502610f43cd023ddfa192cf1192
7
+ data.tar.gz: f3b60a48988a06d3727e5e292b7a690e1d9430f52c6c8c93d777c2c84d688fc4e2a3a911fc086fa2a1cbfe9c561cec31d9cf6f39e0fa83174e168272d63c8ea2
data/lib/fountain.rb CHANGED
@@ -19,9 +19,12 @@ end
19
19
  require 'fountain/applicant'
20
20
  require 'fountain/applicants'
21
21
  require 'fountain/background_check'
22
+ require 'fountain/booked_slot'
22
23
  require 'fountain/document_signature'
23
24
  require 'fountain/funnel'
25
+ require 'fountain/secure_document'
24
26
  require 'fountain/stage'
27
+ require 'fountain/transition'
25
28
 
26
29
  require 'fountain/api/request_helper'
27
30
  require 'fountain/api/applicants'
@@ -4,7 +4,7 @@ module Fountain
4
4
  # Fountain Applicant API
5
5
  #
6
6
  class Applicants
7
- include RequestHelper
7
+ extend RequestHelper
8
8
 
9
9
  #
10
10
  # List applicants
@@ -14,8 +14,8 @@ module Fountain
14
14
  # stage - Filter applicants by stage type
15
15
  # labels - MUST be URL-encoded
16
16
  # cursor - Cursor parameter for cursor-based pagination
17
- # @return [Array] of Fountain::Applicant
18
- def list(filter_options = {})
17
+ # @return [Fountain::Applicants]
18
+ def self.list(filter_options = {})
19
19
  response = request_json(
20
20
  '/v2/applicants',
21
21
  body: Util.slice_hash(
@@ -27,7 +27,58 @@ module Fountain
27
27
  end
28
28
 
29
29
  #
30
- # Update applicant info
30
+ # Create an Applicant
31
+ # @param [String] name Full name of the applicant
32
+ # @param [String] email Email address of the applicant
33
+ # @param [String] phone_number Phone number (does not have to be USA)
34
+ # @param [Hash] create_options A hash of optional parameters
35
+ # data - must be passed in a data object/array
36
+ # secure_data - See 'Secure Fields' section of
37
+ # https://developer.fountain.com/docs/post-apiv2applicants
38
+ # funnel_id - Create applicant under a certain opening (funnel)
39
+ # stage_id - Create applicant under a certain stage
40
+ # skip_automated_actions - `true` if you want to skip automated
41
+ # actions when advancing the applicant
42
+ # @return [Fountain::Applicant]
43
+ def self.create(name, email, phone_number, create_options = {})
44
+ filtered_params = Util.slice_hash(
45
+ create_options,
46
+ :data, :secure_data, :funnel_id, :stage_id, :skip_automated_actions
47
+ )
48
+ response = request_json(
49
+ '/v2/applicants',
50
+ method: :post,
51
+ body: {
52
+ name: name, email: email, phone_number: phone_number
53
+ }.merge(filtered_params)
54
+ )
55
+ Fountain::Applicant.new response
56
+ end
57
+
58
+ #
59
+ # Delete an Applicant
60
+ # @param [String] applicant_id ID of the Fountain applicant
61
+ # @return [Boolean]
62
+ def self.delete(applicant_id)
63
+ response = request(
64
+ "/v2/applicants/#{applicant_id}",
65
+ method: :delete
66
+ )
67
+ check_response response
68
+ true
69
+ end
70
+
71
+ #
72
+ # Get Applicant Info
73
+ # @param [String] applicant_id ID of the Fountain applicant
74
+ # @return [Fountain::Applicant]
75
+ def self.get(applicant_id)
76
+ response = request_json("/v2/applicants/#{applicant_id}")
77
+ Fountain::Applicant.new response
78
+ end
79
+
80
+ #
81
+ # Update Applicant Info
31
82
  # @param [String] applicant_id ID of the Fountain applicant
32
83
  # @param [Hash] update_options A hash of options to update applicant
33
84
  # name
@@ -40,7 +91,7 @@ module Fountain
40
91
  # on_hold_reason
41
92
  # @return [Fountain::Applicant]
42
93
  #
43
- def update(applicant_id, update_options = {})
94
+ def self.update(applicant_id, update_options = {})
44
95
  response = request_json(
45
96
  "/v2/applicants/#{applicant_id}",
46
97
  method: :put,
@@ -52,6 +103,54 @@ module Fountain
52
103
  )
53
104
  Fountain::Applicant.new response
54
105
  end
106
+
107
+ #
108
+ # Get Applicant Documents
109
+ # @param [String] applicant_id ID of the Fountain applicant
110
+ # @return [[Fountain::SecureDocument]]
111
+ def self.get_secure_documents(applicant_id)
112
+ response = request_json("/v2/applicants/#{applicant_id}/secure_documents")
113
+ response['secure_documents'].map { |hash| Fountain::SecureDocument.new hash }
114
+ end
115
+
116
+ #
117
+ # Advance an Applicant
118
+ # @param [String] applicant_id ID of the Fountain applicant
119
+ # @param [Hash] advance_options A hash of options to advance applicant
120
+ # skip_automated_actions - `true` if you want to skip automated
121
+ # actions when advancing the applicant
122
+ # stage_id - Destination stage's ID. If not provided, the applicant
123
+ # will advance to the next stage by default.
124
+ def self.advance_applicant(applicant_id, advance_options = {})
125
+ response = request(
126
+ "/v2/applicants/#{applicant_id}/advance",
127
+ method: :put,
128
+ body: Util.slice_hash(
129
+ advance_options,
130
+ :skip_automated_actions, :stage_id
131
+ )
132
+ )
133
+ check_response response, Net::HTTPNoContent
134
+ true
135
+ end
136
+
137
+ #
138
+ # Get Interview Sessions
139
+ # @param [String] applicant_id ID of the Fountain applicant
140
+ # @return [[Fountain::BookedSlot]]
141
+ def self.get_interview_sessions(applicant_id)
142
+ response = request_json("/v2/applicants/#{applicant_id}/booked_slots")
143
+ response['booked_slots'].map { |hash| Fountain::BookedSlot.new hash }
144
+ end
145
+
146
+ #
147
+ # Get Transition History
148
+ # @param [String] applicant_id ID of the Fountain applicant
149
+ # @return [[Fountain::Transition]]
150
+ def self.get_transition_history(applicant_id)
151
+ response = request_json("/v2/applicants/#{applicant_id}/transitions")
152
+ response['transitions'].map { |hash| Fountain::Transition.new hash }
153
+ end
55
154
  end
56
155
  end
57
156
  end
@@ -17,15 +17,16 @@ module Fountain
17
17
  }.freeze
18
18
 
19
19
  def request_json(path, options = {})
20
+ expected_response = options.delete :expected_response
20
21
  response = request path, options
21
- check_response response
22
+ check_response response, expected_response
22
23
  parse_response response.body
23
24
  end
24
25
 
25
26
  def request(path, options = {})
26
27
  options = DEFAULT_REQUEST_OPTIONS.merge(options)
27
28
 
28
- raise Fountain::InvalidMethodError unless %i[get post put].include? options[:method]
29
+ raise Fountain::InvalidMethodError unless %i[get post put delete].include? options[:method]
29
30
 
30
31
  http = create_http(options)
31
32
  req = create_request(path, options)
@@ -34,9 +35,10 @@ module Fountain
34
35
 
35
36
  private
36
37
 
37
- def check_response(response)
38
+ def check_response(response, expected_response = nil)
39
+ expected_response ||= Net::HTTPOK
38
40
  case response
39
- when Net::HTTPOK then nil
41
+ when expected_response then nil
40
42
  when Net::HTTPUnauthorized then raise Fountain::AuthenticationError
41
43
  when Net::HTTPNotFound then raise Fountain::NotFoundError
42
44
  else raise HTTPError, "Invalid http response code: #{response.code}"
@@ -66,12 +68,11 @@ module Fountain
66
68
  headers = get_headers(options)
67
69
  body = options[:body]
68
70
 
69
- if options[:method] == :post
70
- create_post_request path, headers, body
71
- elsif options[:method] == :put
72
- create_put_request path, headers, body
73
- else
74
- create_get_request path, headers, body
71
+ case options[:method]
72
+ when :post then create_post_request path, headers, body
73
+ when :put then create_put_request path, headers, body
74
+ when :delete then create_delete_request path, headers
75
+ else create_get_request path, headers, body
75
76
  end
76
77
  end
77
78
 
@@ -87,6 +88,10 @@ module Fountain
87
88
  req
88
89
  end
89
90
 
91
+ def create_delete_request(path, headers)
92
+ Net::HTTP::Delete.new(path, headers)
93
+ end
94
+
90
95
  def create_get_request(path, headers, body)
91
96
  path += '?' + body.map { |k, v| "#{k}=#{v}" }.join('&') if body
92
97
  Net::HTTP::Get.new(path, headers)
@@ -0,0 +1,60 @@
1
+ module Fountain
2
+ #
3
+ # Fountain Booked Slot
4
+ #
5
+ class BookedSlot
6
+ # Raw booked slot data
7
+ attr_reader :raw_data
8
+
9
+ #
10
+ # @param [Hash] data Raw booked slot data
11
+ #
12
+ def initialize(data)
13
+ @raw_data = Util.stringify_hash_keys data
14
+ end
15
+
16
+ # Booked slot ID
17
+ def id
18
+ raw_data['id']
19
+ end
20
+
21
+ # Start time
22
+ def start_time
23
+ Time.parse raw_data['start_time']
24
+ end
25
+
26
+ # End time
27
+ def end_time
28
+ Time.parse raw_data['end_time']
29
+ end
30
+
31
+ # Location
32
+ def location
33
+ raw_data['location']
34
+ end
35
+
36
+ # Recruiter
37
+ def recruiter
38
+ raw_data['recruiter']
39
+ end
40
+
41
+ # Instructions
42
+ def instructions
43
+ raw_data['instructions']
44
+ end
45
+
46
+ # Showed up
47
+ def showed_up
48
+ raw_data['showed_up'] == 'true'
49
+ end
50
+
51
+ def inspect
52
+ format(
53
+ '#<%<class_name>s:0x%<object_id>p @id="%<id>s">',
54
+ class_name: self.class.name,
55
+ object_id: object_id,
56
+ id: id
57
+ )
58
+ end
59
+ end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module Fountain
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -0,0 +1,61 @@
1
+ module Fountain
2
+ #
3
+ # Fountain Secure Document
4
+ #
5
+ class SecureDocument
6
+ # Raw document data
7
+ attr_reader :raw_data
8
+
9
+ #
10
+ # @param [Hash] data Raw secure document data
11
+ #
12
+ def initialize(data)
13
+ @raw_data = Util.stringify_hash_keys data
14
+ end
15
+
16
+ # Secure document ID
17
+ def id
18
+ raw_data['id']
19
+ end
20
+
21
+ # Name
22
+ def name
23
+ raw_data['name']
24
+ end
25
+
26
+ # FriendlyName
27
+ def friendly_name
28
+ raw_data['friendly_name']
29
+ end
30
+
31
+ # Filename
32
+ def filename
33
+ raw_data['filename']
34
+ end
35
+
36
+ # Public URL
37
+ def public_url
38
+ raw_data['public_url']
39
+ end
40
+
41
+ # Size
42
+ def size
43
+ raw_data['size']
44
+ end
45
+
46
+ # Stage
47
+ def stage
48
+ Stage.new raw_data['stage']
49
+ end
50
+
51
+ def inspect
52
+ format(
53
+ '#<%<class_name>s:0x%<object_id>p @id="%<id>s" @name="%<name>s">',
54
+ class_name: self.class.name,
55
+ object_id: object_id,
56
+ id: id,
57
+ name: name
58
+ )
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,35 @@
1
+ module Fountain
2
+ #
3
+ # Fountain Transition
4
+ #
5
+ class Transition
6
+ # Raw transition data
7
+ attr_reader :raw_data
8
+
9
+ #
10
+ # @param [Hash] data Raw transition data
11
+ #
12
+ def initialize(data)
13
+ @raw_data = Util.stringify_hash_keys data
14
+ end
15
+
16
+ # Stage title
17
+ def stage_title
18
+ raw_data['stage_title']
19
+ end
20
+
21
+ # Created at
22
+ def created_at
23
+ Time.parse raw_data['created_at']
24
+ end
25
+
26
+ def inspect
27
+ format(
28
+ '#<%<class_name>s:0x%<object_id>p @stage_title="%<title>s">',
29
+ class_name: self.class.name,
30
+ object_id: object_id,
31
+ title: stage_title
32
+ )
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fountain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - abrom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-19 00:00:00.000000000 Z
11
+ date: 2018-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,11 +117,14 @@ files:
117
117
  - lib/fountain/applicant.rb
118
118
  - lib/fountain/applicants.rb
119
119
  - lib/fountain/background_check.rb
120
+ - lib/fountain/booked_slot.rb
120
121
  - lib/fountain/configuration.rb
121
122
  - lib/fountain/document_signature.rb
122
123
  - lib/fountain/funnel.rb
123
124
  - lib/fountain/gem_version.rb
125
+ - lib/fountain/secure_document.rb
124
126
  - lib/fountain/stage.rb
127
+ - lib/fountain/transition.rb
125
128
  - lib/fountain/util.rb
126
129
  homepage: https://github.com/Studiosity/fountain-ruby
127
130
  licenses: