quickbooks-ruby 1.0.23 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b741bafa2526fd6ff2686ed3b57ad4dd6dcb5899dfe93b18847bb2b62088b7d
4
- data.tar.gz: afac6ffcc890ecbbb89bfe80402b3ff1a32753692104c52b140bc90dab772f94
3
+ metadata.gz: cc115bc7b925447fecb75976b448e66406441c9fd56208e964ac34844fdcd37a
4
+ data.tar.gz: fd1ca0b526c14cdadda7a1e276c3dcedb9b8c68e7c76be0aa074df30c63e0382
5
5
  SHA512:
6
- metadata.gz: 7dc090c1fa9ec77d616276b1548c34f9412bbd2f6bfbf5cb59209357370d18ec19ebd13c2f44c52f86ed76bdfc23fcc7d0fdcba91baf51516e892bb2c3af634e
7
- data.tar.gz: abbf29a2c505eeb9bee8aab89d62d3c46b5154def85bd5bc5e63f6a4abcaa195d49dd99011ab823bda1129b304c0299f2069d862cf9143f81deea70046728895
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
@@ -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
 
@@ -429,6 +428,8 @@ module Quickbooks
429
428
  begin
430
429
  @last_response_xml.xpath("//xmlns:IntuitResponse/xmlns:Fault")[0] != nil
431
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")}"
432
433
  true
433
434
  end
434
435
  end
@@ -437,20 +438,20 @@ module Quickbooks
437
438
  error = {:message => "", :detail => "", :type => nil, :code => 0, :intuit_tid => @last_response_intuit_tid}
438
439
  fault = @last_response_xml.xpath("//xmlns:IntuitResponse/xmlns:Fault")[0]
439
440
  if fault
440
- error[:type] = fault.attributes['type'].try(:value)
441
+ error[:type] = fault.attributes['type'].value
441
442
 
442
443
  error_element = fault.xpath("//xmlns:Error")[0]
443
444
  if error_element
444
445
  code_attr = error_element.attributes['code']
445
446
  if code_attr
446
- error[:code] = code_attr.try(:value)
447
+ error[:code] = code_attr.value
447
448
  end
448
449
  element_attr = error_element.attributes['element']
449
450
  if element_attr
450
- error[:element] = code_attr.try(:value)
451
+ error[:element] = code_attr.value
451
452
  end
452
- error[:message] = error_element.xpath("//xmlns:Message").try(:text)
453
- 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
454
455
  end
455
456
  end
456
457
 
@@ -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.23"
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.23
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: 2024-02-12 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,16 +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
- rubyforge_project:
420
+ rubyforge_project:
394
421
  rubygems_version: 2.7.6.2
395
- signing_key:
422
+ signing_key:
396
423
  specification_version: 4
397
424
  summary: REST API to Quickbooks Online
398
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