class Cb::Models::Job

Attributes

apply_requirements[RW]
apply_url[RW]
begin_date[RW]
begin_date_time[RW]
bonus[RW]
can_be_quick_applied[RW]
categories[RW]
category_codes[RW]
city[RW]
commission[RW]
company[RW]
company_details_url[RW]
company_did[RW]
company_image_url[RW]
company_name[RW]
contact_email_url[RW]
contact_fax[RW]
contact_name[RW]
contact_phone[RW]
degree_required[RW]
degree_required_code[RW]
description[RW]
description_teaser[RW]
details_url[RW]
did[RW]
display_job_id[RW]
distance[RW]
divison[RW]
employment_type[RW]
employment_type_code[RW]
end_date[RW]
end_date_time[RW]
experience_required[RW]
experience_required_code[RW]
external_application[W]
external_apply_url[RW]
industry[RW]
industry_codes[RW]
is_screener_apply[W]
is_shared_job[W]
jc_custom_fields[RW]
job_branding[RW]
job_skin[RW]
job_skin_did[RW]
job_tracking_url[RW]
latitude[RW]
location[RW]
location_formatted[RW]
location_metro_city[RW]
location_street_1[RW]
location_street_2[RW]
longitude[RW]
manages_others[W]
manages_others_code[RW]
manages_others_string[RW]
pay[RW]
pay_other[RW]
pay_per[RW]
posted_date[RW]
posted_time[RW]
posting_date[RW]
relevancy[RW]
relocation_covered[W]
relocation_options[RW]
requirements[RW]
service_url[RW]
similar_jobs_url[RW]
state[RW]
title[RW]
travel_required[RW]
travel_required_code[RW]
zip[RW]

Public Class Methods

new(args = {}) click to toggle source
Calls superclass method Cb::Models::ApiResponseModel::new
# File lib/cb/models/implementations/job.rb, line 35
def initialize(args = {})
  super(args)
end

Public Instance Methods

can_be_quick_applied?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 63
def can_be_quick_applied?
  @can_be_quick_applied.downcase == 'true'
end
external_application?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 43
def external_application?
  @external_application.downcase == 'true'
end
find_company() click to toggle source
# File lib/cb/models/implementations/job.rb, line 39
def find_company
  @company ||= Cb::CompanyApi.find_for self
end
has_questionnaire?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 67
def has_questionnaire?
  @has_questionnaire.downcase == 'true'
end
manages_others?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 51
def manages_others?
  @manages_others.downcase == 'true'
end
relocation_covered?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 47
def relocation_covered?
  @relocation_covered.downcase == 'true'
end
screener_apply?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 55
def screener_apply?
  @is_screener_apply.downcase == 'true'
end
shared_job?() click to toggle source
# File lib/cb/models/implementations/job.rb, line 59
def shared_job?
  @is_shared_job.downcase == 'true'
end

Protected Instance Methods

load_extra_fields(_args) click to toggle source
# File lib/cb/models/implementations/job.rb, line 197
def load_extra_fields(_args)
  # for internal use only :)
end
required_fields() click to toggle source
# File lib/cb/models/implementations/job.rb, line 89
def required_fields
  []
