quickeebooks 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/lib/quickeebooks.rb +3 -1
  2. data/lib/quickeebooks/common/online_entity_model.rb +0 -3
  3. data/lib/quickeebooks/common/service_crud.rb +1 -1
  4. data/lib/quickeebooks/online/model/account.rb +1 -6
  5. data/lib/quickeebooks/online/model/address.rb +3 -2
  6. data/lib/quickeebooks/online/model/clazz.rb +60 -0
  7. data/lib/quickeebooks/online/model/intuit_type.rb +9 -4
  8. data/lib/quickeebooks/online/model/item.rb +3 -1
  9. data/lib/quickeebooks/online/service/account.rb +1 -41
  10. data/lib/quickeebooks/online/service/clazz.rb +12 -0
  11. data/lib/quickeebooks/online/service/employee.rb +2 -4
  12. data/lib/quickeebooks/online/service/invoice.rb +8 -58
  13. data/lib/quickeebooks/online/service/item.rb +1 -41
  14. data/lib/quickeebooks/online/service/service_base.rb +2 -2
  15. data/lib/quickeebooks/shared/service/access_token.rb +1 -0
  16. data/lib/quickeebooks/version.rb +1 -1
  17. metadata +8 -178
  18. data/Gemfile +0 -3
  19. data/Gemfile.lock +0 -86
  20. data/Guardfile +0 -8
  21. data/HISTORY.md +0 -44
  22. data/MIT-LICENSE +0 -9
  23. data/README.md +0 -451
  24. data/Rakefile +0 -17
  25. data/coverage/assets/0.7.1/application.css +0 -1110
  26. data/coverage/assets/0.7.1/application.js +0 -626
  27. data/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  28. data/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  29. data/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  30. data/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  31. data/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  32. data/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  33. data/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  34. data/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  35. data/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  36. data/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  37. data/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  38. data/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  39. data/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  40. data/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  41. data/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  42. data/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  43. data/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  44. data/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  45. data/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  46. data/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  47. data/coverage/assets/0.7.1/favicon_green.png +0 -0
  48. data/coverage/assets/0.7.1/favicon_red.png +0 -0
  49. data/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  50. data/coverage/assets/0.7.1/loading.gif +0 -0
  51. data/coverage/assets/0.7.1/magnify.png +0 -0
  52. data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  53. data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  54. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  55. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  56. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  57. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  58. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  59. data/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  60. data/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  61. data/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  62. data/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  63. data/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  64. data/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  65. data/coverage/index.html +0 -39346
  66. data/quickeebooks.gemspec +0 -30
  67. data/spec/mocks/oauth_consumer_mock.rb +0 -2
  68. data/spec/quickeebooks/common/online_line_item_model_methods_spec.rb +0 -41
  69. data/spec/quickeebooks/common/service_crud_spec.rb +0 -41
  70. data/spec/quickeebooks/online/account_spec.rb +0 -37
  71. data/spec/quickeebooks/online/bill_payment_spec.rb +0 -18
  72. data/spec/quickeebooks/online/bill_spec.rb +0 -17
  73. data/spec/quickeebooks/online/company_meta_data_spec.rb +0 -27
  74. data/spec/quickeebooks/online/customer_spec.rb +0 -48
  75. data/spec/quickeebooks/online/employee_spec.rb +0 -31
  76. data/spec/quickeebooks/online/id_spec.rb +0 -18
  77. data/spec/quickeebooks/online/invoice_spec.rb +0 -12
  78. data/spec/quickeebooks/online/journal_entry_spec.rb +0 -26
  79. data/spec/quickeebooks/online/payment_spec.rb +0 -19
  80. data/spec/quickeebooks/online/sales_receipt_spec.rb +0 -18
  81. data/spec/quickeebooks/online/services/account_spec.rb +0 -82
  82. data/spec/quickeebooks/online/services/bill_payment_spec.rb +0 -69
  83. data/spec/quickeebooks/online/services/bill_spec.rb +0 -61
  84. data/spec/quickeebooks/online/services/company_meta_data_spec.rb +0 -30
  85. data/spec/quickeebooks/online/services/customer_spec.rb +0 -93
  86. data/spec/quickeebooks/online/services/employee_spec.rb +0 -83
  87. data/spec/quickeebooks/online/services/filter_spec.rb +0 -53
  88. data/spec/quickeebooks/online/services/invoice_spec.rb +0 -54
  89. data/spec/quickeebooks/online/services/journal_entry_spec.rb +0 -75
  90. data/spec/quickeebooks/online/services/payment_spec.rb +0 -63
  91. data/spec/quickeebooks/online/services/sales_receipt_spec.rb +0 -64
  92. data/spec/quickeebooks/online/services/service_base_spec.rb +0 -150
  93. data/spec/quickeebooks/online/services/time_activity_spec.rb +0 -89
  94. data/spec/quickeebooks/online/services/tracking_class_spec.rb +0 -99
  95. data/spec/quickeebooks/online/services/vendor_spec.rb +0 -85
  96. data/spec/quickeebooks/online/time_activity_spec.rb +0 -18
  97. data/spec/quickeebooks/online/tracking_class_spec.rb +0 -32
  98. data/spec/quickeebooks/online/vendor_spec.rb +0 -33
  99. data/spec/quickeebooks/shared/access_token_spec.rb +0 -129
  100. data/spec/quickeebooks/shared/filter_spec.rb +0 -159
  101. data/spec/quickeebooks/shared/sort_spec.rb +0 -17
  102. data/spec/quickeebooks/windows/customer_spec.rb +0 -45
  103. data/spec/quickeebooks/windows/id_spec.rb +0 -18
  104. data/spec/quickeebooks/windows/services/class_spec.rb +0 -33
  105. data/spec/quickeebooks/windows/services/company_meta_data_spec.rb +0 -29
  106. data/spec/quickeebooks/windows/services/customer_spec.rb +0 -173
  107. data/spec/quickeebooks/windows/services/employee_spec.rb +0 -42
  108. data/spec/quickeebooks/windows/services/invoice_spec.rb +0 -127
  109. data/spec/quickeebooks/windows/services/job_spec.rb +0 -74
  110. data/spec/quickeebooks/windows/services/payment_method_spec.rb +0 -36
  111. data/spec/quickeebooks/windows/services/payment_spec.rb +0 -72
  112. data/spec/quickeebooks/windows/services/sales_rep_spec.rb +0 -42
  113. data/spec/quickeebooks/windows/services/sales_taxes_spec.rb +0 -36
  114. data/spec/quickeebooks/windows/services/service_base_spec.rb +0 -95
  115. data/spec/quickeebooks/windows/services/ship_method_spec.rb +0 -33
  116. data/spec/quickeebooks/windows/services/sync_activity_spec.rb +0 -42
  117. data/spec/quickeebooks/windows/services/sync_status_spec.rb +0 -35
  118. data/spec/quickeebooks/windows/services/time_activity_spec.rb +0 -38
  119. data/spec/quickeebooks_spec.rb +0 -8
  120. data/spec/spec_helper.rb +0 -48
  121. data/spec/support/oauth.rb +0 -20
  122. data/spec/xml/online/account.xml +0 -13
  123. data/spec/xml/online/accounts.xml +0 -108
  124. data/spec/xml/online/api_error.xml +0 -6
  125. data/spec/xml/online/bill.xml +0 -32
  126. data/spec/xml/online/bill2.xml +0 -32
  127. data/spec/xml/online/bill_payment.xml +0 -20
  128. data/spec/xml/online/bill_payment2.xml +0 -20
  129. data/spec/xml/online/bill_payments.xml +0 -26
  130. data/spec/xml/online/bills.xml +0 -33
  131. data/spec/xml/online/company_meta_data.xml +0 -37
  132. data/spec/xml/online/customer.xml +0 -77
  133. data/spec/xml/online/customer2.xml +0 -63
  134. data/spec/xml/online/customers.xml +0 -125
  135. data/spec/xml/online/deleted_invoice.xml +0 -2
  136. data/spec/xml/online/determine_base_url.xml +0 -10
  137. data/spec/xml/online/employee.xml +0 -31
  138. data/spec/xml/online/employee2.xml +0 -31
  139. data/spec/xml/online/employees.xml +0 -36
  140. data/spec/xml/online/invalid_user.xml +0 -7
  141. data/spec/xml/online/invoice.xml +0 -28
  142. data/spec/xml/online/journal_entries.xml +0 -38
  143. data/spec/xml/online/journal_entry.xml +0 -32
  144. data/spec/xml/online/journal_entry2.xml +0 -32
  145. data/spec/xml/online/payment.xml +0 -24
  146. data/spec/xml/online/payment2.xml +0 -24
  147. data/spec/xml/online/payments.xml +0 -30
  148. data/spec/xml/online/sales_receipt.xml +0 -36
  149. data/spec/xml/online/sales_receipt2.xml +0 -36
  150. data/spec/xml/online/sales_receipts.xml +0 -39
  151. data/spec/xml/online/time_activities.xml +0 -27
  152. data/spec/xml/online/time_activity.xml +0 -21
  153. data/spec/xml/online/time_activity2.xml +0 -21
  154. data/spec/xml/online/tracking_class.xml +0 -11
  155. data/spec/xml/online/tracking_class_updated.xml +0 -11
  156. data/spec/xml/online/tracking_classes.xml +0 -26
  157. data/spec/xml/online/user.xml +0 -11
  158. data/spec/xml/online/vendor.xml +0 -34
  159. data/spec/xml/online/vendor2.xml +0 -34
  160. data/spec/xml/online/vendors.xml +0 -67
  161. data/spec/xml/shared/disconnect_invalid.xml +0 -6
  162. data/spec/xml/shared/disconnect_success.xml +0 -5
  163. data/spec/xml/shared/reconnect_error_expired.xml +0 -6
  164. data/spec/xml/shared/reconnect_error_not_approved.xml +0 -6
  165. data/spec/xml/shared/reconnect_error_out_of_bounds.xml +0 -6
  166. data/spec/xml/shared/reconnect_success.xml +0 -8
  167. data/spec/xml/windows/classes.xml +0 -41
  168. data/spec/xml/windows/company_meta_data.xml +0 -30
  169. data/spec/xml/windows/customer.xml +0 -56
  170. data/spec/xml/windows/customer_create_success.xml +0 -13
  171. data/spec/xml/windows/customer_update_success.xml +0 -13
  172. data/spec/xml/windows/customers.xml +0 -137
  173. data/spec/xml/windows/employees.xml +0 -36
  174. data/spec/xml/windows/fetch_customer_by_id.xml +0 -53
  175. data/spec/xml/windows/http_401.xml +0 -8
  176. data/spec/xml/windows/invoice_success_create.xml +0 -11
  177. data/spec/xml/windows/invoices.xml +0 -436
  178. data/spec/xml/windows/job_list_error_invalid_filter_ordering.xml +0 -9
  179. data/spec/xml/windows/jobs.xml +0 -71
  180. data/spec/xml/windows/payment_create_success.xml +0 -11
  181. data/spec/xml/windows/payment_methods.xml +0 -121
  182. data/spec/xml/windows/payments.xml +0 -39
  183. data/spec/xml/windows/sales_reps.xml +0 -204
  184. data/spec/xml/windows/sales_taxes.xml +0 -34
  185. data/spec/xml/windows/ship_methods.xml +0 -139
  186. data/spec/xml/windows/sync_activity_responses.xml +0 -20
  187. data/spec/xml/windows/sync_status_responses.xml +0 -186
  188. data/spec/xml/windows/time_activities.xml +0 -30
  189. data/tmp/console.rb +0 -10
