Class: AllscriptsUnityClient::UnityResponse
- Inherits:
- 
      Object
      
        - Object
- AllscriptsUnityClient::UnityResponse
 
- Defined in:
- lib/allscripts_unity_client/unity_response.rb
Overview
Transform Unity responses from Savon into Hash objects.
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #response  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute response. 
- 
  
    
      #timezone  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute timezone. 
Instance Method Summary collapse
- 
  
    
      #initialize(response, timezone)  ⇒ UnityResponse 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Constructor. 
- 
  
    
      #to_hash  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Convert the Unity response to a Hash with symbolized snake_case keys and convert all dates to UTC. 
Constructor Details
#initialize(response, timezone) ⇒ UnityResponse
Constructor.
- response
- 
The response to transform. 
- timezone
- 
An ActiveSupport:TimeZone instance. 
| 13 14 15 16 17 18 19 | # File 'lib/allscripts_unity_client/unity_response.rb', line 13 def initialize(response, timezone) raise ArgumentError, 'timezone can not be nil' if timezone.nil? raise ArgumentError, 'response can not be nil' if response.nil? @response = response @timezone = timezone end | 
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
| 7 8 9 | # File 'lib/allscripts_unity_client/unity_response.rb', line 7 def response @response end | 
#timezone ⇒ Object
Returns the value of attribute timezone.
| 7 8 9 | # File 'lib/allscripts_unity_client/unity_response.rb', line 7 def timezone @timezone end | 
Instance Method Details
#to_hash ⇒ Object
Convert the Unity response to a Hash with symbolized snake_case keys and convert all dates to UTC.
| 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # File 'lib/allscripts_unity_client/unity_response.rb', line 23 def to_hash result = @response[:magic_response][:magic_result][:diffgram] result = strip_attributes(result) result = convert_dates_to_utc(result) if result.nil? return [] end # All magic responses wrap their result in an ActionResponse element result = result.values.first # Often the first element in ActionResponse is an element # called ActionInfo, but in some cases it has a different name # so we just get the first element. result.values.first end |