Class: AlipayMini::Api::SystemOauthToken

Inherits:
AlipayBase
  • Object
show all
Defined in:
lib/alipay_mini/api/system_oauth_token.rb

Instance Method Summary collapse

Methods inherited from AlipayBase

#base_params, #sign_params, #timestamp

Instance Method Details

#get(grant_type, code) ⇒ Object

when grant_type is ‘authorization_code’, code is the auth_code when grant_type is ‘refresh_token’, code is the refresh_token



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/alipay_mini/api/system_oauth_token.rb', line 7

def get(grant_type, code)
  case grant_type
  when 'authorization_code'
    params = base_params.merge(grant_type: grant_type, code: code)
  when 'refresh_token'
    params = base_params.merge(grant_type: grant_type, refresh_token: code)
  else
    raise ArgumentError, 'grant type not valid, allow type "authorization_code", "refresh_token"'
  end

  AlipayMini::Request.get(method, sign_params(params))
end