quickbooks-ruby 1.0.1 → 2.0.7
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.rb +0 -1
- data/lib/quickbooks/model/account_based_expense_line_detail.rb +1 -0
- data/lib/quickbooks/model/base_model.rb +1 -0
- data/lib/quickbooks/model/bill.rb +2 -0
- data/lib/quickbooks/model/bill_line_item.rb +2 -0
- data/lib/quickbooks/model/customer.rb +6 -3
- data/lib/quickbooks/model/customer_type.rb +15 -0
- data/lib/quickbooks/model/invoice.rb +10 -2
- data/lib/quickbooks/model/item.rb +2 -4
- data/lib/quickbooks/model/item_based_expense_line_detail.rb +1 -0
- data/lib/quickbooks/model/preferences.rb +23 -5
- data/lib/quickbooks/model/purchase_change.rb +7 -0
- data/lib/quickbooks/model/purchase_line_item.rb +1 -0
- data/lib/quickbooks/model/purchase_order.rb +2 -1
- data/lib/quickbooks/model/report.rb +12 -1
- data/lib/quickbooks/model/sales_item_line_detail.rb +1 -0
- data/lib/quickbooks/model/sales_receipt.rb +1 -0
- data/lib/quickbooks/model/transaction_tax_detail.rb +1 -1
- data/lib/quickbooks/model/vendor.rb +1 -0
- data/lib/quickbooks/model/vendor_credit.rb +2 -0
- data/lib/quickbooks/service/access_token.rb +19 -18
- data/lib/quickbooks/service/account.rb +0 -5
- data/lib/quickbooks/service/base_service.rb +112 -82
- data/lib/quickbooks/service/credit_memo.rb +6 -0
- data/lib/quickbooks/service/custom_field.rb +20 -0
- data/lib/quickbooks/service/customer.rb +1 -11
- data/lib/quickbooks/service/customer_type.rb +20 -0
- data/lib/quickbooks/service/invoice.rb +1 -10
- data/lib/quickbooks/service/item.rb +1 -11
- data/lib/quickbooks/service/payment.rb +6 -0
- data/lib/quickbooks/service/preferences.rb +0 -5
- data/lib/quickbooks/service/purchase_change.rb +16 -0
- data/lib/quickbooks/service/purchase_order.rb +16 -0
- data/lib/quickbooks/service/refund_receipt.rb +6 -0
- data/lib/quickbooks/service/responses/oauth_http_response.rb +1 -5
- data/lib/quickbooks/service/sales_receipt.rb +1 -1
- data/lib/quickbooks/service/service_crud.rb +4 -1
- data/lib/quickbooks/service/service_crud_json.rb +1 -1
- data/lib/quickbooks/service/upload.rb +1 -5
- data/lib/quickbooks/util/logging.rb +16 -2
- data/lib/quickbooks/util/multipart.rb +0 -72
- data/lib/quickbooks/util/query_builder.rb +10 -5
- data/lib/quickbooks/version.rb +1 -1
- data/lib/quickbooks-ruby.rb +45 -19
- metadata +92 -42
- data/lib/quickbooks/faraday/middleware/gzip.rb +0 -72
- data/lib/quickbooks/service/responses/oauth1_http_response.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3090c1e6be59c03b4f8802cd3d56771e01ba508166db446e3bb9a372739d5dd0
|
4
|
+
data.tar.gz: 4fdb76a07e05ee92dd3c837622e32ce23cb41ede769928ff198f8cb91d58f5c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26045642638563196533afd56d2a36afa2cdd2a1a8c95a54e6faf0546e99491d144802ae9624df4d1d205e23553965120eeca2fd1b484705a185bcab6633822a
|
7
|
+
data.tar.gz: ea5208b840894935844c3a8d3ff06f880877e48b62fb1a1b8b112f82def2d5d4b7960d3008124891bdaa2cd3044711975ffc2404468cc53f54b2b14b5bc4aeb5
|
@@ -7,6 +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
11
|
|
11
12
|
reference_setters :customer_ref, :class_ref, :account_ref, :tax_code_ref
|
12
13
|
|
@@ -30,6 +30,7 @@ module Quickbooks
|
|
30
30
|
|
31
31
|
def as_json(options = nil)
|
32
32
|
options = {} if options.nil?
|
33
|
+
options = options.dup if options.frozen?
|
33
34
|
except_conditions = ["roxml_references"]
|
34
35
|
except_conditions << options[:except]
|
35
36
|
options[:except] = except_conditions.flatten.uniq.compact
|
@@ -16,6 +16,7 @@ module Quickbooks
|
|
16
16
|
xml_accessor :department_ref, :from => 'DepartmentRef', :as => BaseReference
|
17
17
|
|
18
18
|
xml_accessor :line_items, :from => 'Line', :as => [BillLineItem]
|
19
|
+
xml_accessor :txn_tax_detail, :from => 'TxnTaxDetail', :as => TransactionTaxDetail
|
19
20
|
|
20
21
|
xml_accessor :private_note, :from => 'PrivateNote'
|
21
22
|
|
@@ -30,6 +31,7 @@ module Quickbooks
|
|
30
31
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
31
32
|
xml_accessor :remit_to_address, :from => 'RemitToAddr', :as => PhysicalAddress
|
32
33
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
34
|
+
xml_accessor :mailing_address, :from => 'VendorAddr', :as => PhysicalAddress
|
33
35
|
xml_accessor :exchange_rate, :from => 'ExchangeRate', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
34
36
|
xml_accessor :balance, :from => 'Balance', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
35
37
|
|
@@ -12,6 +12,8 @@ module Quickbooks
|
|
12
12
|
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
13
13
|
xml_accessor :detail_type, :from => 'DetailType'
|
14
14
|
|
15
|
+
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
|
16
|
+
|
15
17
|
#== Various detail types
|
16
18
|
xml_accessor :account_based_expense_line_detail, :from => 'AccountBasedExpenseLineDetail', :as => AccountBasedExpenseLineDetail
|
17
19
|
xml_accessor :item_based_expense_line_detail, :from => 'ItemBasedExpenseLineDetail', :as => ItemBasedExpenseLineDetail
|
@@ -16,8 +16,6 @@ module Quickbooks
|
|
16
16
|
include NameEntity::Quality
|
17
17
|
include NameEntity::PermitAlterations
|
18
18
|
|
19
|
-
MINORVERSION = 33
|
20
|
-
|
21
19
|
xml_name XML_NODE
|
22
20
|
xml_accessor :id, :from => 'Id'
|
23
21
|
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
@@ -55,12 +53,17 @@ module Quickbooks
|
|
55
53
|
xml_accessor :default_tax_code_ref, :from => 'DefaultTaxCodeRef', :as => BaseReference
|
56
54
|
xml_accessor :notes, :from => 'Notes'
|
57
55
|
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
56
|
+
xml_accessor :tax_exemption_reason_id, :from => 'TaxExemptionReasonId'
|
57
|
+
xml_accessor :primary_tax_identifier, :from => 'PrimaryTaxIdentifier'
|
58
|
+
xml_accessor :customer_type_ref, :from => 'CustomerTypeRef', :as => BaseReference
|
59
|
+
xml_accessor :isproject?, :from => 'IsProject'
|
58
60
|
|
59
61
|
#== Validations
|
60
62
|
validate :names_cannot_contain_invalid_characters
|
61
63
|
validate :email_address_is_valid
|
62
64
|
|
63
|
-
reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref
|
65
|
+
reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref,
|
66
|
+
:customer_type_ref
|
64
67
|
|
65
68
|
def job?
|
66
69
|
job.to_s == 'true'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Model
|
3
|
+
class CustomerType < BaseModel
|
4
|
+
XML_COLLECTION_NODE = "CustomerType"
|
5
|
+
XML_NODE = "CustomerType"
|
6
|
+
REST_RESOURCE = 'customertype'
|
7
|
+
|
8
|
+
xml_accessor :id, :from => 'Id'
|
9
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
10
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
|
11
|
+
xml_accessor :name, :from => 'Name'
|
12
|
+
xml_accessor :active?, :from => 'Active'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -17,7 +17,6 @@ module Quickbooks
|
|
17
17
|
XML_COLLECTION_NODE = "Invoice"
|
18
18
|
XML_NODE = "Invoice"
|
19
19
|
EMAIL_STATUS_NEED_TO_SEND = 'NeedToSend'
|
20
|
-
MINORVERSION = 37
|
21
20
|
|
22
21
|
xml_accessor :id, :from => 'Id'
|
23
22
|
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
@@ -37,6 +36,7 @@ module Quickbooks
|
|
37
36
|
xml_accessor :customer_memo, :from => 'CustomerMemo'
|
38
37
|
xml_accessor :billing_address, :from => 'BillAddr', :as => PhysicalAddress
|
39
38
|
xml_accessor :shipping_address, :from => 'ShipAddr', :as => PhysicalAddress
|
39
|
+
xml_accessor :ship_from_address, :from => 'ShipFromAddr', :as => PhysicalAddress
|
40
40
|
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
41
41
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
42
42
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
@@ -60,6 +60,8 @@ module Quickbooks
|
|
60
60
|
xml_accessor :allow_online_credit_card_payment?, :from => 'AllowOnlineCreditCardPayment'
|
61
61
|
xml_accessor :allow_online_ach_payment?, :from => 'AllowOnlineACHPayment'
|
62
62
|
xml_accessor :deposit_to_account_ref, :from => 'DepositToAccountRef', :as => BaseReference
|
63
|
+
xml_accessor :bill_email_cc, :from => 'BillEmailCc', :as => EmailAddress
|
64
|
+
xml_accessor :bill_email_bcc, :from => 'BillEmailBcc', :as => EmailAddress
|
63
65
|
|
64
66
|
|
65
67
|
reference_setters
|
@@ -88,6 +90,13 @@ module Quickbooks
|
|
88
90
|
self.bill_email = EmailAddress.new(email_address_string)
|
89
91
|
end
|
90
92
|
|
93
|
+
def billing_email_cc_address=(email_address_string)
|
94
|
+
self.bill_email_cc = EmailAddress.new(email_address_string)
|
95
|
+
end
|
96
|
+
|
97
|
+
def billing_email_bcc_address=(email_address_string)
|
98
|
+
self.bill_email_bcc = EmailAddress.new(email_address_string)
|
99
|
+
end
|
91
100
|
|
92
101
|
def wants_billing_email_sent!
|
93
102
|
self.email_status = EMAIL_STATUS_NEED_TO_SEND
|
@@ -97,7 +106,6 @@ module Quickbooks
|
|
97
106
|
email_status == EMAIL_STATUS_NEED_TO_SEND
|
98
107
|
end
|
99
108
|
|
100
|
-
|
101
109
|
def existence_of_customer_ref
|
102
110
|
if customer_ref.nil? || (customer_ref && customer_ref.value == 0)
|
103
111
|
errors.add(:customer_ref, "CustomerRef is required and must be a non-zero value.")
|
@@ -10,7 +10,6 @@ module Quickbooks
|
|
10
10
|
XML_COLLECTION_NODE = "Item"
|
11
11
|
XML_NODE = "Item"
|
12
12
|
REST_RESOURCE = 'item'
|
13
|
-
MINORVERSION = 33
|
14
13
|
|
15
14
|
INVENTORY_TYPE = 'Inventory'
|
16
15
|
NON_INVENTORY_TYPE = 'NonInventory'
|
@@ -31,6 +30,7 @@ module Quickbooks
|
|
31
30
|
xml_accessor :level, :from => 'Level', :as => Integer
|
32
31
|
xml_accessor :pref_vendor_ref, :from => 'PrefVendorRef', :as => BaseReference
|
33
32
|
xml_accessor :tax_classification_ref, :from => 'TaxClassificationRef', :as => BaseReference
|
33
|
+
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
34
34
|
|
35
35
|
# read-only
|
36
36
|
xml_accessor :fully_qualified_name, :from => 'FullyQualifiedName'
|
@@ -52,13 +52,11 @@ module Quickbooks
|
|
52
52
|
xml_accessor :inv_start_date, :from => 'InvStartDate', :as => Date
|
53
53
|
xml_accessor :custom_fields, :from => "CustomField", as: [CustomField]
|
54
54
|
xml_accessor :print_grouped_items?, :from => 'PrintGroupedItems'
|
55
|
-
|
56
|
-
|
57
55
|
xml_accessor :item_group_details, :from => 'ItemGroupDetail', :as => ItemGroupDetail
|
58
56
|
|
59
57
|
reference_setters :parent_ref, :income_account_ref, :expense_account_ref
|
60
58
|
reference_setters :asset_account_ref, :sales_tax_code_ref, :purchase_tax_code_ref
|
61
|
-
reference_setters :pref_vendor_ref, :tax_classification_ref
|
59
|
+
reference_setters :pref_vendor_ref, :tax_classification_ref, :class_ref
|
62
60
|
|
63
61
|
#== Validations
|
64
62
|
validates_length_of :name, :minimum => 1
|
@@ -13,6 +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
17
|
|
17
18
|
reference_setters :item_ref, :class_ref, :price_level_ref, :customer_ref, :tax_code_ref
|
18
19
|
end
|
@@ -4,7 +4,6 @@ module Quickbooks
|
|
4
4
|
XML_COLLECTION_NODE = "Preferences"
|
5
5
|
XML_NODE = "Preferences"
|
6
6
|
REST_RESOURCE = 'preferences'
|
7
|
-
MINORVERSION = 21
|
8
7
|
|
9
8
|
xml_name XML_NODE
|
10
9
|
|
@@ -20,7 +19,7 @@ module Quickbooks
|
|
20
19
|
PREFERENCE_SECTIONS = {
|
21
20
|
:accounting_info => %w(TrackDepartments DepartmentTerminology ClassTrackingPerTxnLine? ClassTrackingPerTxn? CustomerTerminology),
|
22
21
|
:product_and_services => %w(ForSales? ForPurchase? QuantityWithPriceAndRate? QuantityOnHand?),
|
23
|
-
:
|
22
|
+
:vendor_and_purchases => %w(TrackingByCustomer? BillableExpenseTracking? DefaultTerms? DefaultMarkup? POCustomField),
|
24
23
|
:time_tracking => %w(UseServices? BillCustomers? ShowBillRateToAll WorkWeekStartDate MarkTimeEntiresBillable?),
|
25
24
|
:tax => %w(UsingSalesTax? PartnerTaxEnabled?),
|
26
25
|
:currency => %w(MultiCurrencyEnabled? HomeCurrency),
|
@@ -28,9 +27,28 @@ module Quickbooks
|
|
28
27
|
}
|
29
28
|
|
30
29
|
xml_reader :sales_forms, :from => "SalesFormsPrefs", :as => create_preference_class(*%w(
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
AllowDeposit?
|
31
|
+
AllowDiscount?
|
32
|
+
AllowEstimates?
|
33
|
+
AllowServiceDate?
|
34
|
+
AllowShipping?
|
35
|
+
AutoApplyCredit?
|
36
|
+
CustomField?
|
37
|
+
CustomTxnNumbers?
|
38
|
+
DefaultCustomerMessage
|
39
|
+
DefaultDiscountAccount?
|
40
|
+
DefaultShippingAccount?
|
41
|
+
DefaultTerms
|
42
|
+
EmailCopyToCompany?
|
43
|
+
EstimateMessage
|
44
|
+
ETransactionAttachPDF?
|
45
|
+
ETransactionEnabledStatus
|
46
|
+
ETransactionPaymentEnabled?
|
47
|
+
IPNSupportEnabled?
|
48
|
+
SalesEmailBcc
|
49
|
+
SalesEmailCc
|
50
|
+
UsingPriceLevels?
|
51
|
+
UsingProgressInvoicing?
|
34
52
|
)) {
|
35
53
|
xml_reader :custom_fields, :as => [CustomField], :from => 'CustomField', in: 'CustomField'
|
36
54
|
}
|
@@ -12,6 +12,7 @@ module Quickbooks
|
|
12
12
|
xml_accessor :description, :from => 'Description'
|
13
13
|
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
|
14
14
|
xml_accessor :detail_type, :from => 'DetailType'
|
15
|
+
xml_accessor :received, :from => 'Received', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
15
16
|
|
16
17
|
#== Various detail types
|
17
18
|
xml_accessor :account_based_expense_line_detail, :from => ACCOUNT_BASED_EXPENSE_LINE_DETAIL, :as => AccountBasedExpenseLineDetail
|
@@ -24,10 +24,11 @@ module Quickbooks
|
|
24
24
|
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
|
25
25
|
xml_accessor :vendor_ref, :from => 'VendorRef', :as => BaseReference
|
26
26
|
xml_accessor :ap_account_ref, :from => 'APAccountRef', :as => BaseReference
|
27
|
+
xml_accessor :po_email, from: "POEmail", as: EmailAddress
|
27
28
|
xml_accessor :class_ref, :from => 'ClassRef', :as => BaseReference
|
28
29
|
xml_accessor :sales_term_ref, :from => 'SalesTermRef', :as => BaseReference
|
29
30
|
|
30
|
-
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml =>
|
31
|
+
xml_accessor :total, :from => 'TotalAmt', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
31
32
|
xml_accessor :due_date, :from => 'DueDate', :as => Date
|
32
33
|
xml_accessor :vendor_address, :from => 'VendorAddr', :as => PhysicalAddress
|
33
34
|
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
|
@@ -38,9 +38,20 @@ module Quickbooks
|
|
38
38
|
value = el.attr('value')
|
39
39
|
|
40
40
|
next nil if value.blank?
|
41
|
-
|
41
|
+
|
42
|
+
parse_row_value(value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_row_value(value)
|
47
|
+
# does it look like a number?
|
48
|
+
if value =~ /\A\-?[0-9\.]+\Z/
|
42
49
|
BigDecimal(value)
|
50
|
+
else
|
51
|
+
value
|
43
52
|
end
|
53
|
+
rescue ArgumentError
|
54
|
+
value
|
44
55
|
end
|
45
56
|
|
46
57
|
end
|
@@ -9,6 +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
13
|
|
13
14
|
reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref
|
14
15
|
end
|
@@ -22,6 +22,7 @@ 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
|
25
26
|
xml_accessor :po_number, :from => 'PONumber'
|
26
27
|
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
|
27
28
|
xml_accessor :ship_date, :from => 'ShipDate', :as => Time
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Model
|
3
3
|
class TransactionTaxDetail < BaseModel
|
4
|
-
|
5
4
|
xml_accessor :txn_tax_code_ref, :from => 'TxnTaxCodeRef', :as => BaseReference
|
6
5
|
xml_accessor :total_tax, :from => 'TotalTax', :as => BigDecimal, :to_xml => to_xml_big_decimal
|
6
|
+
xml_accessor :total_tax_specified, :from => 'TotalTaxSpecified'
|
7
7
|
xml_accessor :lines, :from => 'TaxLine', :as => [TaxLine]
|
8
8
|
|
9
9
|
reference_setters :txn_tax_code_ref
|
@@ -41,6 +41,7 @@ module Quickbooks
|
|
41
41
|
xml_accessor :account_number, :from => 'AcctNum'
|
42
42
|
xml_accessor :is_1099?, :from => 'Vendor1099'
|
43
43
|
xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
|
44
|
+
xml_accessor :bill_rate, from: "BillRate", as: BigDecimal, to_xml: to_xml_big_decimal
|
44
45
|
|
45
46
|
#== Validations
|
46
47
|
validate :names_cannot_contain_invalid_characters
|
@@ -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
|
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module Quickbooks
|
2
2
|
module Service
|
3
3
|
class AccessToken < BaseService
|
4
|
-
|
5
4
|
RENEW_URL = "https://appcenter.intuit.com/api/v1/connection/reconnect"
|
6
|
-
|
7
|
-
DISCONNECT_URL_OAUTH2 = "https://developer.api.intuit.com/v2/oauth2/tokens/revoke"
|
5
|
+
DISCONNECT_URL = "https://developer.api.intuit.com/v2/oauth2/tokens/revoke"
|
8
6
|
|
9
7
|
# https://developer.intuit.com/docs/0025_quickbooksapi/0053_auth_auth/oauth_management_api#Reconnect
|
10
8
|
def renew
|
@@ -22,26 +20,29 @@ module Quickbooks
|
|
22
20
|
|
23
21
|
# https://developer.intuit.com/docs/0025_quickbooksapi/0053_auth_auth/oauth_management_api#Disconnect
|
24
22
|
def disconnect
|
25
|
-
|
26
|
-
|
27
|
-
if response && response.code.to_i == 200
|
28
|
-
Quickbooks::Model::AccessTokenResponse.from_xml(response.plain_body)
|
29
|
-
end
|
30
|
-
elsif oauth_v2?
|
31
|
-
conn = Faraday.new
|
32
|
-
conn.basic_auth oauth.client.id, oauth.client.secret
|
33
|
-
response = conn.post(DISCONNECT_URL_OAUTH2, token: oauth.refresh_token || oauth.token)
|
23
|
+
connection = Faraday.new(headers: { 'Content-Type' => 'application/json' }) do |f|
|
24
|
+
f.adapter(::Quickbooks.http_adapter)
|
34
25
|
|
35
|
-
if
|
36
|
-
|
26
|
+
if Gem.loaded_specs['faraday'].version >= Gem::Version.create('2.0')
|
27
|
+
f.request(:authorization, :basic, oauth.client.id, oauth.client.secret)
|
37
28
|
else
|
38
|
-
|
39
|
-
error_code: response.status.to_s, error_message: response.reason_phrase
|
40
|
-
)
|
29
|
+
f.basic_auth(oauth.client.id, oauth.client.secret)
|
41
30
|
end
|
42
31
|
end
|
43
|
-
end
|
44
32
|
|
33
|
+
url = "#{DISCONNECT_URL}?minorversion=#{Quickbooks.minorversion}"
|
34
|
+
response = connection.post(url) do |request|
|
35
|
+
request.body = JSON.generate({ token: oauth.refresh_token || oauth.token })
|
36
|
+
end
|
37
|
+
|
38
|
+
if response.success?
|
39
|
+
Quickbooks::Model::AccessTokenResponse.new(error_code: "0")
|
40
|
+
else
|
41
|
+
Quickbooks::Model::AccessTokenResponse.new(
|
42
|
+
error_code: response.status.to_s, error_message: response.reason_phrase
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -7,11 +7,6 @@ module Quickbooks
|
|
7
7
|
update(account, :sparse => true)
|
8
8
|
end
|
9
9
|
|
10
|
-
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
11
|
-
url = super(query, start_position, max_results, options)
|
12
|
-
"#{url}&minorversion=#{Quickbooks::Model::Account::MINORVERSION}"
|
13
|
-
end
|
14
|
-
|
15
10
|
private
|
16
11
|
|
17
12
|
def model
|