Class: ColoBiz::DataFetcher

Inherits:
Object
  • Object
show all
Includes:
QueryMethod
Defined in:
lib/colo_biz/data_fetcher.rb

Instance Method Summary collapse

Methods included from QueryMethod

#custom_query, #search_by_agent_full_name, #search_by_agent_mailing_city, #search_by_agent_mailing_state, #search_by_agent_mailing_zipcode, #search_by_agent_principal_city, #search_by_agent_principal_country, #search_by_agent_principal_state, #search_by_agent_principal_zipcode, #search_by_entity_name, #search_by_entity_status, #search_by_entity_type, #search_by_entity_type_verbatum, #search_by_principal_city, #search_by_principal_country, #search_by_principal_state, #search_by_principal_zipcode, #search_for_entities_, #search_for_entities_formed_before, #search_for_entity_formations_after

Constructor Details

#initializeDataFetcher

Returns a new instance of DataFetcher.



6
7
8
9
10
11
12
# File 'lib/colo_biz/data_fetcher.rb', line 6

def initialize
  @conn = Faraday.new(:url => 'https://data.colorado.gov') do |faraday|
    faraday.request  :url_encoded             # form-encode POST params
    faraday.response :logger                  # log requests to STDOUT
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  end
end

Instance Method Details

#biz_entityObject



14
15
16
17
18
19
20
# File 'lib/colo_biz/data_fetcher.rb', line 14

def biz_entity
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json"
  end
  @parsed = JSON.parse(response.body)
  make_biz_entities(@parsed)
end

#make_biz_entities(entities) ⇒ Object



22
23
24
25
26
# File 'lib/colo_biz/data_fetcher.rb', line 22

def make_biz_entities(entities)
  entities.map do |entity|
    BizEntity.new(entity)
  end
end