class Antech::Client
Attributes
auth_token[R]
Public Class Methods
new(credentials = nil)
click to toggle source
# File lib/antech/client.rb, line 10 def initialize(credentials = nil) raise ArgumentError.new 'Credentials are required to initialize the client' if credentials.nil? [:clinic_id, :username, :password].each do |key| raise ArgumentError.new ":#{key} is required to initialize the client" if credentials[key].nil? end @auth_token = login(credentials) end
Public Instance Methods
lab_results()
click to toggle source
# File lib/antech/client.rb, line 20 def lab_results Antech::Resources::LabResult.new(auth_token) end
tests()
click to toggle source
# File lib/antech/client.rb, line 24 def tests Antech::Resources::Test.new(auth_token) end
Private Instance Methods
login(credentials)
click to toggle source
# File lib/antech/client.rb, line 30 def login(credentials) response = RestClient.post( 'https://onlineapi.antechdiagnostics.com/api/v1.1/Users/Login', { ClinicID: credentials[:clinic_id], UserName: credentials[:username], Password: credentials[:password] } ) JSON.parse(response)['Token'] end