quickbooks-ruby 1.0.7 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quickbooks-ruby.rb +10 -0
- data/lib/quickbooks/model/account.rb +0 -1
- data/lib/quickbooks/model/customer.rb +0 -2
- data/lib/quickbooks/model/invoice.rb +0 -1
- data/lib/quickbooks/model/item.rb +2 -4
- data/lib/quickbooks/model/preferences.rb +0 -1
- data/lib/quickbooks/model/purchase_order.rb +0 -1
- data/lib/quickbooks/service/access_token.rb +2 -1
- data/lib/quickbooks/service/account.rb +0 -5
- data/lib/quickbooks/service/base_service.rb +5 -1
- data/lib/quickbooks/service/custom_field.rb +20 -0
- data/lib/quickbooks/service/customer.rb +1 -11
- data/lib/quickbooks/service/invoice.rb +1 -10
- data/lib/quickbooks/service/item.rb +1 -11
- data/lib/quickbooks/service/preferences.rb +0 -5
- data/lib/quickbooks/service/purchase_order.rb +2 -2
- data/lib/quickbooks/service/service_crud_json.rb +1 -1
- data/lib/quickbooks/util/query_builder.rb +6 -5
- data/lib/quickbooks/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1eba3497acedc2c117a231b48c93ba08b99fa4571d667f5b78d62c5774ed3fd
|
4
|
+
data.tar.gz: ba1ee66b0ba3be2a95b245f1f3dd06fbc34179ed9d5df34472adcc435c8f4544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92102915fcc2196839be5e5935265a8622b282af1db0459b23fc7cfe3546e23ab28aa82c414c2ebb2a2e4b51f96384cb976929c3dba0d1df7ee1812ce3e2e546
|
7
|
+
data.tar.gz: 65772e607f93e278811b71c8db7db9235c0fbc1a9304677c3e62a51c4a96b776adb448201c804f13d0f6a8fe968f932bcba829dc79bec91df5d2fa416d44f2d3
|
data/lib/quickbooks-ruby.rb
CHANGED
@@ -139,6 +139,7 @@ require 'quickbooks/service/attachable'
|
|
139
139
|
require 'quickbooks/service/company_info'
|
140
140
|
require 'quickbooks/service/company_currency'
|
141
141
|
require 'quickbooks/service/customer_type'
|
142
|
+
require 'quickbooks/service/custom_field'
|
142
143
|
require 'quickbooks/service/customer'
|
143
144
|
require 'quickbooks/service/department'
|
144
145
|
require 'quickbooks/service/invoice'
|
@@ -190,6 +191,7 @@ Faraday::Middleware.register_middleware :gzip => lambda { Gzip }
|
|
190
191
|
module Quickbooks
|
191
192
|
@@sandbox_mode = false
|
192
193
|
@@logger = nil
|
194
|
+
@@minorversion = 47
|
193
195
|
|
194
196
|
class << self
|
195
197
|
def sandbox_mode
|
@@ -200,6 +202,14 @@ module Quickbooks
|
|
200
202
|
@@sandbox_mode = sandbox_mode
|
201
203
|
end
|
202
204
|
|
205
|
+
def minorversion=(v)
|
206
|
+
@@minorversion = v
|
207
|
+
end
|
208
|
+
|
209
|
+
def minorversion
|
210
|
+
@@minorversion
|
211
|
+
end
|
212
|
+
|
203
213
|
def logger
|
204
214
|
@@logger ||= ::Logger.new($stdout) # TODO: replace with a real log file
|
205
215
|
end
|
@@ -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
|
@@ -23,7 +23,8 @@ module Quickbooks
|
|
23
23
|
def disconnect
|
24
24
|
conn = Faraday.new
|
25
25
|
conn.basic_auth oauth.client.id, oauth.client.secret
|
26
|
-
|
26
|
+
url = "#{DISCONNECT_URL}?minorversion=#{Quickbooks.minorversion}"
|
27
|
+
response = conn.post(url, token: oauth.refresh_token || oauth.token)
|
27
28
|
|
28
29
|
if response.success?
|
29
30
|
Quickbooks::Model::AccessTokenResponse.new(error_code: "0")
|
@@ -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
|
@@ -229,6 +229,8 @@ module Quickbooks
|
|
229
229
|
body['file_metadata_0'] = param_part
|
230
230
|
end
|
231
231
|
|
232
|
+
url = add_query_string_to_url(url, {})
|
233
|
+
|
232
234
|
do_http(:upload, url, body, headers)
|
233
235
|
end
|
234
236
|
|
@@ -292,7 +294,9 @@ module Quickbooks
|
|
292
294
|
@oauth.post_with_multipart(url, headers: headers, body: body, raise_errors: false)
|
293
295
|
end
|
294
296
|
|
295
|
-
def add_query_string_to_url(url, params)
|
297
|
+
def add_query_string_to_url(url, params = {})
|
298
|
+
params ||= {}
|
299
|
+
params['minorversion'] = Quickbooks.minorversion
|
296
300
|
if params.is_a?(Hash) && !params.empty?
|
297
301
|
keyvalues = params.collect { |k| "#{k.first}=#{k.last}" }.join("&")
|
298
302
|
delim = url.index("?") != nil ? "&" : "?"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Quickbooks
|
2
|
+
module Service
|
3
|
+
class CustomField < BaseService
|
4
|
+
|
5
|
+
def delete(customer_type)
|
6
|
+
raise Quickbooks::UnsupportedOperation.new('Deleting CustomerType is not supported by Intuit')
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(customer_type)
|
10
|
+
raise Quickbooks::UnsupportedOperation.new('Creating/updating CustomerType is not supported by Intuit')
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def model
|
16
|
+
Quickbooks::Model::CustomField
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -7,21 +7,11 @@ module Quickbooks
|
|
7
7
|
update(customer, :sparse => true)
|
8
8
|
end
|
9
9
|
|
10
|
-
def url_for_resource(resource)
|
11
|
-
url = super(resource)
|
12
|
-
"#{url}?minorversion=#{Quickbooks::Model::Customer::MINORVERSION}"
|
13
|
-
end
|
14
|
-
|
15
10
|
def fetch_by_id(id, params = {})
|
16
|
-
url = "#{url_for_base}/customer/#{id}
|
11
|
+
url = "#{url_for_base}/customer/#{id}"
|
17
12
|
fetch_object(model, url, params)
|
18
13
|
end
|
19
14
|
|
20
|
-
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
21
|
-
url = super(query, start_position, max_results, options)
|
22
|
-
"#{url}&minorversion=#{Quickbooks::Model::Customer::MINORVERSION}"
|
23
|
-
end
|
24
|
-
|
25
15
|
private
|
26
16
|
|
27
17
|
def model
|
@@ -6,20 +6,11 @@ module Quickbooks
|
|
6
6
|
delete_by_query_string(invoice)
|
7
7
|
end
|
8
8
|
|
9
|
-
def url_for_resource(resource)
|
10
|
-
url = super(resource)
|
11
|
-
end
|
12
|
-
|
13
9
|
def fetch_by_id(id, params = {})
|
14
|
-
url = "#{url_for_base}/invoice/#{id}
|
10
|
+
url = "#{url_for_base}/invoice/#{id}"
|
15
11
|
fetch_object(model, url, params)
|
16
12
|
end
|
17
13
|
|
18
|
-
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
19
|
-
url = super(query, start_position, max_results, options)
|
20
|
-
"#{url}&minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}"
|
21
|
-
end
|
22
|
-
|
23
14
|
def send(invoice, email_address=nil)
|
24
15
|
query = email_address.present? ? "?sendTo=#{email_address}" : ""
|
25
16
|
url = "#{url_for_resource(model::REST_RESOURCE)}/#{invoice.id}/send#{query}"
|
@@ -7,21 +7,11 @@ module Quickbooks
|
|
7
7
|
update(item, :sparse => true)
|
8
8
|
end
|
9
9
|
|
10
|
-
def url_for_resource(resource)
|
11
|
-
url = super(resource)
|
12
|
-
"#{url}?minorversion=#{Quickbooks::Model::Item::MINORVERSION}"
|
13
|
-
end
|
14
|
-
|
15
10
|
def fetch_by_id(id, params = {})
|
16
|
-
url = "#{url_for_base}/item/#{id}
|
11
|
+
url = "#{url_for_base}/item/#{id}"
|
17
12
|
fetch_object(model, url, params)
|
18
13
|
end
|
19
14
|
|
20
|
-
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
21
|
-
url = super(query, start_position, max_results, options)
|
22
|
-
"#{url}&minorversion=#{Quickbooks::Model::Item::MINORVERSION}"
|
23
|
-
end
|
24
|
-
|
25
15
|
private
|
26
16
|
|
27
17
|
def model
|
@@ -2,11 +2,6 @@ module Quickbooks
|
|
2
2
|
module Service
|
3
3
|
class Preferences < BaseService
|
4
4
|
|
5
|
-
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
6
|
-
url = super(query, start_position, max_results, options)
|
7
|
-
"#{url}&minorversion=#{Quickbooks::Model::Preferences::MINORVERSION}"
|
8
|
-
end
|
9
|
-
|
10
5
|
private
|
11
6
|
|
12
7
|
def model
|
@@ -7,13 +7,13 @@ module Quickbooks
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def fetch_by_id(id, params = {})
|
10
|
-
url = "#{url_for_base}/purchaseorder/#{id}?minorversion=#{Quickbooks
|
10
|
+
url = "#{url_for_base}/purchaseorder/#{id}?minorversion=#{Quickbooks.minorversion}"
|
11
11
|
fetch_object(model, url, params)
|
12
12
|
end
|
13
13
|
|
14
14
|
def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
|
15
15
|
url = super(query, start_position, max_results, options)
|
16
|
-
"#{url}&minorversion=#{Quickbooks
|
16
|
+
"#{url}&minorversion=#{Quickbooks.minorversion}"
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -8,7 +8,7 @@ module Quickbooks
|
|
8
8
|
|
9
9
|
def create(entity, options = {})
|
10
10
|
raise Quickbooks::InvalidModelException.new(entity.errors.full_messages.join(',')) unless entity.valid?
|
11
|
-
response =
|
11
|
+
response = do_http_post(url_for_resource(model.resource_for_singular), entity.to_json, options)
|
12
12
|
if response.code.to_i == 200
|
13
13
|
JSON.parse(response.plain_body)
|
14
14
|
else
|
@@ -10,26 +10,27 @@ module Quickbooks
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def clause(field, operator, value)
|
13
|
+
# replace with an escaped backslash
|
14
|
+
escape_single_quotes = -> field { field.to_s.gsub("'", "\\\\'") }
|
15
|
+
|
13
16
|
value = case value
|
14
17
|
when DateTime, Time
|
15
18
|
value.iso8601
|
16
19
|
when Date
|
17
20
|
value.strftime('%Y-%m-%d')
|
18
21
|
when Array
|
19
|
-
value = value.map
|
22
|
+
value = value.map(&escape_single_quotes)
|
20
23
|
else
|
21
|
-
|
22
|
-
value = value.gsub("'", "\\\\'")
|
24
|
+
value = escape_single_quotes.call(value)
|
23
25
|
end
|
24
26
|
|
25
27
|
if operator.downcase == 'in' && value.is_a?(Array)
|
26
|
-
value = value.map{|v| "#{VALUE_QUOTE}#{v}#{VALUE_QUOTE}"}
|
28
|
+
value = value.map { |v| "#{VALUE_QUOTE}#{v}#{VALUE_QUOTE}" }
|
27
29
|
"#{field} #{operator} (#{value.join(', ')})"
|
28
30
|
else
|
29
31
|
"#{field} #{operator} #{VALUE_QUOTE}#{value}#{VALUE_QUOTE}"
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
data/lib/quickbooks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbooks-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Caughlan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: roxml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.0
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.0
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activemodel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- lib/quickbooks/service/company_info.rb
|
295
295
|
- lib/quickbooks/service/credit_memo.rb
|
296
296
|
- lib/quickbooks/service/credit_memo_change.rb
|
297
|
+
- lib/quickbooks/service/custom_field.rb
|
297
298
|
- lib/quickbooks/service/customer.rb
|
298
299
|
- lib/quickbooks/service/customer_change.rb
|
299
300
|
- lib/quickbooks/service/customer_type.rb
|