class PayTrace::Configuration
Contains necessary configuration to access the API
server; notably the user name, password, and URL information
Public Class Methods
new()
click to toggle source
Default initializer. Do not call directly; instead use the PayTrace.configure
method Example:
PayTrace.configure do |config| config.user_name = "demo123" config.password = "password" config.domain = "stage.paytrace.com" config.path = "api/default.pay" end
Note: sane defaults are provided for the domain and path; typically you only need to supply the user name and password.
# File lib/paytrace/configuration.rb, line 20 def initialize @domain = "paytrace.com" @connection = Faraday.new @path = "api/default.pay" end
Public Instance Methods
update_password(params)
click to toggle source
Updates the API
password. Parameters are passed in a hash. They are:
-
:new_password – the new password to use
# File lib/paytrace/configuration.rb, line 28 def update_password(params) request = PayTrace::API::Request.new request.set_param(:method, RESET_PASSWORD_METHOD) request.set_param(:new_password, params[:new_password]) request.set_param(:new_password_confirmation, params[:new_password]) gateway = PayTrace::API::Gateway.new response = gateway.send_request(request) unless response.has_errors? PayTrace.configure do |config| config.password = params[:new_password] end end response end
url()
click to toggle source
Returns the API
URL, based off the domain and path configured.
# File lib/paytrace/configuration.rb, line 46 def url "https://#{@domain}/#{@path}" end