Module: ActiveResource::Formats::TwilioFormat

Extended by:
TwilioFormat
Included in:
TwilioFormat
Defined in:
lib/twilio_resource/twilio_format.rb

Instance Method Summary collapse

Instance Method Details

#decode(xml) ⇒ Object



25
26
27
28
# File 'lib/twilio_resource/twilio_format.rb', line 25

def decode(xml)
  TwilioResource.logger.debug("Response: #{xml}")
  from_xml_data(Hash.from_xml(xml))
end

#encode(hash, options = {}) ⇒ Object

twilio uses camelcase for all of its params, and uses a query string for posts.



15
16
17
18
19
20
21
22
23
# File 'lib/twilio_resource/twilio_format.rb', line 15

def encode(hash, options = {})
  camelized_hash = ActiveSupport::OrderedHash.new
  hash.each do |k, v| 
    camelized_hash[k.camelize] = v
  end

  TwilioResource.logger.info("Request: #{camelized_hash.to_query}")
  camelized_hash.to_query
end

#extensionObject



6
7
8
# File 'lib/twilio_resource/twilio_format.rb', line 6

def extension
  ""
end

#mime_typeObject



10
11
12
# File 'lib/twilio_resource/twilio_format.rb', line 10

def mime_type
  'application/x-www-form-urlencoded'
end