data/lib/quickeebooks.rb CHANGED
@@ -85,6 +85,7 @@ require 'quickeebooks/common/addressable'
85
85
  require 'quickeebooks/online/model/intuit_type'
86
86
  require 'quickeebooks/online/model/company_meta_data'
87
87
  require 'quickeebooks/online/model/customer'
88
+ require 'quickeebooks/online/model/clazz'
88
89
  require 'quickeebooks/online/model/account'
89
90
  require 'quickeebooks/online/model/bill'
90
91
  require 'quickeebooks/online/model/bill_header'
@@ -126,6 +127,7 @@ require 'quickeebooks/online/service/pagination'
126
127
  require 'quickeebooks/online/service/sort'
127
128
  require 'quickeebooks/online/service/company_meta_data'
128
129
  require 'quickeebooks/online/service/customer'
130
+ require 'quickeebooks/online/service/clazz'
129
131
  require 'quickeebooks/online/service/account'
130
132
  require 'quickeebooks/online/service/bill'
131
133
  require 'quickeebooks/online/service/bill_payment'
@@ -216,4 +218,4 @@ require 'quickeebooks/windows/service/employee'
216
218
  require 'quickeebooks/windows/service/time_activity'
217
219
  require 'quickeebooks/windows/service/job'
218
220
  require 'quickeebooks/windows/service/sync_activity'
