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



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

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

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



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

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

#industry_attribute(title) ⇒ Object



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

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

#job_title_attribute(title) ⇒ Object



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

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

#job_type_attribute(string) ⇒ Object



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

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



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

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

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

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



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

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

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

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



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

def search_by_category(region,category, options={})
  options.merge!({:region => region}) if region
  options.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” allow job specializaton, i.e. job/tech



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

def usa_job_search(options)
  options.merge!({:region => "usa"})
  options.merge!({:category => "job"}) unless options && options[:category]
  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