mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 08:21:57 -04:00
removed unused code
This commit is contained in:
@@ -43,40 +43,7 @@ class Estimate < ActiveRecord::Base
|
|||||||
EstimateSyncJob.perform_later(doc_number: number)
|
EstimateSyncJob.perform_later(doc_number: number)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Magic Method
|
|
||||||
# Maps Get/Set methods to QBO estimate object
|
|
||||||
def method_missing(sym, *arguments)
|
|
||||||
# Check to see if the method exists
|
|
||||||
if Quickbooks::Model::Estimate.method_defined?(sym)
|
|
||||||
# download details if required
|
|
||||||
pull unless @details
|
|
||||||
method_name = sym.to_s
|
|
||||||
# Setter
|
|
||||||
if method_name[-1, 1] == "="
|
|
||||||
@details.method(method_name).call(arguments[0])
|
|
||||||
# Getter
|
|
||||||
else
|
|
||||||
return @details.method(method_name).call
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# pull the details
|
|
||||||
def pull
|
|
||||||
log "Pulling details for estimate ##{self.id}..."
|
|
||||||
begin
|
|
||||||
raise Exception unless self.id
|
|
||||||
qbo = QboConnectionService.current!
|
|
||||||
@details = qbo.perform_authenticated_request do |access_token|
|
|
||||||
service = Quickbooks::Service::Estimate.new(company_id: qbo.realm_id, access_token: access_token)
|
|
||||||
service(:estimate).fetch_by_id(self.id)
|
|
||||||
end
|
|
||||||
rescue Exception => e
|
|
||||||
@details = Quickbooks::Model::Estimate.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def log(msg)
|
def log(msg)
|
||||||
Rails.logger.info "[Estimate] #{msg}"
|
Rails.logger.info "[Estimate] #{msg}"
|
||||||
|
|||||||
Reference in New Issue
Block a user