Class: Cb::Clients::Education

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

Class Method Summary collapse

Methods inherited from Base

cb_client, headers

Class Method Details

.get_for(country) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cb/clients/education.rb', line 16

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

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

  cb_client.append_api_responses(codes, json_hash)
end