Class: Cb::Clients::Education

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/education.rb

Class Method Summary collapse

Class Method Details

.get_for(country) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cb/clients/education.rb', line 7

def self.get_for(country)
  Cb::Utils::Country.is_valid? country ? country : 'US'
  my_api = Cb::Utils::Api.instance
  json_hash = my_api.cb_get(Cb.configuration.uri_education_code, :query => {:countrycode => country})

  codes = []
  if json_hash.has_key?('ResponseEducationCodes')
    if json_hash['ResponseEducationCodes'].has_key?('EducationCodes') &&
       json_hash['ResponseEducationCodes']['EducationCodes'].has_key?('Education')
        json_hash['ResponseEducationCodes']['EducationCodes']['Education'].each do | education |
          codes << Cb::Models::Education.new(education)
        end
    end
    my_api.append_api_responses(codes, json_hash['ResponseEducationCodes'])
  end

  my_api.append_api_responses(codes, json_hash)
end