219
- require 'quickeebooks/windows/service/sync_status'
221
+ require 'quickeebooks/windows/service/sync_status'
@@ -50,9 +50,6 @@ module OnlineEntityModel
50
50
  end
51
51
 
52
52
  module ClassMethods
53
- def resource_for_collection
54
- "#{self::REST_RESOURCE}s"
55
- end
56
53
  end
57
54
 
58
55
  end
@@ -1,7 +1,7 @@
1
1
  module ServiceCRUD
2
2
 
3
3
  def create(object)
4
- raise InvalidModelException unless object.valid?
4
+ raise InvalidModelException.new(object.errors.full_messages.join(',')) unless object.valid?
5
5
  xml = object.to_xml_ns
6
6
  response = do_http_post(url_for_resource(model.resource_for_singular), valid_xml_document(xml))
7
7
  if response.code.to_i == 200
@@ -13,7 +13,7 @@ module Quickeebooks
13
13
  XML_NODE = "Account"
14
14
 
15
15
  xml_convention :camelcase
16
- xml_accessor :id, :from => 'Id'
16
+ xml_accessor :id, :from => 'Id', :as => Quickeebooks::Online::Model::Id
17
17
  xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
18
18
  xml_accessor :meta_data, :from => 'MetaData', :as => Quickeebooks::Online::Model::MetaData
19
19
  xml_accessor :name, :from => 'Name'
@@ -47,11 +47,6 @@ module Quickeebooks
47
47
  id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
48
48
  end
49
49
 
50
- #== Class methods
51
- def self.resource_for_collection
52
- "#{self::REST_RESOURCE}s"
53
- end
54
-
55
50
  end
56
51
  end
57
52
 
@@ -19,8 +19,9 @@ module Quickeebooks
19
19
  postal_code
20
20
  end
21
21
 
22
- def to_xml_ns
23
- to_xml_inject_ns('Address')
22
+ def to_xml_ns(options = {})
23
+ options.merge!(:destination_name => 'Address')
24
+ to_xml_inject_ns('Address', options)
24
25
  end
25
26
 
26
27
  end
