Sha256: 2708ee0bcfd38ab77d404d8fafb977aca6fdd63d7913dc6d5e329ec2ac88b3d9

Contents?: true

Size: 606 Bytes

Versions: 5

Compression:

Stored size: 606 Bytes

Contents

require 'json'

class MercadoPago::Client
  module Preferences
    def create_preferences(preferences)
      response = send_preferences_request(preferences)
      @preferences_response = JSON.parse(response)
    rescue RestClient::Exception => e
      @errors << I18n.t(:authentication_error, scope: :mercado_pago)
      raise RuntimeError.new(e.message)
    end

    private

    def send_preferences_request(preferences)
      RestClient.post(preferences_url(access_token), preferences.to_json,
                      :content_type => 'application/json', :accept => 'application/json')
    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/preferences.rb
spree_mercado_pago-0.2.2 app/models/mercado_pago/client/preferences.rb
spree_mercado_pago-0.2.1 app/models/mercado_pago/client/preferences.rb
spree_mercado_pago-0.2.0 app/models/mercado_pago/client/preferences.rb
spree_mercado_pago_payment_method-0.2.0 app/models/mercado_pago/client/preferences.rb