module Firstjob

Constants

VERSION

Public Class Methods

destroy_publication(publication_id) click to toggle source
# File lib/firstjob.rb, line 134
def self.destroy_publication(publication_id)
  destroy_publication_path = "/v0/empresas/avisos/#{publication_id}"
  response = self.delete(destroy_publication_path, @@options)

  return HttpParser.parse_response(response)
end
get_postulation(postulation_id) click to toggle source
# File lib/firstjob.rb, line 127
def self.get_postulation(postulation_id)
  get_postulation_path = "/v0/empresas/postulaciones/#{postulation_id}"
  response = self.get(get_postulation_path, @@options)

  return HttpParser.parse_response_to_json(response)
end
get_postulations_in_publication(publication_id, page=0, postulations_per_page=20) click to toggle source
# File lib/firstjob.rb, line 120
def self.get_postulations_in_publication(publication_id, page=0, postulations_per_page=20)
  get_postulations_in_publication_path = "/v0/empresas/avisos/#{publication_id}/postulaciones"
  response = self.get(get_postulations_in_publication_path, @@options.merge(query: @@options[:query].merge({page: page, perPage: postulations_per_page})))

  return HttpParser.parse_response_to_json(response)
end
get_publication(publication_id) click to toggle source
# File lib/firstjob.rb, line 113
def self.get_publication(publication_id)
  get_publication_path = "/v0/empresas/avisos/#{publication_id}"
  response = self.get(get_publication_path, @@options)

  return HttpParser.parse_response_to_json(response)
end
get_publication_url(publication_id) click to toggle source
# File lib/firstjob.rb, line 109
def self.get_publication_url(publication_id)
  "http://www.laborum.cl/empleos/#{publication_id}.html"
end
publish(params) click to toggle source

Publicaciones creates and publish a publication

# File lib/firstjob.rb, line 72
def self.publish(params)
  publication = Firstjob::Publication.create(params)
  return publication
end
publish_publication(publication_id, pais_id, plan_publication_id) click to toggle source
# File lib/firstjob.rb, line 93
def self.publish_publication(publication_id, pais_id, plan_publication_id)
  publish_publication_path = "/v0/empresas/avisos/#{publication_id}/publicacion/#{plan_publication_id}"
  response = self.put(publish_publication_path, @@options.merge(query: @@options[:query].merge({paisId: pais_id})))

  if HttpParser.parse_response(response)
    case response.code
      when 201
        # "Publication created, All good!"
        return response # body contains id del proceso publicado
      when 200
        # "TODO: Uhm.. no idea, is this good?"
        return response # body contains id del proceso publicado?
    end
  end
end
setup() { |self| ... } click to toggle source

Default way to setup Firstjob.

# File lib/firstjob.rb, line 62
def self.setup
  yield self
  # It does not use basic http auth, it passes the username and password in the body of the request...
  #@@options = {headers: { "Accept" => "application/json", "Content-Type" => "application/json"}, basic_auth: {username: @@username, password: @@password}}
  @@options = {headers: { "Accept" => "application/json", "Content-Type" => "application/json"}}
  @@body = {username: @@username, password: @@password}
end
update_publication(publication_id, json) click to toggle source
# File lib/firstjob.rb, line 77
def self.update_publication(publication_id, json)
  update_publication_path = "/v0/empresas/avisos/#{publication_id}"
  response = self.post(update_publication_path, @@options.merge(body: json, headers: { "Accept" => "application/json", "Content-Type" => "application/json"}))

  if HttpParser.parse_response(response)
    case response.code
      when 201
        # "Publication updated, All good!"
        return response # body contains id del proceso publicado
      when 200
        # "TODO: Uhm.. no idea, is this good?"
        return response # body contains id del proceso publicado?
    end
  end
end