Class: AlipayMini::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/alipay_mini/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_idObject

mini program app id



11
12
13
# File 'lib/alipay_mini/config.rb', line 11

def app_id
  @app_id
end

#charsetObject

charset, default is ‘utf-8’



17
18
19
# File 'lib/alipay_mini/config.rb', line 17

def charset
  @charset
end

#formatObject

format, default is ‘JSON’, only support ‘JSON’



14
15
16
# File 'lib/alipay_mini/config.rb', line 14

def format
  @format
end

#private_keyObject

app private key, use for sign



26
27
28
# File 'lib/alipay_mini/config.rb', line 26

def private_key
  @private_key
end

#public_keyObject

alipay public key, use for verify



29
30
31
# File 'lib/alipay_mini/config.rb', line 29

def public_key
  @public_key
end

#sign_typeObject

sign type, default is ‘RSA2’, support ‘RSA2’ or ‘RSA’



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

def sign_type
  @sign_type
end

#urlObject

api request url



8
9
10
# File 'lib/alipay_mini/config.rb', line 8

def url
  @url
end

#versionObject

version, now is ‘1.0’



23
24
25
# File 'lib/alipay_mini/config.rb', line 23

def version
  @version
end

Instance Method Details

#configurationObject



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

def configuration
  @config ||= {}.tap do |config|
    config[:url] = url if url
    config[:app_id] = app_id if app_id
    config[:private_key] = format_private_key(private_key) if private_key
    config[:public_key] = format_public_key(public_key) if public_key

    config[:version] = '1.0'
    config[:format] = format || 'JSON'
    config[:charset] = charset || 'utf-8'
    config[:sign_type] = sign_type || 'RSA2'
  end
end