Class: PayTrace::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/paytrace/configuration.rb

Constant Summary collapse

RESET_PASSWORD_METHOD =
"UpdatePassword"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



7
8
9
10
11
# File 'lib/paytrace/configuration.rb', line 7

def initialize
  @domain = "paytrace.com"
  @connection = Faraday.new
  @path = "api/default.pay"
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



3
4
5
# File 'lib/paytrace/configuration.rb', line 3

def connection
  @connection
end

#domainObject

Returns the value of attribute domain.



3
4
5
# File 'lib/paytrace/configuration.rb', line 3

def domain
  @domain
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/paytrace/configuration.rb', line 3

def password
  @password
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/paytrace/configuration.rb', line 3

def path
  @path
end

#user_nameObject

Returns the value of attribute user_name.



3
4
5
# File 'lib/paytrace/configuration.rb', line 3

def user_name
  @user_name
end

Instance Method Details

#update_password(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/paytrace/configuration.rb', line 13

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

#urlObject



30
31
32
# File 'lib/paytrace/configuration.rb', line 30

def url
  "https://#{@domain}/#{@path}"
end