Class: Fountain::Api::Labels

Inherits:
Object
  • Object
show all
Extended by:
RequestHelper
Defined in:
lib/fountain/api/labels.rb

Overview

Fountain Label Management API

Constant Summary

Constants included from RequestHelper

RequestHelper::DEFAULT_REQUEST_OPTIONS

Class Method Summary collapse

Methods included from RequestHelper

request, request_json

Class Method Details

.applicant_labels(applicant_id) ⇒ [Fountain::Label]

List Labels for an Applicant

Parameters:

  • applicant_id (String)

    ID of the Fountain applicant

Returns:



18
19
20
21
# File 'lib/fountain/api/labels.rb', line 18

def self.applicant_labels(applicant_id)
  response = request_json("/v2/applicants/#{applicant_id}/labels")
  response['labels'].map { |hash| Fountain::Label.new hash }
end

.stage_labels(stage_id) ⇒ [Fountain::Label]

List Labels for a Stage

Parameters:

  • stage_id (String)

    ID of the Fountain stage

Returns:



48
49
50
51
# File 'lib/fountain/api/labels.rb', line 48

def self.stage_labels(stage_id)
  response = request_json("/v2/stages/#{stage_id}/labels")
  response['labels'].map { |hash| Fountain::Label.new hash }
end

.update_applicant_label(applicant_id, title, update_options = {}) ⇒ [Fountain::Label]

Update Label for an Applicant

Parameters:

  • applicant_id (String)

    ID of the Fountain applicant

  • title (String)

    ID of the Fountain applicant

  • update_options (Hash) (defaults to: {})

    A hash of options to update applicant labels completed completed_at - Date the label was completed

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fountain/api/labels.rb', line 31

def self.update_applicant_label(applicant_id, title, update_options = {})
  filtered_options = Util.slice_hash(update_options, :completed, :completed_at)
  if filtered_options[:completed_at].is_a? Date
    filtered_options[:completed_at] = filtered_options[:completed_at].strftime('%F')
  end
  response = request_json(
    "/v2/applicants/#{applicant_id}/labels/#{CGI.escape(title)}",
    method: :put,
    body: filtered_options
  )
  response['labels'].map { |hash| Fountain::Label.new hash }
end