quickbooks-ruby 1.0.24 → 2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d1813766ca37fe161babf9afc01d1ee20eabb6e52a65dbc5f9d5d535a1ab0e6
4
- data.tar.gz: 75e3fa238c73483049a1f5ea0e87b51d71d9a800d5199c7c27fd3f07069a6092
3
+ metadata.gz: cc115bc7b925447fecb75976b448e66406441c9fd56208e964ac34844fdcd37a
4
+ data.tar.gz: fd1ca0b526c14cdadda7a1e276c3dcedb9b8c68e7c76be0aa074df30c63e0382
5
5
  SHA512:
6
- metadata.gz: 526fb65758bd681ff76f3b63fe078af62479e1568b185131fd08b0a5ddd72e6ce635cf7bf705ee466a41b4f60060c1fe171ccece7e6148ba33d59b785a4b5493
7
- data.tar.gz: 390e88df2ac26d751fb85b6d888cf28227b6d2a706984ea70a5a9aaec0fa2fa003eff9ae11fe53d79a423a03a952a6d6b5d7bf211126a48fc22a52632822716a
6
+ metadata.gz: ce9c6d1732ab2d6ffd2a9ea57c2dad7f091867bb9af828a8bb25140f79a7d739cccd4f59d9b45665ec500d50241e2fbd65c833f4f307d71ba84543cdaec71725
7
+ data.tar.gz: 9bd4d94b4270280b142d93c3ee9bff0b579d4009fc5afe9a217404d201df6e74ea6db8a7fc5b33e48f16e919ea6716bd77f5aeb4e362421db659d1d9f8ac0bf4
@@ -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', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
10
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', 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', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
16
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', 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
- :vendor_and_purchases => %w(TrackingByCustomer? BillableExpenseTracking? DefaultTerms? DefaultMarkup? POCustomField),
22
+ :vendor_and_purchase => %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),
@@ -32,7 +32,6 @@ 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
36
35
  xml_accessor :entity_ref, :from => 'EntityRef', :as => BaseReference
37
36
  xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
38
37
  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', :as => BigDecimal, to_xml: Proc.new { |val| val.to_f }
12
+ xml_accessor :tax_inclusive_amount, from: 'TaxInclusiveAmt', 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,7 +22,7 @@ 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
- f.basic_auth(oauth.client.id, oauth.client.secret)
25
+ f.request(:authorization, :basic, oauth.client.id, oauth.client.secret)
26
26
  end
27
27
 
28
28
  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 = nil
53
- @oauth.client.connection.build do |builder|
54
- builder.use :gzip
55
- builder.request :multipart
56
- builder.request :url_encoded
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
 
@@ -83,11 +82,7 @@ module Quickbooks
83
82
  query ||= default_model_query
84
83
  query = "#{query} STARTPOSITION #{start_position} MAXRESULTS #{max_results}"
85
84
 
86
- URI("#{url_for_base}/query").tap do |uri|
87
- params = Faraday::Utils::ParamsHash.new
88
- params.update(options.merge(query: query))
89
- uri.query = params.to_query
90
- end.to_s
85
+ "#{url_for_base}/query?query=#{CGI.escape(query)}"
91
86
  end
92
87
 
93
88
  private
@@ -120,7 +115,7 @@ module Quickbooks
120
115
  start_position = ((page - 1) * per_page) + 1 # page=2, per_page=10 then we want to start at 11
121
116
  max_results = per_page
122
117
 
123
- response = do_http_get(url_for_query(query, start_position, max_results, options.except(:page, :per_page)))
118
+ response = do_http_get(url_for_query(query, start_position, max_results))
124
119
 
125
120
  parse_collection(response, model)
126
121
  end
@@ -433,6 +428,8 @@ module Quickbooks
433
428
  begin
434
429
  @last_response_xml.xpath("//xmlns:IntuitResponse/xmlns:Fault")[0] != nil
435
430
  rescue Nokogiri::XML::XPath::SyntaxError => exception
431
+ #puts @last_response_xml.to_xml.to_s
432
+ #puts "WTF: #{exception.inspect}:#{exception.backtrace.join("\n")}"
436
433
  true
437
434
  end
438
435
  end
@@ -441,20 +438,20 @@ module Quickbooks
441
438
  error = {:message => "", :detail => "", :type => nil, :code => 0, :intuit_tid => @last_response_intuit_tid}
