Class: SolidusTiny::Account

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/solidus_tiny/account.rb

Instance Method Summary collapse

Instance Method Details

#authorization_urlObject



18
19
20
# File 'app/models/solidus_tiny/account.rb', line 18

def authorization_url
  "https://accounts.tiny.com.br/realms/tiny/protocol/openid-connect/auth?client_id=#{client_id}&redirect_uri=#{redirect_url}&response_type=code&state=#{state}"
end

#authorize(code:) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/models/solidus_tiny/account.rb', line 8

def authorize(code:)
  client = ::SolidusTiny::TinyClient.(self)
  client.authorize(code: code, redirect_url: redirect_url)
  update(
    refresh_token: client.get_refresh_token,
    access_token: client.access_token,
    token_expires_in: client.token_expires_at
  )
end