class CheckMot::Client
Public Instance Methods
by_vehicle_registration(registration)
click to toggle source
# File lib/check_mot/client.rb, line 4 def by_vehicle_registration(registration) response = get(registration: registration) Resource.new(response.sanitized.first) end
Private Instance Methods
connection()
click to toggle source
# File lib/check_mot/client.rb, line 25 def connection @connection ||= create_connection end
create_connection()
click to toggle source
# File lib/check_mot/client.rb, line 29 def create_connection fail Error.new('api_key not configured') unless CheckMot.configuration.api_key Faraday.new(:url => url) do |builder| builder.headers = headers builder.adapter CheckMot.configuration.http_adapter || Faraday.default_adapter end end
get(params)
click to toggle source
# File lib/check_mot/client.rb, line 11 def get(params) Response.new(connection.get path, params).tap do |response| fail ResponseError.new(response.status, response.raw) unless response.success? end end
headers()
click to toggle source
# File lib/check_mot/client.rb, line 38 def headers { 'Accept': 'application/json+v6', 'x-api-key': CheckMot.configuration.api_key } end
path()
click to toggle source
# File lib/check_mot/client.rb, line 21 def path '/trade/vehicles/mot-tests' end
url()
click to toggle source
# File lib/check_mot/client.rb, line 17 def url 'https://beta.check-mot.service.gov.uk' end