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.



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

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

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_expires_inObject

Returns the value of attribute new_expires_in.



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

def new_expires_in
  @new_expires_in
end

#new_refresh_tokenObject

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

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

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



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 18

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

  response = SynapseClient.request(:post, "/api/v2/user/refresh", data)

  unless response.instance_of?(SynapseClient::Error)
    @new_access_token  = response.data["oauth_consumer_key"]
    @new_refresh_token = response.data["refresh_token"]
    @new_expires_in    = response.data["expires_in"]

    return self
  else
    return response
  end
end