Module: Paymax1::Config

Defined in:
lib/paymax1/config.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
    :host                       => 'http://172.30.21.20:9001',
   # :host                       => 'https://www.paymax.cc/merchant-api/v1/',
    :rsa_private_key_path       => '',
    :secret_key                 => '',
    :paymax_rsa_public_key_path => ''
}
UA =
{
    :'lang' => 'ruby',
    :'publisher' => 'Paymax',
    :'sdk-version' => VERSION.to_s,
}
REQUIRED_OPTION_KEYS =
[:rsa_private_key_path, :secret_key,:paymax_rsa_public_key_path]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.settingsObject (readonly)

Returns the value of attribute settings.



20
21
22
# File 'lib/paymax1/config.rb', line 20

def settings
  @settings
end

.user_agentObject (readonly)

Returns the value of attribute user_agent.



20
21
22
# File 'lib/paymax1/config.rb', line 20

def user_agent
  @user_agent
end

Class Method Details

.initialize_connect(options = {}) ⇒ Object

初始化配置



23
24
25
26
27
28
29
30
# File 'lib/paymax1/config.rb', line 23

def initialize_connect options = {}
  @user_agent = UA
  @user_agent.store('os.platform',os_family())
  @settings = DEFAULT_OPTIONS.merge!(options)
  REQUIRED_OPTION_KEYS.each do |opt|
    raise MissingArgsException, [opt] unless settings.has_key?(opt)
  end
end

.os_familyObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/paymax1/config.rb', line 32

def os_family
      case RUBY_PLATFORM
        when /ix/i, /ux/i, /gnu/i, /sysv/i, /solaris/i,/sunos/i, /bsd/i
          "unix"
        when /win/i, /ming/i
          "windows"
        else
         "other"
     end
end