Class: SynapseClient::RefreshedTokens

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_client/refreshed_tokens.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RefreshedTokens

Returns a new instance of RefreshedTokens.



10
11
12
13
14
15
# File 'lib/synapse_client/refreshed_tokens.rb', line 10

def initialize(options = {})
  options = Map.new(options)

  @old_access_token = options[:old_access_token]
  @old_refresh_token = options[:old_refresh_token]
end

Instance Attribute Details

#new_access_tokenObject (readonly)

Returns the value of attribute new_access_token.



7
8
9
# File 'lib/synapse_client/refreshed_tokens.rb', line 7

def new_access_token
  @new_access_token
end

#new_refresh_tokenObject (readonly)

Returns the value of attribute new_refresh_token.



8
9
10
# File 'lib/synapse_client/refreshed_tokens.rb', line 8

def new_refresh_token
  @new_refresh_token
end

#old_access_tokenObject (readonly)

Returns the value of attribute old_access_token.



5
6
7
# File 'lib/synapse_client/refreshed_tokens.rb', line 5

def old_access_token
  @old_access_token
end

#old_refresh_tokenObject (readonly)

Returns the value of attribute old_refresh_token.



6
7
8
# File 'lib/synapse_client/refreshed_tokens.rb', line 6

def old_refresh_token
  @old_refresh_token
end

Instance Method Details

#refresh_old_tokensObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/synapse_client/refreshed_tokens.rb', line 17

def refresh_old_tokens
  data = {
    :grant_type => "refresh_token",
    :refresh_token => @old_refresh_token
  }

  request = SynapseClient::Request.new("/oauth2/access_token", data)
  response = request.post

  unless response.instance_of?(SynapseClient::Error)
    self.new_access_token  = response["access_token"]
    self.new_refresh_token = response["refresh_token"]

    return self
  else
    return response
  end

end