Class: BraintreeHttp::FormEncoded

Inherits:
Object
  • Object
show all
Defined in:
lib/braintreehttp/encoder.rb

Instance Method Summary collapse

Instance Method Details

#content_typeObject



87
88
89
# File 'lib/braintreehttp/encoder.rb', line 87

def content_type
  /^application\/x-www-form-urlencoded/
end

#decode(body) ⇒ Object



83
84
85
# File 'lib/braintreehttp/encoder.rb', line 83

def decode(body)
  raise UnsupportedEncodingError.new("FormEncoded does not support deserialization")
end

#encode(request) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/braintreehttp/encoder.rb', line 74

def encode(request)
  encoded_params = []
  request.body.each do |k, v|
    encoded_params.push("#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}")
  end

  encoded_params.join("&")
end