class Gdsapi::Methods::GetCountries

Private Instance Methods

parse(body) click to toggle source

Parsing routine to be executed while performing action @param [Hash] body - parsed JSON payload from GDS @return [Array] parsed set of countries

# File lib/gdsapi/methods/get_countries.rb, line 16
def parse(body)
  return [] if body.empty?

  countries = body['countries']
  attributes = body['attributes']
  types = body['types']
  result = {}
  result[:countries] = countries.map! do |country|
    country[:attributes] = match_attributes(country['attributes'], attributes)
    Gdsapi::Structs::Country.new country.symbolize_keys
  end
  result[:types] = types.map { |t| Gdsapi::Structs::Type.new(t.symbolize_keys) }
  result
end
path() click to toggle source
# File lib/gdsapi/methods/get_countries.rb, line 9
def path
  'countries'
end
permitted_params() click to toggle source

Query params :offset [Number|String] - number of records to be skipped when fetching chunks (optional) :limit [Number|String] - number of records to be fetched when fetching chunks (optional)

# File lib/gdsapi/methods/get_countries.rb, line 34
def permitted_params
  %i(limit offset])
end