Class: Neuron::Client::GeoTarget

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/neuron-client/model/geo_target.rb

Constant Summary collapse

TYPES =

DO NOT modify, unless you’re absolutely sure of all the ramifications!

%w(COUNTRY REGION METRO CITY)
ATTRIBUTES =
[
  :id,
  :geo_type,      # string, one of TYPES
  :net_acuity_id, # integer
  :abbreviation,  # string
  :full_name,     # string
  :name,          # string
]
EXPECTED_QUERY_PARAMS =
%w(geo_type search limit)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#apply_attributes!, #destroy, #id=, included, #initialize, #new_record?, #save, #to_create_hash, #to_hash, #to_update_hash, #update_attributes, #valid?

Methods included from Base::ClassAndInstanceMethods

#all, #api=, #create, #create!, #find, #validate=

Class Method Details

.query(parameters) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/neuron-client/model/geo_target.rb', line 24

def self.query(parameters)
  if validate?
    unless parameters.all?{|k,v| EXPECTED_QUERY_PARAMS.include?(k.to_s)}
      raise "Unsupported parameters: #{parameters.inspect}"
    end
  end
  data = self.connection.get("geo_targets", parameters)
  validate_against_schema!(:index, data)
  data.map{ |hash| from_hash(hash) }
end

Instance Method Details

#attributesObject



19
20
21
# File 'lib/neuron-client/model/geo_target.rb', line 19

def attributes
  ATTRIBUTES
end