442
439
  fault = @last_response_xml.xpath("//xmlns:IntuitResponse/xmlns:Fault")[0]
443
440
  if fault
444
- error[:type] = fault.attributes['type'].try(:value)
441
+ error[:type] = fault.attributes['type'].value
445
442
 
446
443
  error_element = fault.xpath("//xmlns:Error")[0]
447
444
  if error_element
448
445
  code_attr = error_element.attributes['code']
449
446
  if code_attr
450
- error[:code] = code_attr.try(:value)
447
+ error[:code] = code_attr.value
451
448
  end
452
449
  element_attr = error_element.attributes['element']
453
450
  if element_attr
454
- error[:element] = code_attr.try(:value)
451
+ error[:element] = code_attr.value
455
452
  end
456
- error[:message] = error_element.xpath("//xmlns:Message").try(:text)
457
- error[:detail] = error_element.xpath("//xmlns:Detail").try(:text)
453
+ error[:message] = error_element.xpath("//xmlns:Message").text
454
+ error[:detail] = error_element.xpath("//xmlns:Detail").text
458
455
  end
459
456
  end
460
457
 
@@ -2,7 +2,7 @@ module Quickbooks
2
2
  module Service
3
3
  class ChangeService < BaseService
4
4
 
5
- def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
5
+ def url_for_query(query = nil, start_position = 1, max_results = 20)
6
6
  q = entity
7
7
  q = "#{q}&#{query}" if query.present?
8
8
 
@@ -6,12 +6,6 @@ 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
-
15
9
  private
16
10
 
17
11
  def model
@@ -1,10 +1,8 @@
1
1
  module Quickbooks
2
2
  module Util
3
3
  module Logging
4
- attr_writer :log
5
-
6
4
  def log(msg)
7
- ::Quickbooks.log(msg) if log?
5
+ ::Quickbooks.log(msg)
8
6
  end
9
7
 
10
8
  def log_multiple(messages)
@@ -16,7 +14,7 @@ module Quickbooks
16
14
  end
17
15
 
18
16
  def log?
19
- defined?(@log) ? @log : ::Quickbooks.log?
17
+ ::Quickbooks.log?
20
18
  end
21
19
 
22
20
  def condense_logs?
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "1.0.24"
3
+ VERSION = "2.0"
4
4
 
5
5
  end
@@ -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
@@ -248,8 +246,10 @@ module Quickbooks
248
246
  end
249
247
 
250
248
  def log(msg)
251
- logger.info(msg)
252
- logger.flush if logger.respond_to?(:flush)
249
+ if log?
250
+ logger.info(msg)
251
+ logger.flush if logger.respond_to?(:flush)
252
+ end
253
253
  end
254
254
  end # << self
255
255
 
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: 1.0.24
4
+ version: '2.0'
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: 2025-04-01 00:00:00.000000000 Z
11
+ date: 2022-11-10 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: '1.4'
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: '1.4'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: roxml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "<"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.0'
103
+ version: '3.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "<"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.0'
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
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday-gzip
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.1'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: rake
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +227,6 @@ extensions: []
199
227
  extra_rdoc_files: []
200
228
  files:
201
229
  - lib/quickbooks-ruby.rb
202
- - lib/quickbooks/faraday/middleware/gzip.rb
203
230
  - lib/quickbooks/model/access_token_response.rb
204
231
  - lib/quickbooks/model/account.rb
205
232
  - lib/quickbooks/model/account_based_expense_line_detail.rb
@@ -375,7 +402,7 @@ homepage: http://github.com/ruckus/quickbooks-ruby
375
402
  licenses:
376
403
  - MIT
377
404
  metadata: {}
378
- post_install_message:
405
+ post_install_message:
379
406
  rdoc_options: []
380
407
  require_paths:
381
408
  - lib
@@ -383,15 +410,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
410
  requirements:
384
411
  - - ">="
385
412
  - !ruby/object:Gem::Version
386
- version: '0'
413
+ version: '2.6'
387
414
  required_rubygems_version: !ruby/object:Gem::Requirement
388
415
  requirements:
389
416
  - - ">="
390
417
  - !ruby/object:Gem::Version
391
418
  version: '0'
392
419
  requirements: []
393
- rubygems_version: 3.1.6
394
- signing_key:
420
+ rubyforge_project:
421
+ rubygems_version: 2.7.6.2
422
+ signing_key:
395
423
  specification_version: 4
396
424
  summary: REST API to Quickbooks Online
397
425
  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