Class: Courtfinder::Client::HousingPossession

Inherits:
Object
  • Object
show all
Defined in:
lib/courtfinder/client.rb

Constant Summary collapse

PATH =
'/search/results.json?aol=Housing+possession&postcode='

Instance Method Summary collapse

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/courtfinder/client.rb', line 24

def empty?
  @json.empty?
end

#get(postcode) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/courtfinder/client.rb', line 11

def get postcode
  conn = nil
  begin
    endpoint = "#{Courtfinder::SERVER}#{PATH}#{URI.escape(postcode)}"
    conn = Excon.get(endpoint, :read_timeout => 90)
    check_for_error_code conn
  rescue Excon::Errors::RequestTimeout
    @json = { error: 'timeout' }
  end

  @json
end