@@ -0,0 +1,60 @@
1
+ require "quickeebooks"
2
+ require "quickeebooks/online/model/meta_data"
3
+ require "quickeebooks/online/model/id"
4
+ require "quickeebooks/online/model/meta_data"
5
+
6
+ module Quickeebooks
7
+ module Online
8
+ module Model
9
+ class Clazz < Quickeebooks::Online::Model::IntuitType
10
+ include ActiveModel::Validations
11
+
12
+ XML_COLLECTION_NODE = 'Classes'
13
+ XML_NODE = 'Class'
14
+
15
+ # https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/class
16
+ REST_RESOURCE = "class"
17
+
18
+ xml_convention :camelcase
19
+ xml_accessor :id, :from => 'Id', :as => Quickeebooks::Online::Model::Id
20
+ xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
21
+ xml_accessor :meta_data, :from => 'MetaData', :as => Quickeebooks::Online::Model::MetaData
22
+ xml_accessor :name
23
+ xml_accessor :class_parent_id, :from => 'ClassParentId', :as => Quickeebooks::Online::Model::Id
24
+
25
+ validates_length_of :name, :minimum => 1, :maximum => 256
26
+
27
+ def valid_for_update?
28
+ if sync_token.nil?
29
+ errors.add(:sync_token, "Missing required attribute SyncToken for update")
30
+ end
31
+ errors.empty?
32
+ end
33
+
34
+ def valid_for_create?
35
+ valid?
36
+ if type_of.nil?
37
+ errors.add(:type_of, "Missing required attribute TypeOf for Create")
38
+ end
39
+ errors.empty?
40
+ end
41
+
42
+ def to_xml_ns(options = {})
43
+ options.merge!(:destination_name => 'Class')
44
+ to_xml_inject_ns('Clazz', options)
45
+ end
46
+
47
+ # To delete an account Intuit requires we provide Id and SyncToken fields
48
+ def valid_for_deletion?
49
+ return false if(id.nil? || sync_token.nil?)
50
+ id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
51
+ end
52
+
53
+ def self.resource_for_collection
54
+ "classes"
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -15,7 +15,7 @@ module Quickeebooks
15
15
  # vs
16
16
  # Create an account, fetch an account, etc: <baseURL>/resource/account/v2/<realmID>
17
17
  def self.resource_for_collection
18
- self::REST_RESOURCE
18
+ "#{self::REST_RESOURCE}s"
19
19
  end
20
20
 
21
21
  def self.resource_for_singular
@@ -30,10 +30,15 @@ module Quickeebooks
30
30
  def to_xml_inject_ns(model_name, options = {})
31
31
  s = StringIO.new
32
32
  xml = to_xml(options).write_to(s, :indent => 0, :indent_text => '')
33
- s.string.sub("<#{model_name}>", "<#{model_name} #{Quickeebooks::Online::Service::ServiceBase::XML_NS}>")
33
+ destination_name = options.fetch(:destination_name, nil)
34
+ destination_name ||= model_name
35
+
36
+ step1 = s.string.sub("<#{model_name}>", "<#{destination_name} #{Quickeebooks::Online::Service::ServiceBase::XML_NS}>")
37
+ step2 = step1.sub("</#{model_name}>", "</#{destination_name}>")
38
+ step2
34
39
  end
35
40
 
36
- end
37
- end
41
+ end
42
+ end
38
43
  end
39
44
  end
@@ -14,7 +14,7 @@ module Quickeebooks
14
14
  XML_NODE = "Item"
15
15
 
16
16
  # <baseURL>/resource/items/v2/<realmID>
17
- REST_RESOURCE = "items"
17
+ REST_RESOURCE = "item"
18
18
 
19
19
  xml_name 'Item'
20
20
  xml_accessor :id, :from => 'Id', :as => Quickeebooks::Online::Model::Id
@@ -32,6 +32,7 @@ module Quickeebooks
32
32
  xml_accessor :expense_account_reference, :from => 'ExpenseAccountRef', :as => Quickeebooks::Online::Model::AccountReference
33
33
 
34
34
  validates_presence_of :account_reference
35
+ validates_length_of :name, :within => 1..100
35
36
 
36
37
  def to_xml_ns(options = {})
37
38
  to_xml_inject_ns('Item', options)
@@ -46,6 +47,7 @@ module Quickeebooks
46
47
  def taxable?
47
48
  taxable == "true"
48
49
  end
50
+
49
51
  end
50
52
  end
51
53
  end
@@ -5,47 +5,7 @@ module Quickeebooks
5
5
  module Online
6
6
  module Service
7
7
  class Account < ServiceBase
