Class: Spear::Structure::Resume::Parse

Inherits:
Base
  • Object
show all
Includes:
EmbededClass
Defined in:
lib/spear/structure/resume/parse.rb

Overview

after parse resume, we will call create resume api. So in this class, we will build the data class structure ‘Create resume’ needs.

Instance Attribute Summary collapse

Attributes inherited from Base

#error_message, #response, #root, #status

Instance Method Summary collapse

Methods included from EmbededClass

#generate_educations, #generate_experiences

Methods inherited from Base

#success?

Constructor Details

#initialize(response) ⇒ Parse

Returns a new instance of Parse.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spear/structure/resume/parse.rb', line 13

def initialize(response)
  super(response)

  @resume = @root['Resume'] || {}
  @hrxml_resume = @resume['HRXMLResume']

  @resume_text = @resume['ResumeText'] || ''
  @total_years_experience = @resume['TotalYearsExperience'].to_i rescue 0
  @educations = generate_educations(@resume['Educations']) rescue nil
  @company_experiences = generate_experiences(@resume['CompanyExperiences']) rescue nil
end

Instance Attribute Details

#company_experiencesObject

Returns the value of attribute company_experiences.



10
11
12
# File 'lib/spear/structure/resume/parse.rb', line 10

def company_experiences
  @company_experiences
end

#custom_valuesObject

Returns the value of attribute custom_values.



10
11
12
# File 'lib/spear/structure/resume/parse.rb', line 10

def custom_values
  @custom_values
end

#educationsObject

Returns the value of attribute educations.



10
11
12
# File 'lib/spear/structure/resume/parse.rb', line 10

def educations
  @educations
end

#employer_orgsObject

Returns the value of attribute employer_orgs.



10
11
12
# File 'lib/spear/structure/resume/parse.rb', line 10

def employer_orgs
  @employer_orgs
end

#hrxml_resumeObject (readonly)

Returns the value of attribute hrxml_resume.



9
10
11
# File 'lib/spear/structure/resume/parse.rb', line 9

def hrxml_resume
  @hrxml_resume
end

#languagesObject

Returns the value of attribute languages.



10
11
12
# File 'lib/spear/structure/resume/parse.rb', line 10

def languages
  @languages
end

#resumeObject (readonly)

Returns the value of attribute resume.



9
10
11
# File 'lib/spear/structure/resume/parse.rb', line 9

def resume
  @resume
end

#resume_textObject

Returns the value of attribute resume_text.



11
12
13
# File 'lib/spear/structure/resume/parse.rb', line 11

def resume_text
  @resume_text
end

#total_years_experienceObject

Returns the value of attribute total_years_experience.



11
12
13
# File 'lib/spear/structure/resume/parse.rb', line 11

def total_years_experience
  @total_years_experience
end

Instance Method Details

#hash_for_create(external_user_id, host_site) ⇒ Object



25
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/spear/structure/resume/parse.rb', line 25

def hash_for_create(external_user_id, host_site)
  raise Spear::ParametersRequired.new(%w{UserExternalId HostSite}) if external_user_id.blank? or host_site.blank?

  # Max Educations are 3
  educations = []
  @educations.each_with_index do |e, index|
    break if index > 2
    edu = {}
    edu[:SchoolName] = e.school_name || ""
    edu[:Major] = e.major || ""
    edu[:DegreeCode] = e.degree_code || ""
    edu[:GraduationDate] = e.graduation_date unless e.graduation_date.blank?
    educations << edu
  end

  # Max CompanyExperiences are 5
  company_experiences = []
  @company_experiences.each_with_index do |ce, index|
    break if index > 4
    cen = {}
    cen[:CompanyName] = ce.company_name || ""
    cen[:JobTitle] = ce.job_title || ""
    if ce.start_date.blank?
      cen[:StartDate] = '1970-01-01'
    else
      cen[:StartDate] = ce.start_date
    end
    if ce.end_date.blank?
      cen[:EndDate] = Time.now.strftime("%Y-%m-%d").to_s
    else
      cen[:EndDate] = ce.end_date
    end
    cen[:Details] = ce.details || ""
    company_experiences << cen
  end

  {
    :ExternalUserID => external_user_id,
    :ShowContactInfo => true,
    :Title => 'title',
    :ResumeText => @resume_text,
    :Visibility => 'Public',
    :CanRelocateNationally => false,
    :CanRelocateInternationally => false,
    :TotalYearsExperience => @total_years_experience.to_s,
    :HostSite => host_site,
    :DesiredJobTypes => 'ETFE',
    :CompanyExperiences => company_experiences,
    :Educations => educations,
    :Languages => [],
    :CustomValues => []
  }
end