Sha256: c6afef9fd2d8f5a63908d06cb1585ad69806e27d3ae7025470d9a33f4d2c94fe

Contents?: true

Size: 785 Bytes

Versions: 2

Compression:

Stored size: 785 Bytes

Contents

module AlipayMini
  module Api
    class SystemOauthToken < AlipayBase

      # when grant_type is 'authorization_code', code is the auth_code
      # when grant_type is 'refresh_token', code is the refresh_token
      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

      private

      def method
        "alipay.system.oauth.token"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alipay_mini-0.1.1 lib/alipay_mini/api/system_oauth_token.rb
alipay_mini-0.1.0 lib/alipay_mini/api/system_oauth_token.rb