Class: CivicInformation::RepresentativesResource
- Inherits:
-
Object
- Object
- CivicInformation::RepresentativesResource
- Defined in:
- lib/civic_information/models/representatives_resource.rb
Defined Under Namespace
Classes: Address, Channel, Division, Office, Official
Instance Attribute Summary collapse
-
#divisions ⇒ Object
Returns the value of attribute divisions.
-
#offices ⇒ Object
Returns the value of attribute offices.
-
#officials ⇒ Object
Returns the value of attribute officials.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response:) ⇒ RepresentativesResource
constructor
A new instance of RepresentativesResource.
Constructor Details
#initialize(response:) ⇒ RepresentativesResource
Returns a new instance of RepresentativesResource.
16 17 18 19 20 |
# File 'lib/civic_information/models/representatives_resource.rb', line 16 def initialize(response:) @divisions = build_divisions(response.parsed_response["divisions"] || []) @offices = build_offices(response.parsed_response["offices"] || []) @officials = build_officials(response.parsed_response["officials"] || []) end |
Instance Attribute Details
#divisions ⇒ Object
Returns the value of attribute divisions.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource.rb', line 3 def divisions @divisions end |
#offices ⇒ Object
Returns the value of attribute offices.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource.rb', line 3 def offices @offices end |
#officials ⇒ Object
Returns the value of attribute officials.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource.rb', line 3 def officials @officials end |
Class Method Details
.where(address: nil, roles: nil, levels: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/civic_information/models/representatives_resource.rb', line 5 def self.where(address: nil, roles: nil, levels: nil) response = CivicInformation.get "/representatives", query: { key: CivicInformation.configuration.google_api_key, address: address, roles: roles, levels: levels }.delete_if { |k, v| v.nil? } self.new response: response end |