Sha256: a204cc49e94c6bb75af89e5fcbc2ef3eb3da5906c7bf810f438ccac9a6ed27a2

Contents?: true

Size: 879 Bytes

Versions: 15

Compression:

Stored size: 879 Bytes

Contents

module AllscriptsUnityClient

  # Transform Unity responses from Faraday into Hash objects.
  class JSONUnityResponse < UnityResponse

    # See UnityResponse#to_hash.
    def to_hash
      result = @response

      # All JSON magic responses are an array with one item
      result = result.first

      # All JSON magic results contain one key on their object named
      # actioninfo
      result = result.values.first

      # The data in a JSON magic result is always an array. If that array
      # only has a single item, then just return that as the result. This is
      # a compromise as some actions that should always return arrays
      # (i.e. GetProviders) may return a single hash.
      if result.count == 1
        result = result.first
      end

      result = convert_dates_to_utc(result)
      Utilities::recursively_symbolize_keys(result)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
allscripts_unity_client-3.4.1 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.4.0 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.3.1 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.3.0 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.2.2 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.2.1 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.2.0 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.1.3 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.1.2 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.1.1 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.1.0 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-3.0.0 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-2.2.4 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-2.2.3 lib/allscripts_unity_client/json_unity_response.rb
allscripts_unity_client-2.2.2 lib/allscripts_unity_client/json_unity_response.rb