mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
Cleaning up uneeded code
This commit is contained in:
@@ -51,20 +51,15 @@ class QboController < ApplicationController
|
||||
#redirect_uri = qbo_oauth_callback_url
|
||||
redirect_uri = "https://redmine.rickbarrette.org/qbo/oauth_callback/"
|
||||
if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)
|
||||
# save your tokens here. For example:
|
||||
# quickbooks_credentials.update_attributes(access_token: resp.token, refresh_token: resp.refresh_token,
|
||||
# realm_id: params[:realmId])
|
||||
|
||||
# Remove the last authentication information
|
||||
Qbo.delete_all
|
||||
|
||||
# Save the authentication information
|
||||
qbo = Qbo.new
|
||||
qbo.qb_token = resp.token
|
||||
qbo.qb_secret = resp.refresh_token
|
||||
qbo.token_expires_at = 6.months.from_now.utc
|
||||
qbo.reconnect_token_at = 3.months.from_now.utc
|
||||
qbo.company_id = params[:realmId]
|
||||
|
||||
# Generate Access Token & Serialize it into the database
|
||||
access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)
|
||||
qbo.token = access_token.to_hash
|
||||
qbo.expire = 1.hour.from_now.utc
|
||||
|
||||
@@ -10,12 +10,16 @@
|
||||
|
||||
class Qbo < ActiveRecord::Base
|
||||
unloadable
|
||||
validates_presence_of :qb_token, :qb_secret, :company_id, :token_expires_at, :reconnect_token_at
|
||||
#validates_presence_of :qb_token, :qb_secret, :company_id, :token_expires_at, :reconnect_token_at
|
||||
validates_presence_of :token, :company_id, :expire
|
||||
serialize :token
|
||||
|
||||
OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
|
||||
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
|
||||
|
||||
#
|
||||
# Getter for quickbooks OAuth2 client
|
||||
#
|
||||
def self.get_client
|
||||
oauth_params = {
|
||||
site: "https://appcenter.intuit.com/connect/oauth2",
|
||||
@@ -25,13 +29,19 @@ class Qbo < ActiveRecord::Base
|
||||
return OAuth2::Client.new(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, oauth_params)
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Getter for oauth consumer
|
||||
#
|
||||
def self.get_oauth_consumer
|
||||
# Quickbooks Config Info
|
||||
return $qb_oauth_consumer
|
||||
end
|
||||
|
||||
#
|
||||
# Get a quickbooks base service object for type
|
||||
# @params type of base
|
||||
#
|
||||
def self.get_base(type)
|
||||
# lets getnourbold access token from the database
|
||||
oauth2_client = get_client
|
||||
|
||||
Reference in New Issue
Block a user