Class: AllscriptsUnityClient::JSONUnityRequest

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

Overview

Transform a Unity request into a Hash suitable for sending using Faraday.

Instance Attribute Summary

Attributes inherited from UnityRequest

#appname, #parameters, #raw_dates, #security_token, #timezone

Instance Method Summary collapse

Methods inherited from UnityRequest

#initialize

Constructor Details

This class inherits a constructor from AllscriptsUnityClient::UnityRequest

Instance Method Details

#to_hashObject

Convert the parameters to a Hash for Faraday with all possible dates converted to the Organization’s localtime.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/allscripts_unity_client/json_unity_request.rb', line 8

def to_hash
  action = @parameters[:action]
  userid = @parameters[:userid]
  appname = @parameters[:appname] || @appname
  patientid = @parameters[:patientid]
  token = @parameters[:token] || @security_token
  parameter1 = process_date(@parameters[:parameter1]) || ''
  parameter2 = process_date(@parameters[:parameter2]) || ''
  parameter3 = process_date(@parameters[:parameter3]) || ''
  parameter4 = process_date(@parameters[:parameter4]) || ''
  parameter5 = process_date(@parameters[:parameter5]) || ''
  parameter6 = process_date(@parameters[:parameter6]) || ''
  data = Utilities::encode_data(@parameters[:data]) || ''

  {
    'Action' => action,
    'AppUserID' => userid,
    'Appname' => appname,
    'PatientID' => patientid,
    'Token' => token,
    'Parameter1' => parameter1,
    'Parameter2' => parameter2,
    'Parameter3' => parameter3,
    'Parameter4' => parameter4,
    'Parameter5' => parameter5,
    'Parameter6' => parameter6,
    'Data' => data
  }
end