Class: Oodler::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/oodler/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = Oodler.key, options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
# File 'lib/oodler/client.rb', line 7

def initialize(key=Oodler.key,options={})
  @key, @http_options = key,options
end

Instance Attribute Details

#http_optionsObject (readonly)

Returns the value of attribute http_options.



5
6
7
# File 'lib/oodler/client.rb', line 5

def http_options
  @http_options
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/oodler/client.rb', line 5

def key
  @key
end

Instance Method Details

#company_attribute(title) ⇒ Object



66
67
68
# File 'lib/oodler/client.rb', line 66

def company_attribute(title)
     "company_#{title}"
end

#get(path, options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/oodler/client.rb', line 16

def get(path, options={})
  path = "/listings#{path}"
  validate_parameters(options)
  response = web_client.get(path, options)
  raise_errors(response)
  response.body
end

#industry_attribute(title) ⇒ Object



62
63
64
# File 'lib/oodler/client.rb', line 62

def industry_attribute(title)
     "industry_#{title}"
end

#job_title_attribute(title) ⇒ Object



58
59
60
# File 'lib/oodler/client.rb', line 58

def job_title_attribute(title)
    "job_title_#{title}"
end

#job_type_attribute(string) ⇒ Object



70
71
72
# File 'lib/oodler/client.rb', line 70

def job_type_attribute(string)
     "job_type_#{title}"
end

#listing(options = {}) ⇒ Object

the generic pash a hash version example client.listing(:region=>“chicago”, :category => “vehicle/car”) returns an OodleResponse



52
53
54
55
56
# File 'lib/oodler/client.rb', line 52

def listing(options={})
  path = ""
  options= {:query =>options}
  OodleResponse.from_xml(get(path, options))
end

#search(region, options = {}) ⇒ Object

client.search(“chicago”, =>“vehicle/cars”)



25
26
27
28
29
30
# File 'lib/oodler/client.rb', line 25

def search( region, options={})
  options= {:query =>options}
  options[:query].merge!({:region => region}) if region
  
  self.listing(options)
end

#search_by_category(region, category, options = {}) ⇒ Object

helper method - client.search_by_category(“chicago”, “vehicle/car”)



33
34
35
36
37
38
39
# File 'lib/oodler/client.rb', line 33

def search_by_category(region,category, options={})
  options= {:query =>options}
  options[:query].merge!({:region => region}) if region
  options[:query].merge!({:category => category}) if category
  self.listing(options)

end

#usa_job_search(options) ⇒ Object

specify the :location key for city search, i.e :location=>“Houston, Tx”



42
43
44
45
46
# File 'lib/oodler/client.rb', line 42

def usa_job_search(options)
  options.merge!({:region => "usa"})
  options.merge!({:category => "job"})
  self.listing(options)
end

#web_clientObject



11
12
13
# File 'lib/oodler/client.rb', line 11

def web_client
    @web_client ||= Oodler::WebClient.new(@key)
end