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:



15
16
17
18
# File 'lib/fountain/api/labels.rb', line 15

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:



45
46
47
48
# File 'lib/fountain/api/labels.rb', line 45

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:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fountain/api/labels.rb', line 28

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/#{URI.encode(title)}",
    method: :put,
    body: filtered_options
  )
  response['labels'].map { |hash| Fountain::Label.new hash }
end