Class: Supabase::Auth::Types::Session

Inherits:
Struct
  • Object
show all
Defined in:
lib/supabase/auth/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token

Returns:

  • (Object)

    the current value of access_token



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def access_token
  @access_token
end

#expires_atObject

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def expires_at
  @expires_at
end

#expires_inObject

Returns the value of attribute expires_in

Returns:

  • (Object)

    the current value of expires_in



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def expires_in
  @expires_in
end

#provider_refresh_tokenObject

Returns the value of attribute provider_refresh_token

Returns:

  • (Object)

    the current value of provider_refresh_token



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def provider_refresh_token
  @provider_refresh_token
end

#provider_tokenObject

Returns the value of attribute provider_token

Returns:

  • (Object)

    the current value of provider_token



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def provider_token
  @provider_token
end

#refresh_tokenObject

Returns the value of attribute refresh_token

Returns:

  • (Object)

    the current value of refresh_token



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def refresh_token
  @refresh_token
end

#token_typeObject

Returns the value of attribute token_type

Returns:

  • (Object)

    the current value of token_type



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def token_type
  @token_type
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



150
151
152
# File 'lib/supabase/auth/types.rb', line 150

def user
  @user
end

Class Method Details

.from_hash(hash) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/supabase/auth/types.rb', line 161

def self.from_hash(hash)
  return nil if hash.nil?

  expires_at = hash["expires_at"] || hash[:expires_at]
  expires_in = hash["expires_in"] || hash[:expires_in]
  if expires_in && !expires_at
    expires_at = Time.now.round.to_i + expires_in.to_i
  end
  expires_at = expires_at.to_i if expires_at

  new(
    provider_token: hash["provider_token"] || hash[:provider_token],
    provider_refresh_token: hash["provider_refresh_token"] || hash[:provider_refresh_token],
    access_token: hash["access_token"] || hash[:access_token],
    refresh_token: hash["refresh_token"] || hash[:refresh_token],
    token_type: hash["token_type"] || hash[:token_type],
    expires_in: hash["expires_in"] || hash[:expires_in],
    expires_at: expires_at,
    user: User.from_hash(hash["user"] || hash[:user])
  )
end