Update qbo.rb

This commit is contained in:
2020-01-04 13:59:09 -05:00
committed by GitHub
parent 45859bef3e
commit 41e10d9b0e

View File

@@ -36,17 +36,19 @@ class Qbo < ActiveRecord::Base
account = first account = first
access_token = OAuth2::AccessToken.new(oauth2_client, account.qb_secret, refresh_token: account.qb_secret) access_token = OAuth2::AccessToken.new(oauth2_client, account.qb_secret, refresh_token: account.qb_secret)
qbo = self.first
#save the access #save the access
if self.expire.nil? if qbo.expire.nil?
self.token = access_token qbo.token = access_token
self.expire = 1.hour.from_now.utc qbo.expire = 1.hour.from_now.utc
self.save! qbo.save!
else else
if self.expire.to_date.past? if qbo.expire.to_date.past?
new_access_token_object = access_token.refresh! new_access_token_object = access_token.refresh!
self.token = new_access_token_object qbo.token = new_access_token_object
self.expire = 1.hour.from_now.utc qbo.expire = 1.hour.from_now.utc
self.save! qbo.save!
access_token = new_access_token_object access_token = new_access_token_object
end end
end end