quickbooks-ruby 1.0.20 → 1.0.22
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/item_based_expense_line_detail.rb +1 -1
- data/lib/quickbooks/model/purchase.rb +1 -0
- data/lib/quickbooks/model/sales_item_line_detail.rb +1 -1
- data/lib/quickbooks/model/vendor_credit.rb +2 -0
- data/lib/quickbooks/service/base_service.rb +45 -27
- data/lib/quickbooks/service/payment.rb +6 -0
- data/lib/quickbooks/util/logging.rb +16 -2
- data/lib/quickbooks/version.rb +1 -1
- data/lib/quickbooks-ruby.rb +8 -5
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0585f4ea094b51b56185bb41a2561c8ac7d23f447a52e58859e2ba9729ba6c1
|
4
|
+
data.tar.gz: 8162ad28904da7934146e3870c068d5cec80bd396209c5247746d19646a452fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cedaedd4ae5acd80f31469a60698a8bbee57e13be5646baaa726268b0e11dc864814ec204dee9d98da8043b6cf5838f8c305b7e08e81cde593574979ef36f6
|
7
|
+
data.tar.gz: 8ba452ae4365df500e8408ac7079759d18e90799ba3c5a2d580f7e566c34bb9ddded4cec6d460e4377a05e105a185e7aa3848f8fd98b9c395f96e338b54ad14c
|
@@ -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
|
|
@@ -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
|
@@ -32,6 +32,7 @@ module Quickbooks
|
|
32
32
|
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
33
33
|
|
34
34
|
xml_accessor :payment_type, :from => 'PaymentType'
|
35
|
+
xml_accessor :payment_method_ref, :from => 'PaymentMethodRef', :as => BaseReference
|
35
36
|
xml_accessor :entity_ref, :from => 'EntityRef', :as => BaseReference
|
36
37
|
xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
|
37
38
|
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
@@ -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
|
@@ -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
|
|
@@ -248,11 +248,7 @@ module Quickbooks
|
|
248
248
|
headers['Accept-Encoding'] = HTTP_ACCEPT_ENCODING
|
249
249
|
end
|
250
250
|
|
251
|
-
|
252
|
-
log "METHOD = #{method}"
|
253
|
-
log "RESOURCE = #{url}"
|
254
|
-
log_request_body(body)
|
255
|
-
log "REQUEST HEADERS = #{headers.inspect}"
|
251
|
+
log_request(method, url, body, headers)
|
256
252
|
|
257
253
|
request_info = RequestInfo.new(url, headers, body, method)
|
258
254
|
before_request.call(request_info) if before_request
|
@@ -273,12 +269,8 @@ module Quickbooks
|
|
273
269
|
after_request.call(request_info, raw_response.body) if after_request
|
274
270
|
|
275
271
|
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
|
272
|
+
log_response(response)
|
273
|
+
|
282
274
|
check_response(response, request: body)
|
283
275
|
end
|
284
276
|
|
@@ -354,28 +346,29 @@ module Quickbooks
|
|
354
346
|
end
|
355
347
|
end
|
356
348
|
|
357
|
-
def
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
349
|
+
def log_request(method, url, body, headers)
|
350
|
+
messages = []
|
351
|
+
messages << "------ QUICKBOOKS-RUBY REQUEST ------"
|
352
|
+
messages << "METHOD = #{method}"
|
353
|
+
messages << "RESOURCE = #{url}"
|
354
|
+
messages.concat(request_body_messages(body))
|
355
|
+
messages << "REQUEST HEADERS = #{headers.inspect}"
|
356
|
+
|
357
|
+
log_multiple(messages)
|
366
358
|
end
|
367
359
|
|
368
|
-
def
|
369
|
-
|
360
|
+
def request_body_messages(body)
|
361
|
+
messages = []
|
362
|
+
messages << "REQUEST BODY:"
|
370
363
|
if is_json?
|
371
|
-
|
364
|
+
messages << body.inspect
|
372
365
|
elsif is_pdf?
|
373
|
-
|
366
|
+
messages << "BODY is a PDF : not dumping"
|
374
367
|
else
|
375
368
|
#multipart request for uploads arrive here in a Hash with UploadIO vals
|
376
369
|
if body.is_a?(Hash)
|
377
370
|
body.each do |k,v|
|
378
|
-
|
371
|
+
messages << 'BODY PART:'
|
379
372
|
val_content = v.inspect
|
380
373
|
if v.is_a?(UploadIO)
|
381
374
|
if v.content_type == 'application/xml'
|
@@ -384,12 +377,37 @@ module Quickbooks
|
|
384
377
|
end
|
385
378
|
end
|
386
379
|
end
|
387
|
-
|
380
|
+
messages << "#{k}: #{val_content}"
|
388
381
|
end
|
389
382
|
else
|
390
|
-
|
383
|
+
messages << log_xml(body)
|
391
384
|
end
|
392
385
|
end
|
386
|
+
messages
|
387
|
+
end
|
388
|
+
|
389
|
+
def log_response(response)
|
390
|
+
messages = []
|
391
|
+
messages << "------ QUICKBOOKS-RUBY RESPONSE ------"
|
392
|
+
messages << "RESPONSE CODE = #{response.code}"
|
393
|
+
messages.concat(response_body_messages(response))
|
394
|
+
messages << "RESPONSE HEADERS = #{response.headers}" if response.respond_to?(:headers)
|
395
|
+
|
396
|
+
log_multiple(messages)
|
397
|
+
end
|
398
|
+
|
399
|
+
def response_body_messages(response)
|
400
|
+
messages = []
|
401
|
+
messages << "RESPONSE BODY:"
|
402
|
+
if is_json?
|
403
|
+
messages << ">>>>#{response.plain_body.inspect}"
|
404
|
+
elsif is_pdf?
|
405
|
+
messages << "BODY is a PDF : not dumping"
|
406
|
+
else
|
407
|
+
messages << log_xml(response.plain_body)
|
408
|
+
end
|
409
|
+
|
410
|
+
messages
|
393
411
|
end
|
394
412
|
|
395
413
|
def parse_and_raise_exception(options = {})
|
@@ -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
|
@@ -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
@@ -230,23 +230,26 @@ module Quickbooks
|
|
230
230
|
end
|
231
231
|
|
232
232
|
# set logging on or off
|
233
|
-
attr_writer :log, :log_xml_pretty_print
|
233
|
+
attr_writer :log, :log_xml_pretty_print, :condense_logs
|
234
234
|
|
235
235
|
# Returns whether to log. Defaults to 'false'.
|
236
236
|
def log?
|
237
237
|
@log ||= false
|
238
238
|
end
|
239
239
|
|
240
|
+
# Returns whether to limit log lines
|
241
|
+
def condense_logs?
|
242
|
+
@condense_logs ||= false
|
243
|
+
end
|
244
|
+
|
240
245
|
# pretty printing the xml in the logs is "on" by default
|
241
246
|
def log_xml_pretty_print?
|
242
247
|
defined?(@log_xml_pretty_print) ? @log_xml_pretty_print : true
|
243
248
|
end
|
244
249
|
|
245
250
|
def log(msg)
|
246
|
-
|
247
|
-
|
248
|
-
logger.flush if logger.respond_to?(:flush)
|
249
|
-
end
|
251
|
+
logger.info(msg)
|
252
|
+
logger.flush if logger.respond_to?(:flush)
|
250
253
|
end
|
251
254
|
end # << self
|
252
255
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbooks-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.22
|
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: 2023-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -375,7 +375,7 @@ homepage: http://github.com/ruckus/quickbooks-ruby
|
|
375
375
|
licenses:
|
376
376
|
- MIT
|
377
377
|
metadata: {}
|
378
|
-
post_install_message:
|
378
|
+
post_install_message:
|
379
379
|
rdoc_options: []
|
380
380
|
require_paths:
|
381
381
|
- lib
|
@@ -390,9 +390,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
390
390
|
- !ruby/object:Gem::Version
|
391
391
|
version: '0'
|
392
392
|
requirements: []
|
393
|
-
|
394
|
-
|
395
|
-
signing_key:
|
393
|
+
rubygems_version: 3.0.3.1
|
394
|
+
signing_key:
|
396
395
|
specification_version: 4
|
397
396
|
summary: REST API to Quickbooks Online
|
398
397
|
test_files: []
|