end
set_model_properties() click to toggle source
# File lib/cb/models/implementations/job.rb, line 93
def set_model_properties
  args = api_response

  # General
  @did                          = args['DID'] || args['JobDID'] || ''
  @title                        = args['JobTitle'] || args['Title'] || ''
  @employment_type              = args['EmploymentType'] || ''
  @employment_type_code         = args['EmploymentTypeCode'] || ''
  @latitude                     = args['LocationLatitude'] || ''
  @longitude                    = args['LocationLongitude'] || ''
  @location_street_1            = args['LocationStreet1'] || ''
  @location_street_2            = args['LocationStreet2'] || ''
  @location_formatted           = args['LocationFormatted'] || ''
  @location_metro_city          = args['LocationMetroCity'] || ''

  # Job Skin Related
  @job_skin                     = args.key?('JobSkin') && !args['JobSkin'].nil? ? args['JobSkin']['#cdata-section'] : ''
  @job_skin_did                 = args['JobSkinDID'] || ''
  begin
    @job_branding                 = @job_skin_did.empty? ? '' : Cb.job_branding.find_by_id(job_skin_did)
  rescue Cb::BadRequestError
    @job_branding                 = ''
  end
  @job_tracking_url             = args['JobTrackingURL'] || ''
  @display_job_id               = args['DisplayJobID'] || ''

  # Compensation
  @pay                          = args['PayHighLowFormatted'] || args['Pay'] || ''
  @pay_per                      = args['PayPer'] || ''
  @commission                   = args.key?('PayCommission') && !args['PayCommission'].nil? ? args['PayCommission']['Money']['FormattedAmount'] : ''
  @bonus                        = args.key?('PayBonus') && !args['PayBonus'].nil? ? args['PayBonus']['Money']['FormattedAmount'] : ''
  @pay_other                    = args.key?('PayOther') && !args['PayOther'].nil? ? args['PayOther'] : ''

  # Job Search related
  @description_teaser           = args['DescriptionTeaser'] || ''
  @posted_date                  = args['PostedDate'] || ''
  @posted_time                  = args['PostedTime'] || ''
  @distance                     = args['Distance'] || ''
  @details_url                  = args['JobDetailsURL'] || ''
  @service_url                  = args['JobServiceURL'] || ''
  @location                     = args['Location'] || ''
  @similar_jobs_url             = args['SimilarJobsURL'] || ''

  # Summary
  @categories                   = args['Categories'] || ''
  @category_codes               = args['CategoriesCodes'] || ''
  @degree_required              = args['DegreeRequired'] || ''
  @degree_required_code         = args['DegreeRequiredCode'] || ''
  @experience_required          = args['ExperienceRequired'] || ''
  @experience_required_code     = args['ExperienceRequiredCode'] || ''
  @travel_required              = args['TravelRequired'] || ''
  @travel_required_code         = args['TravelRequiredCode'] || ''
  @relocation_covered           = args['RelocationCovered'] || ''
  @relocation_options           = args['RelocationOptions'] || ''
  @division                     = args['Division'] || ''
  @industry                     = args['Industry'] || ''
  @industry_codes               = args['IndustryCodes'] || ''
  @manages_others               = args['ManagesOthers'] || ''
  @manages_others_code          = args['ManagesOthersCode'] || ''
  @manages_others_string        = args['ManagesOthersString'] || ''

  # Contact Info
  @contact_email_url            = args['ContactInfoEmailURL'] || ''
  @contact_fax                  = args['ContactInfoFax'] || ''
  @contact_name                 = args['ContactInfoName'] || ''
  @contact_phone                = args['ContactInfoPhone'] || ''

  # Job Details related
  @description                  = args['Description'] || args['JobDescription'] || ''
  @requirements                 = args['JobRequirements'] || ''
  @begin_date                   = args['BeginDate'] || ''
  @begin_date_time              = args['BeginDateTime'] || ''
  @end_date                     = args['EndDate'] || ''
  @end_date_time                = args['EndDateTime'] || ''
  @has_questionnaire            = args['HasQuestionnaire'] || ''

  # Application
  @apply_url                    = args['ApplyURL'] || ''
  @external_apply_url           = args['ExternalApplyURL'] || ''
  @external_application         = args['ExternalApplication'] || ''
  @is_screener_apply            = args['IsScreenerApply'] || ''
  @is_shared_job                = args['IsSharedJob'] || ''
  @can_be_quick_applied         = args['CanBeQuickApplied'] || ''
  @apply_requirements           = Cb::Utils::ResponseArrayExtractor.extract(args, 'ApplyRequirements')

  # Company related
  @company_did                  = args['CompanyDID'] || ''
  @company_image_url            = args['CompanyImageURL'] || ''

  # Recommendations related
  @relevancy                    = args['Relevancy'] || ''
  @state                        = args['LocationState'] || ''
  @city                         = args['LocationCity'] || ''
  @zip                          = args['LocationPostalCode'] || ''
  @posting_date                 = args['PostingDate'] || ''

  @jc_custom_fields             = args['JCCustomField'] || ''

  @company_name            = figure_out_company_info(args['Company'], args['Company'], 'CompanyName')
  @company_details_url     = figure_out_company_info(args['CompanyDetailsURL'], args['Company'], 'CompanyDetailsURL')

  load_extra_fields(args)
end

Private Instance Methods

figure_out_company_info(job_search, recommendation, rec_key) click to toggle source
# File lib/cb/models/implementations/job.rb, line 203
def figure_out_company_info(job_search, recommendation, rec_key)
  # Job Search and Recommendations both use this class as a model. Unfortunately, they both return company_name and
  # company_details_url in different ways. Job search returns it in args[company] and args[company_details_url],
  # but recommendations returns it in args[company][key]. This has been ticketed to the API team, and this logic
  # will be removed when they have fixed the issue.
  if job_search.class != Hash && job_search != ''
    return job_search
  elsif recommendation.class == Hash && !recommendation[rec_key].nil?
    return recommendation[rec_key]
  else
    return ''
  end
end