Sha256: f47e1d6048a8d12542f523060e3e5cc7c8b3432e4d9102e51a35b764256bb53f

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

require 'uri'

module PayPalHttp
  class FormEncoded
    def initialize
      @parser = URI::Parser.new()
    end

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

      encoded_params.join("&")
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paypalhttp-2.0.1 lib/paypalhttp/serializers/form_encoded.rb