Class: Teamtailor::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/teamtailor/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(payload) ⇒ Object



22
23
24
# File 'lib/teamtailor/parser.rb', line 22

def self.parse(payload)
  new(payload).parse
end

Instance Method Details

#parseObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/teamtailor/parser.rb', line 26

def parse
  data.map do |record|
    case record&.dig("type")
    when "candidates" then Teamtailor::Candidate.new(record, included)
    when "jobs" then Teamtailor::Job.new(record, included)
    when "users" then Teamtailor::User.new(record, included)
    when "job-applications" then Teamtailor::JobApplication.new(record, included)
    when "companies" then Teamtailor::Company.new(record, included)
    when "stages" then Teamtailor::Stage.new(record, included)
    when "reject-reasons" then Teamtailor::RejectReason.new(record, included)
    when "departments" then Teamtailor::Department.new(record, included)
    when "locations" then Teamtailor::Location.new(record, included)
    when "custom-fields" then Teamtailor::CustomField.new(record, included)
    when "custom-field-selects" then Teamtailor::CustomField.new(record, included)
    when "custom-field-values" then Teamtailor::CustomFieldValue.new(record, included)
    when "referrals" then Teamtailor::Referral.new(record, included)
    when "partner-results" then Teamtailor::PartnerResult.new(record, included)
    when "requisitions" then Teamtailor::Requisition.new(record, included)
    when "requisition-step-verdicts" then Teamtailor::RequisitionStepVerdict.new(record, included)
    when "uploads" then Teamtailor::Upload.new(record, included)

    else
      raise Teamtailor::UnknownResponseTypeError, record&.dig("type")
    end
  end
end