8
-
9
- def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
10
- fetch_collection(Quickeebooks::Online::Model::Account, filters, page, per_page, sort, options)
11
- end
12
-
13
- def create(account)
14
- raise InvalidModelException.new(account.errors.full_messages.join(", ")) unless account.valid?
15
- xml = account.to_xml_ns
16
- response = do_http_post(url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular), valid_xml_document(xml))
17
- if response && response.code.to_i == 200
18
- Quickeebooks::Online::Model::Account.from_xml(response.body)
19
- else
20
- nil
21
- end
22
- end
23
-
24
- def update(account)
25
- raise InvalidModelException unless account.valid_for_update?
26
- xml = account.to_xml_ns
27
- url = "#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{account.id}"
28
- response = do_http_post(url, valid_xml_document(xml))
29
- if response && response.code.to_i == 200
30
- Quickeebooks::Online::Model::Account.from_xml(response.body)
31
- else
32
- nil
33
- end
34
- end
35
-
36
- def fetch_by_id(account_id)
37
- response = do_http_get("#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{account_id}")
38
- Quickeebooks::Online::Model::Account.from_xml(response.body)
39
- end
40
-
41
- def delete(account)
42
- raise InvalidModelException.new("Missing required parameters for delete") unless account.valid_for_deletion?
43
- xml = valid_xml_document(account.to_xml_ns(:fields => ['Id', 'SyncToken']))
44
- url = "#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{account.id}"
45
- response = do_http_post(url, xml, {:methodx => "delete"})
46
- response.code.to_i == 200
47
- end
48
-
8
+ include ServiceCRUD
49
9
  end
50
10
  end
51
11
  end
@@ -0,0 +1,12 @@
1
+ require 'quickeebooks/online/model/clazz'
2
+ require 'quickeebooks/online/service/service_base'
3
+
4
+ module Quickeebooks
5
+ module Online
6
+ module Service
7
+ class Clazz < Quickeebooks::Online::Service::ServiceBase
8
+ include ServiceCRUD
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,15 +1,13 @@
1
1
  require 'quickeebooks/online/service/service_base'
2
2
  require 'quickeebooks/online/model/employee'
3
3
  require 'quickeebooks/common/service_crud'
4
- require 'nokogiri'
5
4
 
6
5
  module Quickeebooks
7
6
  module Online
8
7
  module Service
9
- class Employee < ServiceBase
8
+ class Employee < Quickeebooks::Online::Service::ServiceBase
10
9
  include ServiceCRUD
11
10
  end
12
11
  end
13
12
  end
14
- end
15
-
13
+ end
@@ -8,69 +8,19 @@ module Quickeebooks
8
8
  module Online
9
9
  module Service
10
10
  class Invoice < ServiceBase
11
-
12
- def create(invoice)
13
- raise InvalidModelException unless invoice.valid?
14
- xml = invoice.to_xml_ns
15
- response = do_http_post(url_for_resource(Quickeebooks::Online::Model::Invoice.resource_for_singular), valid_xml_document(xml))
16
- if response.code.to_i == 200
17
- Quickeebooks::Online::Model::Invoice.from_xml(response.body)
18
- else
19
- nil
20
- end
21
- end
22
-
23
- # Fetch an invoice by its ID
24
- # Returns: +Invoice+ object
25
- def fetch_by_id(invoice_id)
26
- response = do_http_get("#{url_for_resource(Quickeebooks::Online::Model::Invoice::REST_RESOURCE)}/#{invoice_id}")
27
- Quickeebooks::Online::Model::Invoice.from_xml(response.body)
28
- end
29
-
30
- def update(invoice)
31
- raise InvalidModelException.new("Missing required parameters for update") unless invoice.valid_for_update?
32
- url = "#{url_for_resource(Quickeebooks::Online::Model::Invoice.resource_for_singular)}/#{invoice.id}"
33
- xml = invoice.to_xml_ns
34
- response = do_http_post(url, valid_xml_document(xml))
35
- if response.code.to_i == 200
36
- Quickeebooks::Online::Model::Invoice.from_xml(response.body)
37
- else
38
- nil
39
- end
40
- end
41
-
42
- # Fetch a +Collection+ of +Invoice+ objects
43
- # Arguments:
44
- # filters: Array of +Filter+ objects to apply
45
- # page: +Fixnum+ Starting page
46
- # per_page: +Fixnum+ How many results to fetch per page
47
- # sort: +Sort+ object
48
- # options: +Hash+ extra arguments
49
- def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
50
- fetch_collection(Quickeebooks::Online::Model::Invoice, filters, page, per_page, sort, options)
51
- end
52
-
11
+ include ServiceCRUD
53
12
  # Returns the absolute path to the PDF on disk
54
13
  # Its left to the caller to unlink the file at some later date
55
- # Returns: +String+ : absolute path to file on disk or nil if couldnt fetch PDF
14
+ # Returns: +String+ : absolute path to file on disk or nil if couldn't fetch PDF
56
15
  def invoice_as_pdf(invoice_id, destination_file_name)
57
16
  response = do_http_get("#{url_for_resource("invoice-document")}/#{invoice_id}", {}, {'Content-Type' => 'application/pdf'})
58
- if response && response.code.to_i == 200
59
- File.open(destination_file_name, "wb") do |file|
60
- file.write(response.body)
61
- end
62
- destination_file_name
63
- else
64
- nil
17
+ File.open(destination_file_name, "wb") do |file|
18
+ file.write(response.body)
65
19
  end
