quickbooks-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{quickbooks.rb → quickbooks-ruby.rb} +26 -4
  3. data/lib/quickbooks/model/account.rb +91 -0
  4. data/lib/quickbooks/model/account_based_expense_line_detail.rb +15 -0
  5. data/lib/quickbooks/model/base_model.rb +21 -0
  6. data/lib/quickbooks/model/{customer_ref.rb → base_reference.rb} +1 -1
  7. data/lib/quickbooks/model/bill.rb +36 -0
  8. data/lib/quickbooks/model/bill_line_item.rb +23 -0
  9. data/lib/quickbooks/model/bill_payment.rb +34 -0
  10. data/lib/quickbooks/model/bill_payment_check.rb +12 -0
  11. data/lib/quickbooks/model/bill_payment_credit_card.rb +10 -0
  12. data/lib/quickbooks/model/bill_payment_line_item.rb +21 -0
  13. data/lib/quickbooks/model/check_payment.rb +11 -0
  14. data/lib/quickbooks/model/credit_card_payment.rb +17 -0
  15. data/lib/quickbooks/model/credit_memo.rb +38 -0
  16. data/lib/quickbooks/model/customer.rb +18 -15
  17. data/lib/quickbooks/model/discount_override.rb +5 -3
  18. data/lib/quickbooks/model/invoice.rb +41 -19
  19. data/lib/quickbooks/model/invoice_line_item.rb +6 -6
  20. data/lib/quickbooks/model/item.rb +24 -17
  21. data/lib/quickbooks/model/line.rb +28 -0
  22. data/lib/quickbooks/model/payment_line_detail.rb +6 -4
  23. data/lib/quickbooks/model/payment_method.rb +14 -0
  24. data/lib/quickbooks/model/physical_address.rb +18 -2
  25. data/lib/quickbooks/model/sales_item_line_detail.rb +9 -7
  26. data/lib/quickbooks/model/sales_receipt.rb +44 -0
  27. data/lib/quickbooks/model/sub_total_line_detail.rb +7 -5
  28. data/lib/quickbooks/service/account.rb +22 -0
  29. data/lib/quickbooks/service/base_service.rb +45 -60
  30. data/lib/quickbooks/service/bill.rb +15 -0
  31. data/lib/quickbooks/service/bill_payment.rb +15 -0
  32. data/lib/quickbooks/service/credit_memo.rb +15 -0
  33. data/lib/quickbooks/service/payment_method.rb +23 -0
  34. data/lib/quickbooks/service/sales_receipt.rb +15 -0
  35. data/lib/quickbooks/service/service_crud.rb +4 -8
  36. data/lib/quickbooks/util/class_util.rb +14 -0
  37. data/lib/quickbooks/{http_encoding_helper.rb → util/http_encoding_helper.rb} +16 -11
  38. data/lib/quickbooks/version.rb +1 -1
  39. metadata +26 -6
  40. data/lib/quickbooks/model/invoice_item_ref.rb +0 -21
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Service
3
+ class Bill < BaseService
4
+ include ServiceCrud
5
+
6
+ def default_model_query
7
+ "SELECT * FROM Bill"
8
+ end
9
+
10
+ def model
11
+ Quickbooks::Model::Bill
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Service
3
+ class BillPayment < BaseService
4
+ include ServiceCrud
5
+
6
+ def default_model_query
7
+ "SELECT * FROM BillPayment"
8
+ end
9
+
10
+ def model
11
+ Quickbooks::Model::BillPayment
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Service
3
+ class CreditMemo < BaseService
4
+ include ServiceCrud
5
+
6
+ def default_model_query
7
+ "SELECT * FROM CreditMemo"
8
+ end
9
+
10
+ def model
11
+ Quickbooks::Model::CreditMemo
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Quickbooks
2
+ module Service
3
+ class PaymentMethod < BaseService
4
+ include ServiceCrud
5
+
6
+ def default_model_query
7
+ "SELECT * FROM PaymentMethod"
8
+ end
9
+
10
+ def fetch_by_name(name)
11
+ self.query(search_name_query(name)).entries.first
12
+ end
13
+
14
+ def model
15
+ Quickbooks::Model::PaymentMethod
16
+ end
17
+
18
+ def search_name_query(name)
19
+ "SELECT * FROM PaymentMethod WHERE Name = '#{name}'"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module Quickbooks
2
+ module Service
3
+ class SalesReceipt < BaseService
4
+ include ServiceCrud
5
+
6
+ def default_model_query
7
+ "SELECT * FROM SALESRECEIPT"
8
+ end
9
+
10
+ def model
11
+ Quickbooks::Model::SalesReceipt
12
+ end
13
+ end
14
+ end
15
+ end
@@ -3,10 +3,6 @@ module Quickbooks
3
3
  module ServiceCrud
