Sha256: cd492fbbb7f0906528eae0c62e48f37c801ac0179bc98af98336360651f97ac6

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'json'

class MercadoPago::Client
  module API
    def redirect_url
      point_key = sandbox ? 'sandbox_init_point' : 'init_point'
      @preferences_response[point_key]
    end

    private

    def notifications_url(operation_id)
      sandbox_part = sandbox ? 'sandbox/' : ''
      "https://api.mercadolibre.com/#{sandbox_part}collections/notifications/#{operation_id}"
    end

    def search_url
      sandbox_part = sandbox ? 'sandbox/' : ''
      "https://api.mercadolibre.com/#{sandbox_part}collections/search"
    end

    def create_url(url, params={})
      uri = URI(url)
      uri.query = URI.encode_www_form(params)
      uri.to_s
    end

    def preferences_url(token)
      create_url('https://api.mercadolibre.com/checkout/preferences', access_token: token)
    end

    def sandbox
      @api_options[:sandbox]
    end

    def get(url, request_options={}, options={})
      response = RestClient.get(url, request_options)
      JSON.parse(response)
    rescue => e
      raise e unless options[:quiet]
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spree_mercado_pago-0.2.3 app/models/mercado_pago/client/api.rb
spree_mercado_pago-0.2.2 app/models/mercado_pago/client/api.rb
spree_mercado_pago-0.2.1 app/models/mercado_pago/client/api.rb
spree_mercado_pago-0.2.0 app/models/mercado_pago/client/api.rb
spree_mercado_pago_payment_method-0.2.0 app/models/mercado_pago/client/api.rb