66
- end
67
-
68
- def delete(invoice)
69
- raise InvalidModelException.new("Missing required parameters for delete") unless invoice.valid_for_deletion?
70
- xml = valid_xml_document(invoice.to_xml_ns(:fields => ['Id', 'SyncToken']))
71
- url = "#{url_for_resource(Quickeebooks::Online::Model::Invoice::REST_RESOURCE)}/#{invoice.id.value}"
72
- response = do_http_post(url, xml, {:methodx => "delete"})
73
- response.code.to_i == 200
20
+ destination_file_name
21
+ rescue => e
22
+ log "Error downloading invoice id #{invoice_id} pdf file #{destination_file_name} with #{e}"
23
+ nil
74
24
  end
75
25
 
76
26
  end
@@ -5,47 +5,7 @@ module Quickeebooks
5
5
  module Online
6
6
  module Service
7
7
  class Item < ServiceBase
8
-
9
- def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
10
- fetch_collection(Quickeebooks::Online::Model::Item, filters, page, per_page, sort, options)
11
- end
12
-
13
- def create(item)
14
- raise InvalidModelException unless item.valid?
15
- xml = item.to_xml_ns
16
- response = do_http_post(url_for_resource(Quickeebooks::Online::Model::Item.resource_for_singular), valid_xml_document(xml))
17
- if response && response.code.to_i == 200
18
- Quickeebooks::Online::Model::Item.from_xml(response.body)
19
- else
20
- nil
21
- end
22
- end
23
-
24
- def update(item)
25
- raise InvalidModelException unless item.valid?
26
- xml = item.to_xml_ns
27
- url = "#{url_for_resource(Quickeebooks::Online::Model::Item.resource_for_singular)}/#{item.id}"
28
- response = do_http_post(url, valid_xml_document(xml))
29
- if response && response.code.to_i == 200
30
- Quickeebooks::Online::Model::Item.from_xml(response.body)
31
- else
32
- nil
33
- end
34
- end
35
-
36
- def fetch_by_id(id)
37
- response = do_http_get("#{url_for_resource(Quickeebooks::Online::Model::Item.resource_for_singular)}/#{id}")
38
- Quickeebooks::Online::Model::Item.from_xml(response.body)
39
- end
40
-
41
- def delete(item)
42
- raise InvalidModelException.new("Missing required parameters for delete") unless item.valid_for_deletion?
43
- xml = valid_xml_document(item.to_xml_ns(:fields => ['Id', 'SyncToken']))
44
- url = "#{url_for_resource(Quickeebooks::Online::Model::Item.resource_for_singular)}/#{item.id}"
45
- response = do_http_post(url, xml, {:methodx => "delete"})
46
- response.code.to_i == 200
47
- end
48
-
8
+ include ServiceCRUD
49
9
  end
50
10
  end
51
11
  end
@@ -30,8 +30,8 @@ module Quickeebooks
30
30
  msg += "This version of the constructor is deprecated. "
31
31
  msg += "Use the no-arg constructor and set the AccessToken (access_token=) and the RealmID (realm_id=) using the setters."
32
32
  warn(msg)
33
- access_token = oauth_access_token
34
- realm_id = realm_id
33
+ self.access_token = oauth_access_token
34
+ self.realm_id = realm_id
35
35
  end
36
36
  end
37
37
 
@@ -12,6 +12,7 @@ module Quickeebooks
12
12
  xml_accessor :error_message
13
13
  xml_accessor :token, :from => 'OAuthToken'
14
14
  xml_accessor :secret, :from => 'OAuthTokenSecret'
15
+ xml_accessor :server_time, :from => 'ServerTime', :as => Time
15
16
 
16
17
  def error?
17
18
  error_code.to_i != 0
@@ -1,5 +1,5 @@
1
1
  module Quickeebooks
2
2
 
3
- VERSION = "0.1.10"
3
+ VERSION = "0.1.11"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickeebooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roxml
@@ -48,16 +48,16 @@ dependencies:
48
48
  prerelease: false
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.5.9
54
54
  none: false
55
55
  type: :runtime
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ! '>='
58
+ - - ~>
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: 1.5.9
61
61
  none: false
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: activemodel
@@ -209,51 +209,6 @@ executables: []
209
209
  extensions: []
210
210
  extra_rdoc_files: []
211
211
  files:
