Sha256: 7f40d7d2b5e901abf050a79deb03e6e6eaf22d28de40ded98da6a2c3a919ae39

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module Paymill
  module Request
    class Info
      attr_accessor :http_method, :api_url, :data

      def initialize(http_method, api_url, data)
        @http_method = http_method
        @api_url     = api_url
        @data        = data
      end

      def url
        url = "/#{API_VERSION}/#{api_url}"
        if is_refund?
          url += "/#{data[:id]}"
          data.delete(:id)
        end

        url
      end

      def path_with_params(path, params)
        unless params.empty?
          encoded_params = URI.encode_www_form(params)
          [path, encoded_params].join("?")
        else
          path
        end
      end

      protected

      def is_refund?
        api_url == "refunds"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paymill-0.4.0 lib/paymill/request/info.rb