Sha256: d7cbb03bb4589948346db36b0e86ea0ccc670d0564e7088cd313c6af914e8562

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module PayPal
  class AccessTokenRequest
    attr_accessor :path, :body, :headers, :verb

    def initialize(environment, refreshToken = nil)
      @path = "/v1/oauth2/token"
      @body = {
        :grant_type => "client_credentials",
      }

      if (refreshToken)
        @body[:grant_type] = "refresh_token"
        @body[:refresh_token] = refreshToken
      end

      @headers = {
        "Content-Type" => "application/x-www-form-urlencoded",
        "Authorization" => environment.authorizationString(),
      }
      @verb = "POST"
    end
  end

  class RefreshTokenRequest
    attr_accessor :path, :body, :headers, :verb

    def initialize(environment, authorization_code)
      @path = "/v1/identity/openidconnect/tokenservice"
      @body = {
        :grant_type => "authorization_code",
        :code => authorization_code,
      }
      @headers = {
        "Content-Type" => "application/x-www-form-urlencoded",
        "Authorization" => environment.authorizationString(),
      }
      @verb = "POST"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paypal-payouts-sdk-2.0.1 lib/core/token_requests.rb
paypal-payouts-sdk-1.0.1 lib/core/token_requests.rb
paypal-payouts-sdk-1.0.0 lib/core/token_requests.rb