212
- - coverage/assets/0.7.1/application.css
213
- - coverage/assets/0.7.1/application.js
214
- - coverage/assets/0.7.1/fancybox/blank.gif
215
- - coverage/assets/0.7.1/fancybox/fancy_close.png
216
- - coverage/assets/0.7.1/fancybox/fancy_loading.png
217
- - coverage/assets/0.7.1/fancybox/fancy_nav_left.png
218
- - coverage/assets/0.7.1/fancybox/fancy_nav_right.png
219
- - coverage/assets/0.7.1/fancybox/fancy_shadow_e.png
220
- - coverage/assets/0.7.1/fancybox/fancy_shadow_n.png
221
- - coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png
222
- - coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png
223
- - coverage/assets/0.7.1/fancybox/fancy_shadow_s.png
224
- - coverage/assets/0.7.1/fancybox/fancy_shadow_se.png
225
- - coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png
226
- - coverage/assets/0.7.1/fancybox/fancy_shadow_w.png
227
- - coverage/assets/0.7.1/fancybox/fancy_title_left.png
228
- - coverage/assets/0.7.1/fancybox/fancy_title_main.png
229
- - coverage/assets/0.7.1/fancybox/fancy_title_over.png
230
- - coverage/assets/0.7.1/fancybox/fancy_title_right.png
231
- - coverage/assets/0.7.1/fancybox/fancybox-x.png
232
- - coverage/assets/0.7.1/fancybox/fancybox-y.png
233
- - coverage/assets/0.7.1/fancybox/fancybox.png
234
- - coverage/assets/0.7.1/favicon_green.png
235
- - coverage/assets/0.7.1/favicon_red.png
236
- - coverage/assets/0.7.1/favicon_yellow.png
237
- - coverage/assets/0.7.1/loading.gif
238
- - coverage/assets/0.7.1/magnify.png
239
- - coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
240
- - coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
241
- - coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
242
- - coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
243
- - coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png
244
- - coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
245
- - coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
246
- - coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
247
- - coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png
248
- - coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png
249
- - coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png
250
- - coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png
251
- - coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png
252
- - coverage/index.html
253
- - Gemfile
254
- - Gemfile.lock
255
- - Guardfile
256
- - HISTORY.md
257
212
  - lib/quickeebooks/common/addressable.rb
258
213
  - lib/quickeebooks/common/date_time.rb
259
214
  - lib/quickeebooks/common/logging.rb
@@ -271,6 +226,7 @@ files:
271
226
  - lib/quickeebooks/online/model/bill_payment_header.rb
272
227
  - lib/quickeebooks/online/model/bill_payment_line_item.rb
273
228
  - lib/quickeebooks/online/model/bill_reimbursable.rb
229
+ - lib/quickeebooks/online/model/clazz.rb
274
230
  - lib/quickeebooks/online/model/company_meta_data.rb
275
231
  - lib/quickeebooks/online/model/credit_card.rb
276
232
  - lib/quickeebooks/online/model/credit_charge_info.rb
@@ -312,6 +268,7 @@ files:
312
268
  - lib/quickeebooks/online/service/account.rb
313
269
  - lib/quickeebooks/online/service/bill.rb
314
270
  - lib/quickeebooks/online/service/bill_payment.rb
271
+ - lib/quickeebooks/online/service/clazz.rb
315
272
  - lib/quickeebooks/online/service/company_meta_data.rb
316
273
  - lib/quickeebooks/online/service/customer.rb
317
274
  - lib/quickeebooks/online/service/employee.rb
@@ -420,133 +377,6 @@ files:
420
377
  - lib/quickeebooks/windows/service/sync_status.rb
421
378
  - lib/quickeebooks/windows/service/time_activity.rb
422
379
  - lib/quickeebooks.rb
