Class: Cassia::Requests::GetToken

Inherits:
Object
  • Object
show all
Defined in:
lib/cassia/requests/get_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_controller) ⇒ GetToken

Returns a new instance of GetToken.



4
5
6
# File 'lib/cassia/requests/get_token.rb', line 4

def initialize(access_controller)
  @access_controller = access_controller
end

Instance Method Details

#body ⇒ Object



12
13
14
# File 'lib/cassia/requests/get_token.rb', line 12

def body
  { 'grant_type' => "client_credentials" }.to_json
end

#headers ⇒ Object



16
17
18
19
20
21
# File 'lib/cassia/requests/get_token.rb', line 16

def headers
  {
    'Authorization' => "Basic #{get_encode}",
    'Content-Type' => "application/json"
  }
end

#path ⇒ Object



8
9
10
# File 'lib/cassia/requests/get_token.rb', line 8

def path
  '/api/oauth2/token'
end

#perform ⇒ Object



23
24
25
# File 'lib/cassia/requests/get_token.rb', line 23

def perform
  Cassia::ResponseHandlers::GetToken.new(@access_controller).handle(Cassia.api.post(self))
end