Class: Firstjob::Publication

Inherits:
Object
  • Object
show all
Defined in:
lib/firstjob/publication.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Publication

Returns a new instance of Publication.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/firstjob/publication.rb', line 8

def initialize(attributes={})
  # Default values
  @salary = 0
  @location = "Chile"
  @career_status_id = 1
  @years_experience = 0
  @english_level_id = 1
  @excel_level_id = 1

  attributes.each do |key, value|
    self.send("#{key}=", value)
  end
end

Instance Attribute Details

#career_status_idObject

Returns the value of attribute career_status_id.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def career_status_id
  @career_status_id
end

#careers_idsObject

Returns the value of attribute careers_ids.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def careers_ids
  @careers_ids
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def description
  @description
end

#english_level_idObject

Returns the value of attribute english_level_id.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def english_level_id
  @english_level_id
end

#excel_level_idObject

Returns the value of attribute excel_level_id.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def excel_level_id
  @excel_level_id
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def id
  @id
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def location
  @location
end

#looking_for_idObject

Returns the value of attribute looking_for_id.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def looking_for_id
  @looking_for_id
end

#postulantesObject

Returns the value of attribute postulantes.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def postulantes
  @postulantes
end

#salaryObject

Returns the value of attribute salary.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def salary
  @salary
end

#slugObject

Returns the value of attribute slug.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def slug
  @slug
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def status
  @status
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def title
  @title
end

#universities_idsObject

Returns the value of attribute universities_ids.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def universities_ids
  @universities_ids
end

#years_experienceObject

Returns the value of attribute years_experience.



3
4
5
# File 'lib/firstjob/publication.rb', line 3

def years_experience
  @years_experience
end

Class Method Details

.create(params) ⇒ Object



26
27
28
29
# File 'lib/firstjob/publication.rb', line 26

def self.create(params)
  publication = new(params)
  response = publication.publish()
end

Instance Method Details

#bodyObject



22
23
24
# File 'lib/firstjob/publication.rb', line 22

def body
  default_publication_json()
end

#destroyObject



65
66
67
68
69
70
71
72
# File 'lib/firstjob/publication.rb', line 65

def destroy
  response = Firstjob.post("/api/doregister_job",
                           Firstjob.options.merge(
                             body: Firstjob.body.merge({job_id: id}).to_json
                            )
                          )
  response_body = HttpParser.parse_response(response)
end

#postulantsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/firstjob/publication.rb', line 51

def postulants
  # Get postulants
  response = Firstjob.post("/api/get_applicants_job",
                           Firstjob.options.merge(
                             body: Firstjob.body.merge({job_id: @id}).to_json
                            )
                          )
  response_body = HttpParser.parse_json_response(response)

  # load results
  @postulantes = response_body["postulantes"]
  return @postulantes
end

#publishObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/firstjob/publication.rb', line 31

def publish
  # Post publication
  response = Firstjob.post("/api/publish_job",
                           Firstjob.options.merge(
                             body: Firstjob.body.merge({publish_job: self.body}).to_json
                            )
                          )
  response_body = HttpParser.parse_json_response(response)

  # load results
  @slug = response_body["slug"]
  @id = response_body["id"]
  @status = response_body["status"]
  return self
end

#urlObject



47
48
49
# File 'lib/firstjob/publication.rb', line 47

def url
  "#{Firstjob.base_uri}/jobs/#{slug}"
end