lib/bumeran.rb in bumeran-0.2.4 vs lib/bumeran.rb in bumeran-0.3.0
- old
+ new
@@ -3,11 +3,11 @@
require 'httparty'
require 'erb'
module Bumeran
include HTTParty
- base_uri 'https://developers.bumeran.com'
+ base_uri 'https://api.bumeran.com'
# API login configuration, need initialization setup to work
mattr_accessor :grant_type
@@grant_type = "password"
@@ -59,10 +59,20 @@
# Default way to setup Bumeran.
def self.setup
yield self
end
+ def self.environment(use_environment="production")
+ if use_environment == "production"
+ Bumeran.base_uri('https://api.bumeran.com')
+ elsif use_environment == "development"
+ Bumeran.base_uri('https://developers.bumeran.com')
+ else
+ Bumeran.base_uri('https://developers.bumeran.com')
+ end
+ end
+
def self.initialize
unless has_valid_access_token?
login
@@options = { query: {access_token: @@access_token} }
end
@@ -128,10 +138,27 @@
return response # body contains id del proceso publicado?
end
end
end
+ def self.update_publication(publication_id, json)
+ Bumeran.initialize
+ 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 Parser.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
+
def self.publish_publication(publication_id, pais_id, plan_publication_id)
Bumeran.initialize
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})))
@@ -145,10 +172,14 @@
return response # body contains id del proceso publicado?
end
end
end
+ def self.get_publication_url(publication_id)
+ "http://www.laborum.cl/empleos/#{publication_id}.html"
+ end
+
def self.get_publication(publication_id)
Bumeran.initialize
get_publication_path = "/v0/empresas/avisos/#{publication_id}"
response = self.get(get_publication_path, @@options)
@@ -347,30 +378,30 @@
end
# Servicios generales asociados a datos de localizaciĆ³n
def self.get_paises
Bumeran.initialize
- paises_path = "/v0/empresas/localizaciones/paises"
+ paises_path = "/v0/empresas/locacion/paises"
response = self.get(paises_path, @@options)
paises_json = Parser.parse_response_to_json(response)
Parser.parse_json_to_hash(paises_json, @@paises)
end
def self.get_zonas_in(pais_id)
Bumeran.initialize
- zonas_path = "/v0/empresas/localizaciones/paises/#{pais_id}/zonas"
+ zonas_path = "/v0/empresas/locacion/paises/#{pais_id}/zonas"
response = self.get(zonas_path, @@options)
json_zonas = Parser.parse_response_to_json(response)
Parser.parse_json_to_hash(json_zonas, @@zonas) # to save the zone in the zonas hash
Parser.parse_json_to_hash(json_zonas, {}) # to return only the zonas from the country
end
def self.get_localidades_in(zona_id)
Bumeran.initialize
- localidades_path = "/v0/empresas/localizaciones/zonas/#{zona_id}/localidades"
+ localidades_path = "/v0/empresas/locacion/zonas/#{zona_id}/localidades"
response = self.get(localidades_path, @@options)
json = Parser.parse_response_to_json(response)
Parser.parse_json_to_hash(json, @@localidades) # to save the localidades
Parser.parse_json_to_hash(json, {}) # to return only the localidades from the zone
@@ -505,10 +536,10 @@
# Servicios de la experiencia laboral de los postulantes
def self.get_experiencia_laboral(experiencia_laboral_id)
Bumeran.initialize
- experiencia_laboral_path = "/v0/experienciasLaborales/#{experiencia_laboral_id}"
+ experiencia_laboral_path = "/v0/experienciaLaborales/#{experiencia_laboral_id}"
response = self.get(experiencia_laboral_path, @@options)
return Parser.parse_response_to_json(response)
end