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)__.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/allscripts_unity_client/client_options.rb', line 23

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]

  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

#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)


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

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

#ca_path?Boolean

Return true if ca_path is not empty.

Returns:

  • (Boolean)


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

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

#logger?Boolean

Return true if logger is not nil.

Returns:

  • (Boolean)


110
111
112
# File 'lib/allscripts_unity_client/client_options.rb', line 110

def logger?
  !@logger.nil?
end

#proxy?Boolean

Return true if proxy is set and not empty.

Returns:

  • (Boolean)


105
106
107
# File 'lib/allscripts_unity_client/client_options.rb', line 105

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

#timeout?Boolean

Return true if timeout is not empty.

Returns:

  • (Boolean)


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

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)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/allscripts_unity_client/client_options.rb', line 45

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