quickbooks-ruby 1.0.6 → 1.0.7

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: c912118ddd84fcffd9348f9c80986c5acd65645f3f1df65175ff091c13a3478b
4
- data.tar.gz: '0739b9834c0ac6f1a46c8741acf6742970b490a7c6648f40c20361036fd9bb0c'
3
+ metadata.gz: 594f8d68572ba0677e421dd9b6bd94b9dddc4cebca01fb3563acc274221d531e
4
+ data.tar.gz: 65094892047b057642b59afedd9575e4cfcac52535d65b909a4be964277eb8d3
5
5
  SHA512:
6
- metadata.gz: 9aeb39c90d47fa2e2319b0a66ed44b2e61627642a6302c585206483ee6a5ced61fad94170a9c2b7f8ccfcf66b4f9940a4fcb5000f5eb1c513719ff9639712159
7
- data.tar.gz: de3b723c54f1371baa1e8b0b7f20ef4c8a70cdfbd4687d2ff437bb6501337b9f20c2627329ba22d73707af99d686848c84ea14315d034116449eec0eb5dba1cb
6
+ metadata.gz: 0df95bc28c87dafd0aca1b9e4242cd01093e075344dc63431a6456fcc6d87c8e9611c0359a176642d304a563591e53a4f74cc7318826211e8bec90618d10906b
7
+ data.tar.gz: 5b4a6a44deb549a9fa9f4931e9b9628f9ee9982bbc377356ade7daab6040a3a3ef5f9f30e9fd73957d9f8f2f0b8521f87a604bee4674dcee1dccb57b5dc21518
@@ -75,6 +75,7 @@ require 'quickbooks/model/invoice_line_item'
75
75
  require 'quickbooks/model/invoice_group_line_detail'
76
76
  require 'quickbooks/model/company_info'
77
77
  require 'quickbooks/model/company_currency'
78
+ require 'quickbooks/model/customer_type'
78
79
  require 'quickbooks/model/customer'
79
80
  require 'quickbooks/model/delivery_info'
80
81
  require 'quickbooks/model/sales_receipt'
@@ -137,6 +138,7 @@ require 'quickbooks/service/class'
137
138
  require 'quickbooks/service/attachable'
138
139
  require 'quickbooks/service/company_info'
139
140
  require 'quickbooks/service/company_currency'
141
+ require 'quickbooks/service/customer_type'
140
142
  require 'quickbooks/service/customer'
141
143
  require 'quickbooks/service/department'
142
144
  require 'quickbooks/service/invoice'
@@ -246,6 +248,7 @@ module Quickbooks
246
248
  class TooManyRequests < Error; end
247
249
  class ServiceUnavailable < Error; end
248
250
  class MissingRealmError < Error; end
251
+ class UnsupportedOperation < Error; end
249
252
 
250
253
  class IntuitRequestException < Error
251
254
  attr_accessor :message, :code, :detail, :type, :intuit_tid, :request_xml, :request_json
@@ -23,6 +23,8 @@ class Gzip < Faraday::Middleware
23
23
  def call(env)
24
24
  env[:request_headers][ACCEPT_ENCODING] ||= SUPPORTED_ENCODINGS
25
25
  @app.call(env).on_complete do |response_env|
26
+ break if response_env[:response_headers].nil?
27
+
26
28
  case response_env[:response_headers][CONTENT_ENCODING]
27
29
  when 'gzip'
28
30
  reset_body(response_env, &method(:uncompress_gzip))
@@ -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
 
@@ -56,12 +56,15 @@ module Quickbooks
56
56
  xml_accessor :notes, :from => 'Notes'
57
57
  xml_accessor :currency_ref, :from => 'CurrencyRef', :as => BaseReference
58
58
  xml_accessor :tax_exemption_reason_id, :from => 'TaxExemptionReasonId'
59
+ xml_accessor :primary_tax_identifier, :from => 'PrimaryTaxIdentifier'
60
+ xml_accessor :customer_type_ref, :from => 'CustomerTypeRef', :as => BaseReference
59
61
 
60
62
  #== Validations
61
63
  validate :names_cannot_contain_invalid_characters
62
64
  validate :email_address_is_valid
63
65
 
64
- reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref
66
+ reference_setters :parent_ref, :sales_term_ref, :payment_method_ref, :default_tax_code_ref, :currency_ref,
67
+ :customer_type_ref
65
68
 
66
69
  def job?
67
70
  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
