Class: PayPal::AccessTokenRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/core/token_requests.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, refreshToken = nil) ⇒ AccessTokenRequest

Returns a new instance of AccessTokenRequest.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/core/token_requests.rb', line 5

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/core/token_requests.rb', line 3

def body
  @body
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/core/token_requests.rb', line 3

def headers
  @headers
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/core/token_requests.rb', line 3

def path
  @path
end

#verbObject

Returns the value of attribute verb.



3
4
5
# File 'lib/core/token_requests.rb', line 3

def verb
  @verb
end