Class: Rubykassa::Configuration

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

Constant Summary collapse

ATTRIBUTES =
[
  :login, :first_password, :second_password, :mode, :http_method,
  :xml_http_method, :success_callback, :fail_callback, :result_callback,
  :hash_algorithm
]
HASH_ALGORITHMS =
[:md5, :ripemd160, :sha1, :sha256, :sha384, :sha512]

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rubykassa/configuration.rb', line 12

def initialize
  self. = 'your_login'
  self.first_password   = 'first_password'
  self.second_password  = 'second_password'
  self.mode             = :test
  self.http_method      = :get
  self.xml_http_method  = :get
  self.hash_algorithm   = :md5
  self.success_callback = ->(notification) { render text: 'success' }
  self.fail_callback    = ->(notification) { render text: 'fail' }
  self.result_callback  = ->(notification) do
    render text: notification.success
  end
end

Instance Method Details

#correct_hash_algorithm?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rubykassa/configuration.rb', line 39

def correct_hash_algorithm?
  HASH_ALGORITHMS.include?(hash_algorithm)
end

#correct_http_method?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rubykassa/configuration.rb', line 31

def correct_http_method?
  [:get, :post].include?(http_method)
end

#correct_mode?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rubykassa/configuration.rb', line 27

def correct_mode?
  [:test, :production].include?(mode)
end

#correct_xml_http_method?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rubykassa/configuration.rb', line 35

def correct_xml_http_method?
  [:get, :post].include?(xml_http_method)
end