@@ -38,7 +38,7 @@ module Quickbooks
38
38
  value = el.attr('value')
39
39
 
40
40
  next nil if value.blank?
41
- next value if value.to_s.match(/^\d+$|^\d+.\d+$|^-\d+|^-\d+.\d+$|^.\d+$/).nil?
41
+ next value if value.to_s.match(/^\d+$|^\d+\.\d+$|^-\d+|^-\d+\.\d+$|^\.\d+$/).nil?
42
42
  BigDecimal(value)
43
43
  end
44
44
  end
@@ -9,6 +9,9 @@ module Quickbooks
9
9
  attr_reader :base_uri
10
10
  attr_reader :last_response_xml
11
11
  attr_reader :last_response_intuit_tid
12
+ attr_accessor :before_request
13
+ attr_accessor :around_request
14
+ attr_accessor :after_request
12
15
 
13
16
  XML_NS = %{xmlns="http://schema.intuit.com/finance/v3"}
14
17
  HTTP_CONTENT_TYPE = 'application/xml'
@@ -17,6 +20,8 @@ module Quickbooks
17
20
  BASE_DOMAIN = 'quickbooks.api.intuit.com'
18
21
  SANDBOX_DOMAIN = 'sandbox-quickbooks.api.intuit.com'
19
22
 
23
+ RequestInfo = Struct.new(:url, :headers, :body, :method)
24
+
20
25
  def initialize(attributes = {})
21
26
  domain = Quickbooks.sandbox_mode ? SANDBOX_DOMAIN : BASE_DOMAIN
22
27
  @base_uri = "https://#{domain}/v3/company"
@@ -247,17 +252,24 @@ module Quickbooks
247
252
  log_request_body(body)
248
253
  log "REQUEST HEADERS = #{headers.inspect}"
249
254
 
250
- raw_response = case method
251
- when :get
252
- oauth_get(url, headers)
253
- when :post
254
- oauth_post(url, body, headers)
255
- when :upload
256
- oauth_post_with_multipart(url, body, headers)
257
- else
258
- raise "Do not know how to perform that HTTP operation"
255
+ request_info = RequestInfo.new(url, headers, body, method)
256
+ before_request.call(request_info) if before_request
257
+
258
+ raw_response = with_around_request(request_info) do
259
+ case method
260
+ when :get
261
+ oauth_get(url, headers)
262
+ when :post
263
+ oauth_post(url, body, headers)
264
+ when :upload
265
+ oauth_post_with_multipart(url, body, headers)
266
+ else
267
+ raise "Do not know how to perform that HTTP operation"
268
+ end
259
269
  end
260
270
 
271
+ after_request.call(request_info, raw_response.body) if after_request
272
+
261
273
  response = Quickbooks::Service::Responses::OAuthHttpResponse.wrap(raw_response)
262
274
  log "------ QUICKBOOKS-RUBY RESPONSE ------"
263
275
  log "RESPONSE CODE = #{response.code}"
@@ -429,6 +441,13 @@ module Quickbooks
429
441
  error
430
442
  end
431
443
 
444
+ def with_around_request(request_info, &block)
445
+ if around_request
446
+ around_request.call(request_info, &block)
447
+ else
448
+ block.call
449
+ end
450
+ end
432
451
  end
433
452
  end
434
453
  end
@@ -0,0 +1,20 @@
1
+ module Quickbooks
2
+ module Service
3
+ class CustomerType < 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::CustomerType
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
 
5
5
  end
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.6
4
+ version: 1.0.7
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-02-10 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -202,6 +202,7 @@ files:
202
202
  - lib/quickbooks/model/custom_field.rb
203
203
  - lib/quickbooks/model/customer.rb
204
204
  - lib/quickbooks/model/customer_change.rb
205
+ - lib/quickbooks/model/customer_type.rb
205
206
  - lib/quickbooks/model/definition.rb
206
207
  - lib/quickbooks/model/delivery_info.rb
207
208
  - lib/quickbooks/model/department.rb
@@ -295,6 +296,7 @@ files:
295
296
  - lib/quickbooks/service/credit_memo_change.rb
296
297
  - lib/quickbooks/service/customer.rb
297
298
  - lib/quickbooks/service/customer_change.rb
299
+ - lib/quickbooks/service/customer_type.rb
298
300
  - lib/quickbooks/service/department.rb
299
301
  - lib/quickbooks/service/deposit.rb
300
302
  - lib/quickbooks/service/employee.rb