quickbooks-ruby 1.0.26 → 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 +4 -4
- data/lib/quickbooks/model/account_based_expense_line_detail.rb +1 -1
- data/lib/quickbooks/model/base_model.rb +0 -1
- data/lib/quickbooks/model/item_based_expense_line_detail.rb +1 -1
- data/lib/quickbooks/model/preferences.rb +1 -1
- data/lib/quickbooks/model/purchase.rb +0 -1
- data/lib/quickbooks/model/sales_item_line_detail.rb +1 -1
- data/lib/quickbooks/model/sales_receipt.rb +0 -1
- data/lib/quickbooks/service/access_token.rb +1 -1
- data/lib/quickbooks/service/base_service.rb +14 -17
- data/lib/quickbooks/service/change_service.rb +1 -1
- data/lib/quickbooks/service/refund_receipt.rb +0 -6
- data/lib/quickbooks/util/logging.rb +2 -4
- data/lib/quickbooks/version.rb +1 -1
- data/lib/quickbooks-ruby.rb +6 -10
- metadata +42 -18
- data/lib/quickbooks/faraday/middleware/gzip.rb +0 -74
- data/lib/quickbooks/model/inventory_adjustment.rb +0 -41
- data/lib/quickbooks/model/inventory_adjustment_line_item.rb +0 -14
- data/lib/quickbooks/model/item_adjustment_line_detail.rb +0 -10
- data/lib/quickbooks/service/inventory_adjustment.rb +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc115bc7b925447fecb75976b448e66406441c9fd56208e964ac34844fdcd37a
|
|
4
|
+
data.tar.gz: fd1ca0b526c14cdadda7a1e276c3dcedb9b8c68e7c76be0aa074df30c63e0382
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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',
|
|
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
|
|
|
@@ -30,7 +30,6 @@ module Quickbooks
|
|
|
30
30
|
|
|
31
31
|
def as_json(options = nil)
|
|
32
32
|
options = {} if options.nil?
|
|
33
|
-
options = options.dup if options.frozen?
|
|
34
33
|
except_conditions = ["roxml_references"]
|
|
35
34
|
except_conditions << options[:except]
|
|
36
35
|
options[:except] = except_conditions.flatten.uniq.compact
|
|
@@ -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',
|
|
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
|
-
:
|
|
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',
|
|
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,6 @@ 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
|
|
26
25
|
xml_accessor :po_number, :from => 'PONumber'
|
|
27
26
|
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
|
|
28
27
|
xml_accessor :ship_date, :from => 'ShipDate', :as => Time
|
|
@@ -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.
|
|
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 =
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
|
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'].
|
|
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.
|
|
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.
|
|
451
|
+
error[:element] = code_attr.value
|
|
455
452
|
end
|
|
456
|
-
error[:message] = error_element.xpath("//xmlns:Message").
|
|
457
|
-
error[:detail] = error_element.xpath("//xmlns:Detail").
|
|
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
|
|
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)
|
|
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
|
-
|
|
17
|
+
::Quickbooks.log?
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
def condense_logs?
|
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'
|
|
@@ -128,9 +129,6 @@ require 'quickbooks/model/purchase_change'
|
|
|
128
129
|
require 'quickbooks/model/transfer'
|
|
129
130
|
require 'quickbooks/model/change_data_capture'
|
|
130
131
|
require 'quickbooks/model/refund_receipt_change'
|
|
131
|
-
require 'quickbooks/model/item_adjustment_line_detail'
|
|
132
|
-
require 'quickbooks/model/inventory_adjustment_line_item'
|
|
133
|
-
require 'quickbooks/model/inventory_adjustment'
|
|
134
132
|
|
|
135
133
|
#== Services
|
|
136
134
|
require 'quickbooks/service/service_crud'
|
|
@@ -189,10 +187,6 @@ require 'quickbooks/service/purchase_change'
|
|
|
189
187
|
require 'quickbooks/service/transfer'
|
|
190
188
|
require 'quickbooks/service/change_data_capture'
|
|
191
189
|
require 'quickbooks/service/refund_receipt_change'
|
|
192
|
-
require 'quickbooks/service/inventory_adjustment'
|
|
193
|
-
|
|
194
|
-
# Register Faraday Middleware
|
|
195
|
-
Faraday::Middleware.register_middleware :gzip => lambda { Gzip }
|
|
196
190
|
|
|
197
191
|
module Quickbooks
|
|
198
192
|
@@sandbox_mode = false
|
|
@@ -252,8 +246,10 @@ module Quickbooks
|
|
|
252
246
|
end
|
|
253
247
|
|
|
254
248
|
def log(msg)
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
if log?
|
|
250
|
+
logger.info(msg)
|
|
251
|
+
logger.flush if logger.respond_to?(:flush)
|
|
252
|
+
end
|
|
257
253
|
end
|
|
258
254
|
end # << self
|
|
259
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:
|
|
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:
|
|
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: '
|
|
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: '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
|
|
@@ -252,14 +279,11 @@ files:
|
|
|
252
279
|
- lib/quickbooks/model/global_tax_calculation.rb
|
|
253
280
|
- lib/quickbooks/model/group_line_detail.rb
|
|
254
281
|
- lib/quickbooks/model/has_line_items.rb
|
|
255
|
-
- lib/quickbooks/model/inventory_adjustment.rb
|
|
256
|
-
- lib/quickbooks/model/inventory_adjustment_line_item.rb
|
|
257
282
|
- lib/quickbooks/model/invoice.rb
|
|
258
283
|
- lib/quickbooks/model/invoice_change.rb
|
|
259
284
|
- lib/quickbooks/model/invoice_group_line_detail.rb
|
|
260
285
|
- lib/quickbooks/model/invoice_line_item.rb
|
|
261
286
|
- lib/quickbooks/model/item.rb
|
|
262
|
-
- lib/quickbooks/model/item_adjustment_line_detail.rb
|
|
263
287
|
- lib/quickbooks/model/item_based_expense_line_detail.rb
|
|
264
288
|
- lib/quickbooks/model/item_change.rb
|
|
265
289
|
- lib/quickbooks/model/item_group_detail.rb
|
|
@@ -335,7 +359,6 @@ files:
|
|
|
335
359
|
- lib/quickbooks/service/employee.rb
|
|
336
360
|
- lib/quickbooks/service/estimate.rb
|
|
337
361
|
- lib/quickbooks/service/exchange_rate.rb
|
|
338
|
-
- lib/quickbooks/service/inventory_adjustment.rb
|
|
339
362
|
- lib/quickbooks/service/invoice.rb
|
|
340
363
|
- lib/quickbooks/service/invoice_change.rb
|
|
341
364
|
- lib/quickbooks/service/item.rb
|
|
@@ -379,7 +402,7 @@ homepage: http://github.com/ruckus/quickbooks-ruby
|
|
|
379
402
|
licenses:
|
|
380
403
|
- MIT
|
|
381
404
|
metadata: {}
|
|
382
|
-
post_install_message:
|
|
405
|
+
post_install_message:
|
|
383
406
|
rdoc_options: []
|
|
384
407
|
require_paths:
|
|
385
408
|
- lib
|
|
@@ -387,15 +410,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
387
410
|
requirements:
|
|
388
411
|
- - ">="
|
|
389
412
|
- !ruby/object:Gem::Version
|
|
390
|
-
version: '
|
|
413
|
+
version: '2.6'
|
|
391
414
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
392
415
|
requirements:
|
|
393
416
|
- - ">="
|
|
394
417
|
- !ruby/object:Gem::Version
|
|
395
418
|
version: '0'
|
|
396
419
|
requirements: []
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
rubyforge_project:
|
|
421
|
+
rubygems_version: 2.7.6.2
|
|
422
|
+
signing_key:
|
|
399
423
|
specification_version: 4
|
|
400
424
|
summary: REST API to Quickbooks Online
|
|
401
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
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module Quickbooks
|
|
2
|
-
module Model
|
|
3
|
-
class InventoryAdjustment < BaseModel
|
|
4
|
-
include HasLineItems
|
|
5
|
-
|
|
6
|
-
XML_COLLECTION_NODE = "InventoryAdjustment"
|
|
7
|
-
XML_NODE = "InventoryAdjustment"
|
|
8
|
-
REST_RESOURCE = 'inventoryadjustment'
|
|
9
|
-
|
|
10
|
-
# Requires minorversion >= 70
|
|
11
|
-
|
|
12
|
-
xml_accessor :id, :from => 'Id'
|
|
13
|
-
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
|
14
|
-
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
|
15
|
-
xml_accessor :doc_number, :from => 'DocNumber'
|
|
16
|
-
xml_accessor :txn_date, :from => 'TxnDate', :as => Date
|
|
17
|
-
xml_accessor :private_note, :from => 'PrivateNote'
|
|
18
|
-
xml_accessor :adjust_account_ref, :from => 'AdjustAccountRef', :as => BaseReference
|
|
19
|
-
xml_accessor :line_items, :from => 'Line', :as => [InventoryAdjustmentLineItem]
|
|
20
|
-
|
|
21
|
-
validates_presence_of :adjust_account_ref
|
|
22
|
-
|
|
23
|
-
reference_setters :adjust_account_ref
|
|
24
|
-
|
|
25
|
-
def build_line_item_for(item_id: , qty_diff:)
|
|
26
|
-
line_item = Quickbooks::Model::InventoryAdjustmentLineItem.new().tap do |line_item|
|
|
27
|
-
line_item.detail_type = InventoryAdjustmentLineItem::ITEM_ADJUSTMENT_LINE_DETAIL
|
|
28
|
-
|
|
29
|
-
adjustment_line_detail = ItemAdjustmentLineDetail.new
|
|
30
|
-
adjustment_line_detail.item_id = item_id
|
|
31
|
-
adjustment_line_detail.qty_diff = qty_diff
|
|
32
|
-
|
|
33
|
-
line_item.item_adjustment_line_detail = adjustment_line_detail
|
|
34
|
-
end
|
|
35
|
-
line_items << line_item
|
|
36
|
-
|
|
37
|
-
self
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Quickbooks
|
|
2
|
-
module Model
|
|
3
|
-
class InventoryAdjustmentLineItem < BaseModel
|
|
4
|
-
require 'quickbooks/model/item_adjustment_line_detail'
|
|
5
|
-
|
|
6
|
-
ITEM_ADJUSTMENT_LINE_DETAIL = 'ItemAdjustmentLineDetail'
|
|
7
|
-
|
|
8
|
-
xml_accessor :detail_type, :from => 'DetailType'
|
|
9
|
-
xml_accessor :item_adjustment_line_detail, :from => ITEM_ADJUSTMENT_LINE_DETAIL, :as => ItemAdjustmentLineDetail
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module Quickbooks
|
|
2
|
-
module Model
|
|
3
|
-
class ItemAdjustmentLineDetail < BaseModel
|
|
4
|
-
xml_accessor :item_ref, :from => 'ItemRef', :as => BaseReference
|
|
5
|
-
xml_accessor :qty_diff, :from => 'QtyDiff', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
|
6
|
-
|
|
7
|
-
reference_setters :item_ref
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Quickbooks
|
|
2
|
-
module Service
|
|
3
|
-
class InventoryAdjustment < BaseService
|
|
4
|
-
|
|
5
|
-
def create(inventory_adjustment, options = {})
|
|
6
|
-
# pin to 70
|
|
7
|
-
v = "?minorversion=#{Quickbooks.minorversion >= 70 ? Quickbooks.minorversion : 70}"
|
|
8
|
-
params = { query: { minorversion: Quickbooks.minorversion >= 70 ? Quickbooks.minorversion : 70 } }
|
|
9
|
-
super(inventory_adjustment, options.merge(params))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def model
|
|
15
|
-
Quickbooks::Model::InventoryAdjustment
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|