Class: AllscriptsUnityClient::ClientOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/allscripts_unity_client/client_options.rb

Overview

Contains various options for Unity configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ClientOptions

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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

Instance Attribute Details

#appnameObject

Returns the value of attribute appname.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def appname
  @appname
end

#base_unity_urlObject

Returns the value of attribute base_unity_url.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def base_unity_url
  @base_unity_url
end

#ca_fileObject

Returns the value of attribute ca_file.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ca_file
  @ca_file
end

#ca_pathObject

Returns the value of attribute ca_path.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ca_path
  @ca_path
end

#ehr_passwordObject

Returns the value of attribute ehr_password.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ehr_password
  @ehr_password
end

#ehr_useridObject

Returns the value of attribute ehr_userid.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ehr_userid
  @ehr_userid
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def password
  @password
end

#proxyObject

Returns the value of attribute proxy.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def proxy
  @proxy
end

#raw_datesObject

Returns the value of attribute raw_dates.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def raw_dates
  @raw_dates
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def timeout
  @timeout
end

#timezoneObject

Returns the value of attribute timezone.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def timezone
  @timezone
end

#use_ubiquityObject

Returns the value of attribute use_ubiquity.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def use_ubiquity
  @use_ubiquity
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def username
  @username
end

Instance Method Details

#ca_file?Boolean

Return true if ca_file is not empty.

Returns:

  • (Boolean)


124
125
126
# File 'lib/allscripts_unity_client/client_options.rb', line 124

def ca_file?
  !@ca_file.to_s.strip.empty?
end

#ca_path?Boolean

Return true if ca_path is not empty.

Returns:

  • (Boolean)


129
130
131
# File 'lib/allscripts_unity_client/client_options.rb', line 129

def ca_path?
  !@ca_path.to_s.strip.empty?
end

#logger?Boolean

Return true if logger is not nil.

Returns:

  • (Boolean)


119
120
121
# File 'lib/allscripts_unity_client/client_options.rb', line 119

def logger?
  !@logger.nil?
end

#proxy?Boolean

Return true if proxy is set and not empty.

Returns:

  • (Boolean)


114
115
116
# File 'lib/allscripts_unity_client/client_options.rb', line 114

def proxy?
  !@proxy.to_s.strip.empty?
end

#timeout?Boolean

Return true if timeout is not empty.

Returns:

  • (Boolean)


134
135
136
# File 'lib/allscripts_unity_client/client_options.rb', line 134

def timeout?
  !@timeout.to_s.strip.empty?
end

#validate_options(options = {}) ⇒ Object

Validates options by ensuring that all required options are present.

See #initialize.

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
# 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