lib/tropo-webapi-ruby/tropo-webapi-ruby.rb
def parse(response)
      response = JSON.parse(response) if response.class == String

      # Check to see what type of response we are working with
      if response['session']
        transformed_response = { 'session' => { } }
        
        response['session'].each_pair do |key, value|
          value = transform_hash value if value.kind_of? Hash
          transformed_response['session'].merge!(transform_pair(key, value))
        end
        
      elsif response['result']
        transformed_response = { 'result' => { } }

        response['result'].each_pair do |key, value|
          value = transform_hash value if value.kind_of? Hash
          value = transform_array value  if value.kind_of? Array
          transformed_response['result'].merge!(transform_pair(key, value))
        end
      end

      transformed_response = Hashie::Mash.new(transformed_response)
    end
##
# Parses the JSON string recieved from Tropo into a Ruby Hash, or 
# if already a Ruby Hash parses it with the nicities provided by
# the gem
#
# @param [String or Hash] a JSON string or a Ruby Hash
# @return [Hash] a Hash representing the formatted response from Tropo
Parses the JSON string recieved from Tropo into a Ruby Hash, or
if already a Ruby Hash parses it with the nicities provided by
the gem
Parses the JSON string recieved from Tropo into a Ruby Hash or if already a Ruby Hash parses it with the nicities provided by the gem
def parse(response)
      response = JSON.parse(response) if response.class == String
      if response['session']
        transformed_response = { 'session' => { } }
        response['session'].each_pair do |key, value|
          value = transform_hash value if value.kind_of? Hash
          transformed_response['session'].merge!(transform_pair(key, value))
        end
      elsif response['result']
        transformed_response = { 'result' => { } }
        response['result'].each_pair do |key, value|
          value = transform_hash value if value.kind_of? Hash
          value = transform_array value  if value.kind_of? Array
          transformed_response['result'].merge!(transform_pair(key, value))
        end
      end
      transformed_response = Hashie::Mash.new(transformed_response)
    end
def parse ( response ) response = JSON . parse ( response ) if response . class == String if response [ 'session' ] transformed_response = { 'session' => { } } response [ 'session' ] . each_pair do | key , value | value = transform_hash value if value . kind_of? Hash transformed_response [ 'session' ] . merge! ( transform_pair ( key , value ) ) end elsif response [ 'result' ] transformed_response = { 'result' => { } } response [ 'result' ] . each_pair do | key , value | value = transform_hash value if value . kind_of? Hash value = transform_array value if value . kind_of? Array transformed_response [ 'result' ] . merge! ( transform_pair ( key , value ) ) end end transformed_response = Hashie :: Mash . new ( transformed_response ) end
Parses the JSON string recieved from Tropo into a Ruby Hash, or
if already a Ruby Hash parses it with the nicities provided by
the gem
Parses the JSON string recieved from Tropo into a Ruby Hash or if already a Ruby Hash parses it with the nicities provided by the gem
# Check to see what type of response we are working with
a Hash representing the formatted response from Tropo
a Hash representing the formatted response from Tropo
Hash
response
a JSON string or a Ruby Hash
a JSON string or a Ruby Hash