Class: Lighthouse::Facilities::Client

Inherits:
Common::Client::Base show all
Defined in:
lib/lighthouse/facilities/client.rb

Overview

Instance Method Summary collapse

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#get_by_id(id) ⇒ Lighthouse::Facilities::Facility

Request a single facility

Examples:

client.get_by_id(vha_358)

Parameters:

  • id (String)

    the id of the facility created by combining the type of facility and station number

Returns:



21
22
23
24
# File 'lib/lighthouse/facilities/client.rb', line 21

def get_by_id(id)
  response = perform(:get, "/services/va_facilities/v0/facilities/#{id}", nil)
  Lighthouse::Facilities::Response.new(response.body, response.status).facility
end

#get_facilities(params) ⇒ Array<Lighthouse::Facilities::Facility>

Request a list of facilities matching the params provided

Examples:

client.get_facilities(bbox: [60.99, 10.54, 180.00, 20.55])

client.get_facilities(ids: ‘vha_358,vba_358’)

client.get_facilities(lat: 10.54, long: 180.00, per_page: 50, page: 2)

Parameters:

Returns:



35
36
37
38
39
40
# File 'lib/lighthouse/facilities/client.rb', line 35

def get_facilities(params)
  response = perform(:get, '/services/va_facilities/v0/facilities', params)
  facilities = Lighthouse::Facilities::Response.new(response.body, response.status).facilities
  facilities.reject!(&:mobile?) if params['exclude_mobile']
  facilities
end

#nearby(params) ⇒ Array<Lighthouse::Facilities::NearbyFacility>

Request a list of nearby facilities based on calculated drive time bands

  • Returns only health facilities

  • Returns only facilities within a 90-minute drive time

  • Does not respect per_page parameter

Examples:

client.nearby(street_address: ‘123 Fake Street’, city: ‘Springfield’, state: ‘IL’, zip: ‘62703’)

client.nearby(lat: 10.54, lng: 180.00)

Parameters:

Returns:



53
54
55
56
# File 'lib/lighthouse/facilities/client.rb', line 53

def nearby(params)
  response = perform(:get, '/services/va_facilities/v0/nearby', params)
  Lighthouse::Facilities::NearbyResponse.new(response.body, response.status).facilities
end