Class: SacCountyData::ProcessServers

Inherits:
Object
  • Object
show all
Defined in:
lib/sac_county_data/process_servers.rb

Constant Summary collapse

RESOURCE_URL =
'PROCE-SERVE-LISTI/data.json'.freeze

Class Method Summary collapse

Class Method Details

.allObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sac_county_data/process_servers.rb', line 8

def self.all
  objs = []

  response = Faraday.get("#{API_URL}/#{RESOURCE_URL}/?auth_key=#{SacCountyData.api_key}")
  a = JSON.parse(response.body)['result']['fArray']
  a[6..-1].each_slice(6) do |s|
    obj = {}
    obj[:reg_number]      = s[0]['fStr']
    obj[:type]            = s[1]['fStr']
    obj[:registrant_name] = s[2]['fStr']
    obj[:dba]             = s[3]['fStr']
    obj[:expires_at]      = s[4]['fStr']
    obj[:phone]           = s[5]['fStr']

    objs.push OpenStruct.new obj
  end

  objs
end