Add NPS client class

This commit is contained in:
2025-10-08 01:44:23 -07:00
parent d43483a7ad
commit c0c3a1beb5
5 changed files with 36 additions and 0 deletions

21
app/lib/nps_client.rb Normal file
View File

@@ -0,0 +1,21 @@
class NpsClient
def self.current
@current ||= new
end
def parks(offset: 0)
conn.get('parks', { start: offset })
end
private
def conn
@conn ||= Faraday.new(
url: 'https://developer.nps.gov/api/v1',
headers: { 'X-Api-Key': ENV.fetch('NPS_API_KEY') }
) do |builder|
builder.response :json
builder.response :raise_error
end
end
end