quickbooks-ruby 1.0.19 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/quickbooks/model/account_based_expense_line_detail.rb +1 -1
- data/lib/quickbooks/model/base_model.rb +1 -0
- data/lib/quickbooks/model/bill.rb +1 -0
- data/lib/quickbooks/model/invoice.rb +5 -0
- data/lib/quickbooks/model/item_based_expense_line_detail.rb +1 -1
- data/lib/quickbooks/model/preferences.rb +1 -1
- data/lib/quickbooks/model/sales_item_line_detail.rb +1 -1
- data/lib/quickbooks/model/sales_receipt.rb +1 -0
- data/lib/quickbooks/model/vendor_credit.rb +2 -0
- data/lib/quickbooks/service/access_token.rb +6 -1
- data/lib/quickbooks/service/base_service.rb +56 -37
- data/lib/quickbooks/service/payment.rb +6 -0
- data/lib/quickbooks/service/refund_receipt.rb +6 -0
- data/lib/quickbooks/service/upload.rb +1 -5
- data/lib/quickbooks/util/logging.rb +16 -2
- data/lib/quickbooks/version.rb +1 -1
- data/lib/quickbooks-ruby.rb +11 -10
- metadata +59 -13
- data/lib/quickbooks/faraday/middleware/gzip.rb +0 -74
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3090c1e6be59c03b4f8802cd3d56771e01ba508166db446e3bb9a372739d5dd0
|
|
4
|
+
data.tar.gz: 4fdb76a07e05ee92dd3c837622e32ce23cb41ede769928ff198f8cb91d58f5c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26045642638563196533afd56d2a36afa2cdd2a1a8c95a54e6faf0546e99491d144802ae9624df4d1d205e23553965120eeca2fd1b484705a185bcab6633822a
|
|
7
|
+
data.tar.gz: ea5208b840894935844c3a8d3ff06f880877e48b62fb1a1b8b112f82def2d5d4b7960d3008124891bdaa2cd3044711975ffc2404468cc53f54b2b14b5bc4aeb5
|
|
@@ -7,7 +7,7 @@ module Quickbooks
|
|
|
7
7
|
xml_accessor :billable_status, :from => 'BillableStatus'
|
|
8
8
|
xml_accessor :tax_amount, :from => 'UnitPrice', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
|
9
9
|
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
|
10
|
-
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
|
|
10
|
+
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
|
|
11
11
|
|
|
12
12
|
reference_setters :customer_ref, :class_ref, :account_ref, :tax_code_ref
|
|
13
13
|
|
|
@@ -30,6 +30,7 @@ module Quickbooks
|
|
|
30
30
|
|
|
31
31
|
def as_json(options = nil)
|
|
32
32
|
options = {} if options.nil?
|
|
33
|
+
options = options.dup if options.frozen?
|
|
33
34
|
except_conditions = ["roxml_references"]
|
|
34
35
|
except_conditions << options[:except]
|
|
35
36
|
options[:except] = except_conditions.flatten.uniq.compact
|
|
@@ -31,6 +31,7 @@ module Quickbooks
|
|
|
31
31
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
|
32
32
|
xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
|
|
33
33
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
|
34
|
+
xml_accessor :mailing_address, :from => 'VendorAddr', :as => PhysicalAddress
|
|
34
35
|
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
|
35
36
|
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
|
36
37
|
|
|
@@ -61,6 +61,7 @@ module Quickbooks
|
|
|
61
61
|
xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
|
|
62
62
|
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
|
63
63
|
xml_accessor :bill_email_cc, :from => 'BillEmailCc', :as => EmailAddress
|
|
64
|
+
xml_accessor :bill_email_bcc, :from => 'BillEmailBcc', :as => EmailAddress
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
reference_setters
|
|
@@ -93,6 +94,10 @@ module Quickbooks
|
|
|
93
94
|
self.bill_email_cc = EmailAddress.new(email_address_string)
|
|
94
95
|
end
|
|
95
96
|
|
|
97
|
+
def billing_email_bcc_address=(email_address_string)
|
|
98
|
+
self.bill_email_bcc = EmailAddress.new(email_address_string)
|
|
99
|
+
end
|
|
100
|
+
|
|
96
101
|
def wants_billing_email_sent!
|
|
97
102
|
self.email_status = EMAIL_STATUS_NEED_TO_SEND
|
|
98
103
|
end
|
|
@@ -13,7 +13,7 @@ module Quickbooks
|
|
|
13
13
|
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
|
14
14
|
xml_accessor :customer_ref, :from => 'CustomerRef', :as => BaseReference
|
|
15
15
|
xml_accessor :billable_status, :from => 'BillableStatus'
|
|
16
|
-
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
|
|
16
|
+
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
|
|
17
17
|
|
|
18
18
|
reference_setters :item_ref, :class_ref, :price_level_ref, :customer_ref, :tax_code_ref
|
|
19
19
|
end
|
|
@@ -19,7 +19,7 @@ module Quickbooks
|
|
|
19
19
|
PREFERENCE_SECTIONS = {
|
|
20
20
|
:accounting_info => %w(TrackDepartments DepartmentTerminology ClassTrackingPerTxnLine? ClassTrackingPerTxn? CustomerTerminology),
|
|
21
21
|
:product_and_services => %w(ForSales? ForPurchase? QuantityWithPriceAndRate? QuantityOnHand?),
|
|
22
|
-
:
|
|
22
|
+
:vendor_and_purchases => %w(TrackingByCustomer? BillableExpenseTracking? DefaultTerms? DefaultMarkup? POCustomField),
|
|
23
23
|
:time_tracking => %w(UseServices? BillCustomers? ShowBillRateToAll WorkWeekStartDate MarkTimeEntiresBillable?),
|
|
24
24
|
:tax => %w(UsingSalesTax? PartnerTaxEnabled?),
|
|
25
25
|
:currency => %w(MultiCurrencyEnabled? HomeCurrency),
|
|
@@ -9,7 +9,7 @@ module Quickbooks
|
|
|
9
9
|
xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
|
10
10
|
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
|
|
11
11
|
xml_accessor :service_date, :from => 'ServiceDate', :as => Date
|
|
12
|
-
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', to_xml: Proc.new { |val| val.to_f }
|
|
12
|
+
xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
|
|
13
13
|
|
|
14
14
|
reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref
|
|
15
15
|
end
|
|
@@ -22,6 +22,7 @@ module Quickbooks
|
|
|
22
22
|
xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
|
|
23
23
|
xml_accessor :delivery_info, :from => 'DeliveryInfo', :as => DeliveryInfo
|
|
24
24
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
|
25
|
+
xml_accessor :ship_from_address, :from => 'ShipFromAddr', :as => PhysicalAddress
|
|
25
26
|
xml_accessor :po_number, :from => 'PONumber'
|
|
26
27
|
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
|
|
27
28
|
xml_accessor :ship_date, :from => 'ShipDate', :as => Time
|
|
@@ -28,6 +28,8 @@ module Quickbooks
|
|
|
28
28
|
|
|
29
29
|
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
|
30
30
|
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
|
31
|
+
|
|
32
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
|
31
33
|
|
|
32
34
|
reference_setters
|
|
33
35
|
|
|
@@ -22,7 +22,12 @@ module Quickbooks
|
|
|
22
22
|
def disconnect
|
|
23
23
|
connection = Faraday.new(headers: { 'Content-Type' => 'application/json' }) do |f|
|
|
24
24
|
f.adapter(::Quickbooks.http_adapter)
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
if Gem.loaded_specs['faraday'].version >= Gem::Version.create('2.0')
|
|
27
|
+
f.request(:authorization, :basic, oauth.client.id, oauth.client.secret)
|
|
28
|
+
else
|
|
29
|
+
f.basic_auth(oauth.client.id, oauth.client.secret)
|
|
30
|
+
end
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
url = "#{DISCONNECT_URL}?minorversion=#{Quickbooks.minorversion}"
|
|
@@ -49,12 +49,11 @@ module Quickbooks
|
|
|
49
49
|
# [OAuth2] The default Faraday connection does not have gzip or multipart support.
|
|
50
50
|
# We need to reset the existing connection and build a new one.
|
|
51
51
|
def rebuild_connection!
|
|
52
|
-
@oauth.client.connection =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
builder.adapter ::Quickbooks.http_adapter
|
|
52
|
+
@oauth.client.connection = Faraday.new do |f|
|
|
53
|
+
f.request :multipart
|
|
54
|
+
f.request :gzip
|
|
55
|
+
f.request :url_encoded
|
|
56
|
+
f.adapter ::Quickbooks.http_adapter
|
|
58
57
|
end
|
|
59
58
|
end
|
|
60
59
|
|
|
@@ -225,7 +224,7 @@ module Quickbooks
|
|
|
225
224
|
if metadata
|
|
226
225
|
standalone_prefix = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
|
227
226
|
meta_data_xml = "#{standalone_prefix}\n#{metadata.to_xml_ns.to_s}"
|
|
228
|
-
param_part = UploadIO.new(StringIO.new(meta_data_xml), "application/xml")
|
|
227
|
+
param_part = Faraday::UploadIO.new(StringIO.new(meta_data_xml), "application/xml")
|
|
229
228
|
body['file_metadata_0'] = param_part
|
|
230
229
|
end
|
|
231
230
|
|
|
@@ -248,11 +247,7 @@ module Quickbooks
|
|
|
248
247
|
headers['Accept-Encoding'] = HTTP_ACCEPT_ENCODING
|
|
249
248
|
end
|
|
250
249
|
|
|
251
|
-
|
|
252
|
-
log "METHOD = #{method}"
|
|
253
|
-
log "RESOURCE = #{url}"
|
|
254
|
-
log_request_body(body)
|
|
255
|
-
log "REQUEST HEADERS = #{headers.inspect}"
|
|
250
|
+
log_request(method, url, body, headers)
|
|
256
251
|
|
|
257
252
|
request_info = RequestInfo.new(url, headers, body, method)
|
|
258
253
|
before_request.call(request_info) if before_request
|
|
@@ -273,12 +268,8 @@ module Quickbooks
|
|
|
273
268
|
after_request.call(request_info, raw_response.body) if after_request
|
|
274
269
|
|
|
275
270
|
response = Quickbooks::Service::Responses::OAuthHttpResponse.wrap(raw_response)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
log_response_body(response)
|
|
279
|
-
if response.respond_to?(:headers)
|
|
280
|
-
log "RESPONSE HEADERS = #{response.headers}"
|
|
281
|
-
end
|
|
271
|
+
log_response(response)
|
|
272
|
+
|
|
282
273
|
check_response(response, request: body)
|
|
283
274
|
end
|
|
284
275
|
|
|
@@ -354,50 +345,78 @@ module Quickbooks
|
|
|
354
345
|
end
|
|
355
346
|
end
|
|
356
347
|
|
|
357
|
-
def
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
348
|
+
def log_request(method, url, body, headers)
|
|
349
|
+
messages = []
|
|
350
|
+
messages << "------ QUICKBOOKS-RUBY REQUEST ------"
|
|
351
|
+
messages << "METHOD = #{method}"
|
|
352
|
+
messages << "RESOURCE = #{url}"
|
|
353
|
+
messages.concat(request_body_messages(body))
|
|
354
|
+
messages << "REQUEST HEADERS = #{headers.inspect}"
|
|
355
|
+
|
|
356
|
+
log_multiple(messages)
|
|
366
357
|
end
|
|
367
358
|
|
|
368
|
-
def
|
|
369
|
-
|
|
359
|
+
def request_body_messages(body)
|
|
360
|
+
messages = []
|
|
361
|
+
messages << "REQUEST BODY:"
|
|
370
362
|
if is_json?
|
|
371
|
-
|
|
363
|
+
messages << body.inspect
|
|
372
364
|
elsif is_pdf?
|
|
373
|
-
|
|
365
|
+
messages << "BODY is a PDF : not dumping"
|
|
374
366
|
else
|
|
375
367
|
#multipart request for uploads arrive here in a Hash with UploadIO vals
|
|
376
368
|
if body.is_a?(Hash)
|
|
377
369
|
body.each do |k,v|
|
|
378
|
-
|
|
370
|
+
messages << 'BODY PART:'
|
|
379
371
|
val_content = v.inspect
|
|
380
|
-
if v.is_a?(UploadIO)
|
|
372
|
+
if v.is_a?(Faraday::UploadIO)
|
|
381
373
|
if v.content_type == 'application/xml'
|
|
382
374
|
if v.io.is_a?(StringIO)
|
|
383
375
|
val_content = log_xml(v.io.string)
|
|
384
376
|
end
|
|
385
377
|
end
|
|
386
378
|
end
|
|
387
|
-
|
|
379
|
+
messages << "#{k}: #{val_content}"
|
|
388
380
|
end
|
|
389
381
|
else
|
|
390
|
-
|
|
382
|
+
messages << log_xml(body)
|
|
391
383
|
end
|
|
392
384
|
end
|
|
385
|
+
messages
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def log_response(response)
|
|
389
|
+
messages = []
|
|
390
|
+
messages << "------ QUICKBOOKS-RUBY RESPONSE ------"
|
|
391
|
+
messages << "RESPONSE CODE = #{response.code}"
|
|
392
|
+
messages.concat(response_body_messages(response))
|
|
393
|
+
messages << "RESPONSE HEADERS = #{response.headers}" if response.respond_to?(:headers)
|
|
394
|
+
|
|
395
|
+
log_multiple(messages)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
def response_body_messages(response)
|
|
399
|
+
messages = []
|
|
400
|
+
messages << "RESPONSE BODY:"
|
|
401
|
+
if is_json?
|
|
402
|
+
messages << ">>>>#{response.plain_body.inspect}"
|
|
403
|
+
elsif is_pdf?
|
|
404
|
+
messages << "BODY is a PDF : not dumping"
|
|
405
|
+
else
|
|
406
|
+
messages << log_xml(response.plain_body)
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
messages
|
|
393
410
|
end
|
|
394
411
|
|
|
395
412
|
def parse_and_raise_exception(options = {})
|
|
396
413
|
err = parse_intuit_error
|
|
397
|
-
|
|
414
|
+
element_msg = err[:element] ? "#{err[:element]}: " : ""
|
|
415
|
+
ex = Quickbooks::IntuitRequestException.new("#{element_msg}#{err[:message]}:\n\t#{err[:detail]}")
|
|
398
416
|
ex.code = err[:code]
|
|
399
417
|
ex.detail = err[:detail]
|
|
400
418
|
ex.type = err[:type]
|
|
419
|
+
ex.element = err[:element] if err[:element]
|
|
401
420
|
if is_json?
|
|
402
421
|
ex.request_json = options[:request]
|
|
403
422
|
else
|
|
@@ -431,7 +450,7 @@ module Quickbooks
|
|
|
431
450
|
end
|
|
432
451
|
element_attr = error_element.attributes['element']
|
|
433
452
|
if element_attr
|
|
434
|
-
error[:element] =
|
|
453
|
+
error[:element] = element_attr.try(:value)
|
|
435
454
|
end
|
|
436
455
|
error[:message] = error_element.xpath("//xmlns:Message").text
|
|
437
456
|
error[:detail] = error_element.xpath("//xmlns:Detail").text
|
|
@@ -19,6 +19,12 @@ module Quickbooks
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def pdf(payment)
|
|
23
|
+
url = "#{url_for_resource(model::REST_RESOURCE)}/#{payment.id}/pdf"
|
|
24
|
+
response = do_http_raw_get(url, {}, {'Accept' => 'application/pdf'})
|
|
25
|
+
response.plain_body
|
|
26
|
+
end
|
|
27
|
+
|
|
22
28
|
private
|
|
23
29
|
|
|
24
30
|
def model
|
|
@@ -6,6 +6,12 @@ module Quickbooks
|
|
|
6
6
|
delete_by_query_string(refund_receipt)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
def pdf(refund_receipt)
|
|
10
|
+
url = "#{url_for_resource(model::REST_RESOURCE)}/#{refund_receipt.id}/pdf"
|
|
11
|
+
response = do_http_raw_get(url, {}, {'Accept' => 'application/pdf'})
|
|
12
|
+
response.plain_body
|
|
13
|
+
end
|
|
14
|
+
|
|
9
15
|
private
|
|
10
16
|
|
|
11
17
|
def model
|
|
@@ -9,7 +9,7 @@ module Quickbooks
|
|
|
9
9
|
# attachable: Quickbooks::Model::Attachable meta-data details, can be null
|
|
10
10
|
def upload(path_to_file, mime_type, attachable = nil)
|
|
11
11
|
url = url_for_resource("upload")
|
|
12
|
-
uploadIO =
|
|
12
|
+
uploadIO = Faraday::UploadIO.new(path_to_file, mime_type)
|
|
13
13
|
response = do_http_file_upload(uploadIO, url, attachable)
|
|
14
14
|
prefix = "AttachableResponse/xmlns:Attachable"
|
|
15
15
|
if response.code.to_i == 200
|
|
@@ -19,10 +19,6 @@ module Quickbooks
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def class_for_io
|
|
23
|
-
oauth.is_a?(OAuth2::AccessToken) ? Faraday::UploadIO : UploadIO
|
|
24
|
-
end
|
|
25
|
-
|
|
26
22
|
def download(uploadId)
|
|
27
23
|
url = url_for_resource("download/#{uploadId}")
|
|
28
24
|
do_http_get(url, {}, headers)
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
module Quickbooks
|
|
2
2
|
module Util
|
|
3
3
|
module Logging
|
|
4
|
+
attr_writer :log
|
|
5
|
+
|
|
4
6
|
def log(msg)
|
|
5
|
-
::Quickbooks.log(msg)
|
|
7
|
+
::Quickbooks.log(msg) if log?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def log_multiple(messages)
|
|
11
|
+
if condense_logs?
|
|
12
|
+
log(messages.join("\n"))
|
|
13
|
+
else
|
|
14
|
+
messages.each(&method(:log))
|
|
15
|
+
end
|
|
6
16
|
end
|
|
7
17
|
|
|
8
18
|
def log?
|
|
9
|
-
::Quickbooks.log?
|
|
19
|
+
defined?(@log) ? @log : ::Quickbooks.log?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def condense_logs?
|
|
23
|
+
::Quickbooks.condense_logs?
|
|
10
24
|
end
|
|
11
25
|
|
|
12
26
|
def log_xml(str)
|
data/lib/quickbooks/version.rb
CHANGED
data/lib/quickbooks-ruby.rb
CHANGED
|
@@ -8,12 +8,13 @@ require 'date'
|
|
|
8
8
|
require 'forwardable'
|
|
9
9
|
require 'oauth2'
|
|
10
10
|
require 'net/http/post/multipart'
|
|
11
|
+
require 'faraday/multipart'
|
|
12
|
+
require 'faraday/gzip'
|
|
11
13
|
require 'quickbooks/util/collection'
|
|
12
14
|
require 'quickbooks/util/logging'
|
|
13
15
|
require 'quickbooks/util/http_encoding_helper'
|
|
14
16
|
require 'quickbooks/util/name_entity'
|
|
15
17
|
require 'quickbooks/util/query_builder'
|
|
16
|
-
require 'quickbooks/faraday/middleware/gzip'
|
|
17
18
|
|
|
18
19
|
#== OAuth Responses
|
|
19
20
|
require 'quickbooks/service/responses/oauth_http_response'
|
|
@@ -187,9 +188,6 @@ require 'quickbooks/service/transfer'
|
|
|
187
188
|
require 'quickbooks/service/change_data_capture'
|
|
188
189
|
require 'quickbooks/service/refund_receipt_change'
|
|
189
190
|
|
|
190
|
-
# Register Faraday Middleware
|
|
191
|
-
Faraday::Middleware.register_middleware :gzip => lambda { Gzip }
|
|
192
|
-
|
|
193
191
|
module Quickbooks
|
|
194
192
|
@@sandbox_mode = false
|
|
195
193
|
@@logger = nil
|
|
@@ -230,23 +228,26 @@ module Quickbooks
|
|
|
230
228
|
end
|
|
231
229
|
|
|
232
230
|
# set logging on or off
|
|
233
|
-
attr_writer :log, :log_xml_pretty_print
|
|
231
|
+
attr_writer :log, :log_xml_pretty_print, :condense_logs
|
|
234
232
|
|
|
235
233
|
# Returns whether to log. Defaults to 'false'.
|
|
236
234
|
def log?
|
|
237
235
|
@log ||= false
|
|
238
236
|
end
|
|
239
237
|
|
|
238
|
+
# Returns whether to limit log lines
|
|
239
|
+
def condense_logs?
|
|
240
|
+
@condense_logs ||= false
|
|
241
|
+
end
|
|
242
|
+
|
|
240
243
|
# pretty printing the xml in the logs is "on" by default
|
|
241
244
|
def log_xml_pretty_print?
|
|
242
245
|
defined?(@log_xml_pretty_print) ? @log_xml_pretty_print : true
|
|
243
246
|
end
|
|
244
247
|
|
|
245
248
|
def log(msg)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
logger.flush if logger.respond_to?(:flush)
|
|
249
|
-
end
|
|
249
|
+
logger.info(msg)
|
|
250
|
+
logger.flush if logger.respond_to?(:flush)
|
|
250
251
|
end
|
|
251
252
|
end # << self
|
|
252
253
|
|
|
@@ -272,7 +273,7 @@ module Quickbooks
|
|
|
272
273
|
class UnsupportedOperation < Error; end
|
|
273
274
|
|
|
274
275
|
class IntuitRequestException < Error
|
|
275
|
-
attr_accessor :message, :code, :detail, :type, :intuit_tid, :request_xml, :request_json
|
|
276
|
+
attr_accessor :message, :code, :detail, :element, :type, :intuit_tid, :request_xml, :request_json
|
|
276
277
|
|
|
277
278
|
def initialize(msg)
|
|
278
279
|
self.message = msg
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: quickbooks-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cody Caughlan
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-04-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: oauth2
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "<"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "<"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '3.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: roxml
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +94,54 @@ dependencies:
|
|
|
94
94
|
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: faraday
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "<"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "<"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: faraday-multipart
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '1.0'
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: 1.0.4
|
|
121
|
+
type: :runtime
|
|
122
|
+
prerelease: false
|
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - "~>"
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '1.0'
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: 1.0.4
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: faraday-gzip
|
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '1.0'
|
|
138
|
+
type: :runtime
|
|
139
|
+
prerelease: false
|
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '1.0'
|
|
97
145
|
- !ruby/object:Gem::Dependency
|
|
98
146
|
name: rake
|
|
99
147
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -185,7 +233,6 @@ extensions: []
|
|
|
185
233
|
extra_rdoc_files: []
|
|
186
234
|
files:
|
|
187
235
|
- lib/quickbooks-ruby.rb
|
|
188
|
-
- lib/quickbooks/faraday/middleware/gzip.rb
|
|
189
236
|
- lib/quickbooks/model/access_token_response.rb
|
|
190
237
|
- lib/quickbooks/model/account.rb
|
|
191
238
|
- lib/quickbooks/model/account_based_expense_line_detail.rb
|
|
@@ -361,7 +408,7 @@ homepage: http://github.com/ruckus/quickbooks-ruby
|
|
|
361
408
|
licenses:
|
|
362
409
|
- MIT
|
|
363
410
|
metadata: {}
|
|
364
|
-
post_install_message:
|
|
411
|
+
post_install_message:
|
|
365
412
|
rdoc_options: []
|
|
366
413
|
require_paths:
|
|
367
414
|
- lib
|
|
@@ -369,16 +416,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
369
416
|
requirements:
|
|
370
417
|
- - ">="
|
|
371
418
|
- !ruby/object:Gem::Version
|
|
372
|
-
version: '
|
|
419
|
+
version: '2.6'
|
|
373
420
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
421
|
requirements:
|
|
375
422
|
- - ">="
|
|
376
423
|
- !ruby/object:Gem::Version
|
|
377
424
|
version: '0'
|
|
378
425
|
requirements: []
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
signing_key:
|
|
426
|
+
rubygems_version: 3.1.6
|
|
427
|
+
signing_key:
|
|
382
428
|
specification_version: 4
|
|
383
429
|
summary: REST API to Quickbooks Online
|
|
384
430
|
test_files: []
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/gzip.rb
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
|
|
5
|
-
# Middleware to automatically decompress response bodies. If the
|
|
6
|
-
# "Accept-Encoding" header wasn't set in the request, this sets it to
|
|
7
|
-
# "gzip,deflate" and appropriately handles the compressed response from the
|
|
8
|
-
# server. This resembles what Ruby 1.9+ does internally in Net::HTTP#get.
|
|
9
|
-
#
|
|
10
|
-
# This middleware is NOT necessary when these adapters are used:
|
|
11
|
-
# - net_http on Ruby 1.9+
|
|
12
|
-
# - net_http_persistent on Ruby 2.0+
|
|
13
|
-
# - em_http
|
|
14
|
-
class Gzip < Faraday::Middleware
|
|
15
|
-
dependency 'zlib'
|
|
16
|
-
|
|
17
|
-
ACCEPT_ENCODING = 'Accept-Encoding'.freeze
|
|
18
|
-
CONTENT_ENCODING = 'Content-Encoding'.freeze
|
|
19
|
-
CONTENT_LENGTH = 'Content-Length'.freeze
|
|
20
|
-
SUPPORTED_ENCODINGS = 'gzip,deflate,br'.freeze
|
|
21
|
-
RUBY_ENCODING = '1.9'.respond_to?(:force_encoding)
|
|
22
|
-
|
|
23
|
-
def call(env)
|
|
24
|
-
env[:request_headers][ACCEPT_ENCODING] ||= SUPPORTED_ENCODINGS
|
|
25
|
-
@app.call(env).on_complete do |response_env|
|
|
26
|
-
break if response_env[:response_headers].nil?
|
|
27
|
-
|
|
28
|
-
case response_env[:response_headers][CONTENT_ENCODING]
|
|
29
|
-
when 'gzip'
|
|
30
|
-
reset_body(response_env, &method(:uncompress_gzip))
|
|
31
|
-
when 'deflate'
|
|
32
|
-
reset_body(response_env, &method(:inflate))
|
|
33
|
-
when 'br'
|
|
34
|
-
reset_body(response_env, &method(:brotli_inflate))
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def reset_body(env)
|
|
40
|
-
env[:body] = yield(env[:body])
|
|
41
|
-
env[:response_headers].delete(CONTENT_ENCODING)
|
|
42
|
-
env[:response_headers][CONTENT_LENGTH] = env[:body].length
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def uncompress_gzip(body)
|
|
46
|
-
io = StringIO.new(body)
|
|
47
|
-
gzip_reader = if RUBY_ENCODING
|
|
48
|
-
Zlib::GzipReader.new(io, :encoding => 'ASCII-8BIT')
|
|
49
|
-
else
|
|
50
|
-
Zlib::GzipReader.new(io)
|
|
51
|
-
end
|
|
52
|
-
gzip_reader.read
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def inflate(body)
|
|
56
|
-
# Inflate as a DEFLATE (RFC 1950+RFC 1951) stream
|
|
57
|
-
Zlib::Inflate.inflate(body)
|
|
58
|
-
rescue Zlib::DataError
|
|
59
|
-
# Fall back to inflating as a "raw" deflate stream which
|
|
60
|
-
# Microsoft servers return
|
|
61
|
-
inflate = Zlib::Inflate.new(-Zlib::MAX_WBITS)
|
|
62
|
-
begin
|
|
63
|
-
inflate.inflate(body)
|
|
64
|
-
ensure
|
|
65
|
-
inflate.close
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def brotli_inflate(body)
|
|
70
|
-
self.class.dependency 'brotli'
|
|
71
|
-
|
|
72
|
-
Brotli.inflate(body)
|
|
73
|
-
end
|
|
74
|
-
end
|