module NHS::API
Public Class Methods
Source
# File app/lib/nhs/api.rb, line 13 def access_token fetch_access_token if access_token_expired? @auth_info[:access_token] end
Source
# File app/lib/nhs/api.rb, line 19 def access_token_expired? return true if @auth_info.blank? # 5 seconds to accommodate connection time Time.current > @auth_info[:expires_at] - 5.seconds end
Source
# File app/lib/nhs/api.rb, line 5 def connection return fhir_connection if Settings.nhs_api.disable_authentication fhir_connection.tap do |conn| conn.headers["Authorization"] = "Bearer #{access_token}" end end