423
- - MIT-LICENSE
424
- - quickeebooks.gemspec
425
- - Rakefile
426
- - README.md
427
- - spec/mocks/oauth_consumer_mock.rb
428
- - spec/quickeebooks/common/online_line_item_model_methods_spec.rb
429
- - spec/quickeebooks/common/service_crud_spec.rb
430
- - spec/quickeebooks/online/account_spec.rb
431
- - spec/quickeebooks/online/bill_payment_spec.rb
432
- - spec/quickeebooks/online/bill_spec.rb
433
- - spec/quickeebooks/online/company_meta_data_spec.rb
434
- - spec/quickeebooks/online/customer_spec.rb
435
- - spec/quickeebooks/online/employee_spec.rb
436
- - spec/quickeebooks/online/id_spec.rb
437
- - spec/quickeebooks/online/invoice_spec.rb
438
- - spec/quickeebooks/online/journal_entry_spec.rb
439
- - spec/quickeebooks/online/payment_spec.rb
440
- - spec/quickeebooks/online/sales_receipt_spec.rb
441
- - spec/quickeebooks/online/services/account_spec.rb
442
- - spec/quickeebooks/online/services/bill_payment_spec.rb
443
- - spec/quickeebooks/online/services/bill_spec.rb
444
- - spec/quickeebooks/online/services/company_meta_data_spec.rb
445
- - spec/quickeebooks/online/services/customer_spec.rb
446
- - spec/quickeebooks/online/services/employee_spec.rb
447
- - spec/quickeebooks/online/services/filter_spec.rb
448
- - spec/quickeebooks/online/services/invoice_spec.rb
449
- - spec/quickeebooks/online/services/journal_entry_spec.rb
450
- - spec/quickeebooks/online/services/payment_spec.rb
451
- - spec/quickeebooks/online/services/sales_receipt_spec.rb
452
- - spec/quickeebooks/online/services/service_base_spec.rb
453
- - spec/quickeebooks/online/services/time_activity_spec.rb
454
- - spec/quickeebooks/online/services/tracking_class_spec.rb
455
- - spec/quickeebooks/online/services/vendor_spec.rb
456
- - spec/quickeebooks/online/time_activity_spec.rb
457
- - spec/quickeebooks/online/tracking_class_spec.rb
458
- - spec/quickeebooks/online/vendor_spec.rb
459
- - spec/quickeebooks/shared/access_token_spec.rb
460
- - spec/quickeebooks/shared/filter_spec.rb
461
- - spec/quickeebooks/shared/sort_spec.rb
462
- - spec/quickeebooks/windows/customer_spec.rb
463
- - spec/quickeebooks/windows/id_spec.rb
464
- - spec/quickeebooks/windows/services/class_spec.rb
465
- - spec/quickeebooks/windows/services/company_meta_data_spec.rb
466
- - spec/quickeebooks/windows/services/customer_spec.rb
467
- - spec/quickeebooks/windows/services/employee_spec.rb
468
- - spec/quickeebooks/windows/services/invoice_spec.rb
469
- - spec/quickeebooks/windows/services/job_spec.rb
470
- - spec/quickeebooks/windows/services/payment_method_spec.rb
471
- - spec/quickeebooks/windows/services/payment_spec.rb
472
- - spec/quickeebooks/windows/services/sales_rep_spec.rb
473
- - spec/quickeebooks/windows/services/sales_taxes_spec.rb
474
- - spec/quickeebooks/windows/services/service_base_spec.rb
475
- - spec/quickeebooks/windows/services/ship_method_spec.rb
476
- - spec/quickeebooks/windows/services/sync_activity_spec.rb
477
- - spec/quickeebooks/windows/services/sync_status_spec.rb
478
- - spec/quickeebooks/windows/services/time_activity_spec.rb
479
- - spec/quickeebooks_spec.rb
480
- - spec/spec_helper.rb
481
- - spec/support/oauth.rb
482
- - spec/xml/online/account.xml
483
- - spec/xml/online/accounts.xml
484
- - spec/xml/online/api_error.xml
485
- - spec/xml/online/bill.xml
486
- - spec/xml/online/bill2.xml
487
- - spec/xml/online/bill_payment.xml
488
- - spec/xml/online/bill_payment2.xml
489
- - spec/xml/online/bill_payments.xml
490
- - spec/xml/online/bills.xml
491
- - spec/xml/online/company_meta_data.xml
492
- - spec/xml/online/customer.xml
493
- - spec/xml/online/customer2.xml
494
- - spec/xml/online/customers.xml
495
- - spec/xml/online/deleted_invoice.xml
496
- - spec/xml/online/determine_base_url.xml
497
- - spec/xml/online/employee.xml
498
- - spec/xml/online/employee2.xml
499
- - spec/xml/online/employees.xml
500
- - spec/xml/online/invalid_user.xml
501
- - spec/xml/online/invoice.xml
502
- - spec/xml/online/journal_entries.xml
503
- - spec/xml/online/journal_entry.xml
504
- - spec/xml/online/journal_entry2.xml
505
- - spec/xml/online/payment.xml
506
- - spec/xml/online/payment2.xml
507
- - spec/xml/online/payments.xml
508
- - spec/xml/online/sales_receipt.xml
509
- - spec/xml/online/sales_receipt2.xml
510
- - spec/xml/online/sales_receipts.xml
511
- - spec/xml/online/time_activities.xml
512
- - spec/xml/online/time_activity.xml
513
- - spec/xml/online/time_activity2.xml
514
- - spec/xml/online/tracking_class.xml
515
- - spec/xml/online/tracking_class_updated.xml
516
- - spec/xml/online/tracking_classes.xml
517
- - spec/xml/online/user.xml
518
- - spec/xml/online/vendor.xml
519
- - spec/xml/online/vendor2.xml
520
- - spec/xml/online/vendors.xml
521
- - spec/xml/shared/disconnect_invalid.xml
522
- - spec/xml/shared/disconnect_success.xml
523
- - spec/xml/shared/reconnect_error_expired.xml
524
- - spec/xml/shared/reconnect_error_not_approved.xml
525
- - spec/xml/shared/reconnect_error_out_of_bounds.xml
526
- - spec/xml/shared/reconnect_success.xml
527
- - spec/xml/windows/classes.xml
528
- - spec/xml/windows/company_meta_data.xml
529
- - spec/xml/windows/customer.xml
530
- - spec/xml/windows/customer_create_success.xml
531
- - spec/xml/windows/customer_update_success.xml
532
- - spec/xml/windows/customers.xml
533
- - spec/xml/windows/employees.xml
534
- - spec/xml/windows/fetch_customer_by_id.xml
535
- - spec/xml/windows/http_401.xml
536
- - spec/xml/windows/invoice_success_create.xml
537
- - spec/xml/windows/invoices.xml
538
- - spec/xml/windows/job_list_error_invalid_filter_ordering.xml
539
- - spec/xml/windows/jobs.xml
540
- - spec/xml/windows/payment_create_success.xml
541
- - spec/xml/windows/payment_methods.xml
542
- - spec/xml/windows/payments.xml
543
- - spec/xml/windows/sales_reps.xml
544
- - spec/xml/windows/sales_taxes.xml
545
- - spec/xml/windows/ship_methods.xml
546
- - spec/xml/windows/sync_activity_responses.xml
547
- - spec/xml/windows/sync_status_responses.xml
548
- - spec/xml/windows/time_activities.xml
549
- - tmp/console.rb
550
380
  homepage: http://github.com/ruckus/quickeebooks
551
381
  licenses: []
552
382
  post_install_message: