class AllscriptsUnityClient::ClientOptions

Contains various options for Unity configuration.

Attributes

appname[R]
base_unity_url[R]
ca_file[RW]
ca_path[RW]
ehr_password[RW]
ehr_userid[RW]
logger[RW]
password[R]
proxy[RW]
raw_dates[R]
timeout[RW]
timezone[R]
use_ubiquity[R]
username[R]

Public Class Methods

new(options = {}) click to toggle source

Constructor.

options
  • :username - Unity license username for security token __(required)__.

  • :password - Unity license password for security token __(required)__.

  • :appname - Unity license appname __(required)__.

  • :proxy - A string URL pointing to an HTTP proxy (optional, primarily for debugging)

  • :logger - A Ruby object that adheres to the same interface as Logger.

  • :ca_file - A string path for a CA File on the OS (JSON only).

  • :cs_path - A string path for a CA directory (JSON only).

  • :timeout - The number of seconds to set the HTTP response timeout and keepalive timeout (JSON only).

  • :base_unity_url - The URL where a Unity server is located (i.e. unity.server.com) __(required)__

  • :ehr_userid - Allscripts EHR Username for user authentication __(required)__.

  • :ehr_password - EHR Password for user authentication __(required)__.

  • :use_ubiquity - Specifies whether the base_unity_url is a ubiquity endpoint

# File lib/allscripts_unity_client/client_options.rb, line 24
def initialize(options = {})
  @username = options[:username]
  @password = options[:password]
  @appname = options[:appname]
  @proxy = options[:proxy]
  @logger = options[:logger]
  @ca_file = options[:ca_file]
  @ca_path = options[:ca_path]
  @timeout = options[:timeout]
  @ehr_userid = options[:ehr_userid]
  @ehr_password = options[:ehr_password]
  @use_ubiquity = options[:use_ubiquity] || false

  self.timezone = options[:timezone]
  self.base_unity_url = options[:base_unity_url]
  self.raw_dates = options[:raw_dates]

  validate_options
end

Public Instance Methods

appname=(appname) click to toggle source

Mutator for appname.

Ensures appname is not nil,

# File lib/allscripts_unity_client/client_options.rb, line 93
def appname=(appname)
  validate_options(appname: appname)
  @appname = appname
end
base_unity_url=(base_unity_url) click to toggle source

Mutator for @base_unity_url.

Strips trailing slash for URL.

# File lib/allscripts_unity_client/client_options.rb, line 62
def base_unity_url=(base_unity_url)
  validate_options(base_unity_url: base_unity_url)
  @base_unity_url = base_unity_url.gsub(/\/$/, '')
end
ca_file?() click to toggle source

Return true if ca_file is not empty.

# File lib/allscripts_unity_client/client_options.rb, line 124
def ca_file?
  !@ca_file.to_s.strip.empty?
end
ca_path?() click to toggle source

Return true if ca_path is not empty.

# File lib/allscripts_unity_client/client_options.rb, line 129
def ca_path?
  !@ca_path.to_s.strip.empty?
end
logger?() click to toggle source

Return true if logger is not nil.

# File lib/allscripts_unity_client/client_options.rb, line 119
def logger?
  !@logger.nil?
end
password=(password) click to toggle source

Mutator for password.

Ensures password is not nil,

# File lib/allscripts_unity_client/client_options.rb, line 85
def password=(password)
  validate_options(password: password)
  @password = password
end
proxy?() click to toggle source

Return true if proxy is set and not empty.

# File lib/allscripts_unity_client/client_options.rb, line 114
def proxy?
  !@proxy.to_s.strip.empty?
end
raw_dates=(raw_dates) click to toggle source
# File lib/allscripts_unity_client/client_options.rb, line 109
def raw_dates=(raw_dates)
  @raw_dates = raw_dates || false
end
timeout?() click to toggle source

Return true if timeout is not empty.

# File lib/allscripts_unity_client/client_options.rb, line 134
def timeout?
  !@timeout.to_s.strip.empty?
end
timezone=(timezone) click to toggle source

Mutator for timezone.

Ensures timezone is not nil,

# File lib/allscripts_unity_client/client_options.rb, line 101
def timezone=(timezone)
  if !timezone.nil?
    @timezone = ActiveSupport::TimeZone[timezone]
  else
    @timezone = ActiveSupport::TimeZone['Etc/UTC']
  end
end
use_ubiquity=(use_ubiquity) click to toggle source

Mutator for @use_ubiquity.

defaults value to false if nil

# File lib/allscripts_unity_client/client_options.rb, line 70
def use_ubiquity=(use_ubiquity)
  @use_ubiquity = use_ubiquity || false
end
username=(username) click to toggle source

Mutator for username.

Ensures username is not nil,

# File lib/allscripts_unity_client/client_options.rb, line 77
def username=(username)
  validate_options(username: username)
  @username = username
end
validate_options(options = {}) click to toggle source

Validates options by ensuring that all required options are present.

See initialize.

# File lib/allscripts_unity_client/client_options.rb, line 47
def validate_options(options = {})
  base_unity_url = options.fetch(:base_unity_url, @base_unity_url)
  username = options.fetch(:username, @username)
  password = options.fetch(:password, @password)
  appname = options.fetch(:appname, @appname)

  raise ArgumentError, 'base_unity_url can not be nil' if base_unity_url.nil?
  raise ArgumentError, 'username can not be nil' if username.nil?
  raise ArgumentError, 'password can not be nil' if password.nil?
  raise ArgumentError, 'appname can not be nil' if appname.nil?
end