quickbooks-ruby 1.0.21 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/sales_item_line_detail.rb +1 -1
- data/lib/quickbooks/service/access_token.rb +6 -1
- data/lib/quickbooks/service/base_service.rb +5 -6
- data/lib/quickbooks/version.rb +1 -1
- data/lib/quickbooks-ruby.rb +2 -4
- metadata +38 -12
- 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: 8168dc0e28267b4342b56bdfc689af6a7edb151694fe1fca9fd6e9a827528687
|
4
|
+
data.tar.gz: e6f4f347dff9732e61298357fc74d7ec68cde532718279cb1d785cd6b38909d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88b3bf54416112c1aff009c9c6e9dce8ab437ec806a855627f9abf6dda1804a2419f94bbbe07d04aaa91503bfe8a7a630c0b85fb8f174bb805a4fe901138bd20
|
7
|
+
data.tar.gz: 25421b3b29a88dcca907940274b84b1d10f819489da6a66ffbd7d8b835a3a7d84667ec69bb63d9828df0e6ed916b6183c372d5e05f1a475d01d5f2ffefb56527
|
@@ -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
|
@@ -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,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
|
|
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
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-02 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
|
@@ -100,14 +100,42 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "<"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
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: '
|
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: '1.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.0'
|
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
|
@@ -383,15 +410,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
383
410
|
requirements:
|
384
411
|
- - ">="
|
385
412
|
- !ruby/object:Gem::Version
|
386
|
-
version: '
|
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
|
-
|
394
|
-
rubygems_version: 2.7.6.2
|
420
|
+
rubygems_version: 3.0.3.1
|
395
421
|
signing_key:
|
396
422
|
specification_version: 4
|
397
423
|
summary: REST API to Quickbooks Online
|
@@ -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
|