4
4
 
5
5
  def query(object_query = nil, options = {})
6
- object_query ||= default_model_query
7
-
8
- options[:page] ||= 1
9
- options[:per_page] ||= 20
10
6
  fetch_collection(object_query, model, options)
11
7
  end
12
8
 
@@ -20,7 +16,7 @@ module Quickbooks
20
16
  xml = entity.to_xml_ns(options)
21
17
  response = do_http_post(url_for_resource(model.resource_for_singular), valid_xml_document(xml))
22
18
  if response.code.to_i == 200
23
- model.from_xml(parse_singular_entity_response(model, response.body))
19
+ model.from_xml(parse_singular_entity_response(model, response.plain_body))
24
20
  else
25
21
  nil
26
22
  end
@@ -36,7 +32,7 @@ module Quickbooks
36
32
  xml = entity.to_xml_ns(options)
37
33
  response = do_http_post(url, valid_xml_document(xml))
38
34
  if response.code.to_i == 200
39
- parse_singular_entity_response_for_delete(model, response.body)
35
+ parse_singular_entity_response_for_delete(model, response.plain_body)
40
36
  else
41
37
  false
42
38
  end
@@ -50,7 +46,7 @@ module Quickbooks
50
46
  xml = entity.to_xml_ns(options)
51
47
  response = do_http_post(url_for_resource(model.resource_for_singular), valid_xml_document(xml))
52
48
  if response.code.to_i == 200
53
- model.from_xml(parse_singular_entity_response(model, response.body))
49
+ model.from_xml(parse_singular_entity_response(model, response.plain_body))
54
50
  else
55
51
  nil
56
52
  end
@@ -58,4 +54,4 @@ module Quickbooks
58
54
 
59
55
  end
60
56
  end
61
- end
57
+ end
@@ -0,0 +1,14 @@
1
+ module Quickbooks
2
+ module Util
3
+ class ClassUtil
4
+ def self.defined?(class_name)
5
+ begin
6
+ klass = Module.const_get(class_name)
7
+ return klass.is_a?(Class)
8
+ rescue NameError
9
+ return false
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -18,9 +18,9 @@
18
18
  # content=response.plain_body # Method from our library
19
19
  # puts "Transferred: #{response.body.length} bytes"
20
20
  # puts "Compression: #{response['content-encoding']}"
21
- # puts "Extracted: #{response.plain_body.length} bytes"
21
+ # puts "Extracted: #{response.plain_body.length} bytes"
22
22
  # end
23
- #
23
+ #
24
24
 
25
25
  require 'zlib'
26
26
  require 'stringio'
@@ -28,22 +28,27 @@ require 'stringio'
28
28
  class Net::HTTPResponse
29
29
  # Return the uncompressed content
30
30
  def plain_body
31
- encoding=self['content-encoding']
32
- content=nil
33
- if encoding then
31
+
32
+ encoding = self['Content-Encoding']
33
+ @_content ||= nil
34
+
35
+ return @_content if @_content
36
+
37
+ if encoding
34
38
  case encoding
35
39
  when 'gzip'
36
- i=Zlib::GzipReader.new(StringIO.new(self.body))
37
- content=i.read
40
+ i = Zlib::GzipReader.new(StringIO.new(self.body))
41
+ @_content = i.read
38
42
  when 'deflate'
39
- i=Zlib::Inflate.new
40
- content=i.inflate(self.body)
43
+ i = Zlib::Inflate.new
44
+ @_content = i.inflate(self.body)
41
45
  else
42
46
  raise "Unknown encoding - #{encoding}"
43
47
  end
44
48
  else
45
- content=self.body
49
+ @_content = self.body
46
50
  end
47
- return content
51
+
52
+ @_content
48
53
  end
49
54
  end
@@ -1,5 +1,5 @@
1
1
  module Quickbooks
2
2
 
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
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: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Caughlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-18 00:00:00.000000000 Z
11
+ date: 2014-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -170,33 +170,53 @@ executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
- - lib/quickbooks/http_encoding_helper.rb
173
+ - lib/quickbooks/model/account.rb
174
+ - lib/quickbooks/model/account_based_expense_line_detail.rb
174
175
  - lib/quickbooks/model/base_model.rb
176
+ - lib/quickbooks/model/base_reference.rb
177
+ - lib/quickbooks/model/bill.rb
178
+ - lib/quickbooks/model/bill_line_item.rb
179
+ - lib/quickbooks/model/bill_payment.rb
180
+ - lib/quickbooks/model/bill_payment_check.rb
181
+ - lib/quickbooks/model/bill_payment_credit_card.rb
182
+ - lib/quickbooks/model/bill_payment_line_item.rb
183
+ - lib/quickbooks/model/check_payment.rb
184
+ - lib/quickbooks/model/credit_card_payment.rb
185
+ - lib/quickbooks/model/credit_memo.rb
175
186
  - lib/quickbooks/model/custom_field.rb
176
187
  - lib/quickbooks/model/customer.rb
177
- - lib/quickbooks/model/customer_ref.rb
178
188
  - lib/quickbooks/model/discount_override.rb
179
189
  - lib/quickbooks/model/email_address.rb
180
190
  - lib/quickbooks/model/invoice.rb
181
- - lib/quickbooks/model/invoice_item_ref.rb
182
191
  - lib/quickbooks/model/invoice_line_item.rb
183
192
  - lib/quickbooks/model/item.rb
193
+ - lib/quickbooks/model/line.rb
184
194
  - lib/quickbooks/model/linked_transaction.rb
185
195
  - lib/quickbooks/model/meta_data.rb
186
196
  - lib/quickbooks/model/payment_line_detail.rb
197
+ - lib/quickbooks/model/payment_method.rb
187
198
  - lib/quickbooks/model/physical_address.rb
188
199
  - lib/quickbooks/model/sales_item_line_detail.rb
200
+ - lib/quickbooks/model/sales_receipt.rb
189
201
  - lib/quickbooks/model/sub_total_line_detail.rb
190
202
  - lib/quickbooks/model/telephone_number.rb
191
203
  - lib/quickbooks/model/web_site_address.rb
204
+ - lib/quickbooks/service/account.rb
192
205
  - lib/quickbooks/service/base_service.rb
206
+ - lib/quickbooks/service/bill.rb
207
+ - lib/quickbooks/service/bill_payment.rb
208
+ - lib/quickbooks/service/credit_memo.rb
193
209
  - lib/quickbooks/service/customer.rb
194
210
  - lib/quickbooks/service/invoice.rb
195
211
  - lib/quickbooks/service/item.rb
212
+ - lib/quickbooks/service/payment_method.rb
213
+ - lib/quickbooks/service/sales_receipt.rb
196
214
  - lib/quickbooks/service/service_crud.rb
215
+ - lib/quickbooks/util/class_util.rb
216
+ - lib/quickbooks/util/http_encoding_helper.rb
197
217
  - lib/quickbooks/util/logging.rb
198
218
  - lib/quickbooks/version.rb
199
- - lib/quickbooks.rb
219
+ - lib/quickbooks-ruby.rb
200
220
  homepage: http://github.com/ruckus/quickbooks-ruby
201
221
  licenses:
202
222
  - MIT
@@ -1,21 +0,0 @@
1
- module Quickbooks
2
- module Model
3
- class InvoiceItemRef < BaseModel
4
- xml_convention :camelcase
5
- xml_accessor :name, :from => '@name' # Attribute with name 'name'
6
- xml_accessor :value, :from => :content
7
-
8
- def initialize(value = nil)
9
- self.value = value
10
- end
11
-
12
- def to_i
13
- self.value.to_i
14
- end
15
-
16
- def to_s
17
- self.value.to_s
18
- end
19
- end
20
- end
21
- end