quickeebooks 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/quickeebooks.rb +2 -0
- data/lib/quickeebooks/online/service/service_base.rb +1 -1
- data/lib/quickeebooks/version.rb +1 -1
- data/lib/quickeebooks/windows/model/clazz.rb +66 -0
- data/lib/quickeebooks/windows/model/id.rb +5 -0
- data/lib/quickeebooks/windows/service/clazz.rb +20 -0
- data/spec/quickeebooks/windows/services/class_spec.rb +38 -0
- data/spec/xml/windows/classes.xml +41 -0
- metadata +6 -2
data/Gemfile.lock
CHANGED
data/lib/quickeebooks.rb
CHANGED
@@ -124,6 +124,7 @@ require 'quickeebooks/windows/model/payment_detail'
|
|
124
124
|
require 'quickeebooks/windows/model/credit_card'
|
125
125
|
require 'quickeebooks/windows/model/credit_charge_info'
|
126
126
|
require 'quickeebooks/windows/model/credit_charge_response'
|
127
|
+
require 'quickeebooks/windows/model/clazz'
|
127
128
|
|
128
129
|
# Services
|
129
130
|
require 'quickeebooks/windows/service/filter'
|
@@ -138,3 +139,4 @@ require 'quickeebooks/windows/service/sales_tax'
|
|
138
139
|
require 'quickeebooks/windows/service/customer_msg'
|
139
140
|
require 'quickeebooks/windows/service/company_meta_data'
|
140
141
|
require 'quickeebooks/windows/service/payment'
|
142
|
+
require 'quickeebooks/windows/service/clazz'
|
@@ -80,7 +80,7 @@ module Quickeebooks
|
|
80
80
|
# store service base response
|
81
81
|
# so it can be accessed by other methods
|
82
82
|
def service_response
|
83
|
-
@service_response ||= @oauth.request(:get, qb_base_uri_with_realm_id)
|
83
|
+
@service_response ||= check_response(@oauth.request(:get, qb_base_uri_with_realm_id))
|
84
84
|
end
|
85
85
|
|
86
86
|
# allows for reuse of service base's xml doc
|
data/lib/quickeebooks/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "quickeebooks"
|
2
|
+
require "quickeebooks/windows/model/meta_data"
|
3
|
+
require "quickeebooks/windows/model/id"
|
4
|
+
require "quickeebooks/windows/model/custom_field"
|
5
|
+
require "quickeebooks/windows/model/meta_data"
|
6
|
+
|
7
|
+
module Quickeebooks
|
8
|
+
module Windows
|
9
|
+
module Model
|
10
|
+
class Clazz < Quickeebooks::Windows::Model::IntuitType
|
11
|
+
include ActiveModel::Validations
|
12
|
+
|
13
|
+
XML_COLLECTION_NODE = 'Classes'
|
14
|
+
XML_NODE = 'Class'
|
15
|
+
|
16
|
+
# https://services.intuit.com/sb/customer/v2/<realmID>
|
17
|
+
REST_RESOURCE = "class"
|
18
|
+
|
19
|
+
xml_convention :camelcase
|
20
|
+
xml_accessor :id, :from => 'Id', :as => Quickeebooks::Windows::Model::Id
|
21
|
+
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
|
22
|
+
xml_accessor :synchronized, :from => 'Synchronized'
|
23
|
+
xml_accessor :meta_data, :from => 'MetaData', :as => Quickeebooks::Windows::Model::MetaData
|
24
|
+
xml_accessor :custom_fields, :from => 'CustomField', :as => [Quickeebooks::Windows::Model::CustomField]
|
25
|
+
xml_accessor :draft
|
26
|
+
xml_accessor :object_state
|
27
|
+
xml_accessor :name
|
28
|
+
xml_accessor :active
|
29
|
+
xml_accessor :class_parent_id, :from => 'ClassParentId', :as => Quickeebooks::Windows::Model::Id
|
30
|
+
xml_accessor :class_parent_name, :from => 'ClassParentName'
|
31
|
+
|
32
|
+
validates_length_of :name, :minimum => 1, :maximum => 256
|
33
|
+
|
34
|
+
def active?
|
35
|
+
active == 'true'
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid_for_update?
|
39
|
+
if sync_token.nil?
|
40
|
+
errors.add(:sync_token, "Missing required attribute SyncToken for update")
|
41
|
+
end
|
42
|
+
errors.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid_for_create?
|
46
|
+
valid?
|
47
|
+
if type_of.nil?
|
48
|
+
errors.add(:type_of, "Missing required attribute TypeOf for Create")
|
49
|
+
end
|
50
|
+
errors.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_xml_ns(options = {})
|
54
|
+
to_xml
|
55
|
+
end
|
56
|
+
|
57
|
+
# To delete an account Intuit requires we provide Id and SyncToken fields
|
58
|
+
def valid_for_deletion?
|
59
|
+
return false if(id.nil? || sync_token.nil?)
|
60
|
+
id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'quickeebooks/windows/model/clazz'
|
2
|
+
require 'quickeebooks/windows/service/service_base'
|
3
|
+
|
4
|
+
module Quickeebooks
|
5
|
+
module Windows
|
6
|
+
module Service
|
7
|
+
class Clazz < Quickeebooks::Windows::Service::ServiceBase
|
8
|
+
|
9
|
+
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
|
10
|
+
custom_field_query = '<?xml version="1.0" encoding="utf-8"?>'
|
11
|
+
custom_field_query += '<ClassQuery xmlns="http://www.intuit.com/sb/cdm/v2">'
|
12
|
+
custom_field_query += "<StartPage>#{page}</StartPage><ChunkSize>#{per_page}</ChunkSize>"
|
13
|
+
custom_field_query += '</ClassQuery>'
|
14
|
+
fetch_collection(Quickeebooks::Windows::Model::Clazz, custom_field_query.strip, filters, page, per_page, sort, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
+
require "fakeweb"
|
3
|
+
require "oauth"
|
4
|
+
require "quickeebooks"
|
5
|
+
|
6
|
+
describe "Quickeebooks::Windows::Service::Clazz" do
|
7
|
+
before(:all) do
|
8
|
+
FakeWeb.allow_net_connect = false
|
9
|
+
qb_key = "key"
|
10
|
+
qb_secret = "secreet"
|
11
|
+
|
12
|
+
@realm_id = "9991111222"
|
13
|
+
@base_uri = "https://qbo.intuit.com/qbo36"
|
14
|
+
@oauth_consumer = OAuth::Consumer.new(qb_key, qb_key, {
|
15
|
+
:site => "https://oauth.intuit.com",
|
16
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
17
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
18
|
+
:access_token_path => "/oauth/v1/get_access_token"
|
19
|
+
})
|
20
|
+
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can fetch a list of classes" do
|
24
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/windows/classes.xml")
|
25
|
+
model = Quickeebooks::Windows::Model::Clazz
|
26
|
+
service = Quickeebooks::Windows::Service::Clazz.new
|
27
|
+
service.access_token = @oauth
|
28
|
+
service.realm_id = @realm_id
|
29
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
30
|
+
classes = service.list
|
31
|
+
classes.entries.count.should == 3
|
32
|
+
entry = classes.entries.first
|
33
|
+
entry.name.should == "Bugay"
|
34
|
+
entry.id.to_i.should == 157
|
35
|
+
entry.active?.should == true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
|
3
|
+
<Classes>
|
4
|
+
<Class>
|
5
|
+
<Id idDomain="QB">157</Id>
|
6
|
+
<SyncToken>1</SyncToken>
|
7
|
+
<MetaData>
|
8
|
+
<CreateTime>2012-10-19T21:57:46Z</CreateTime>
|
9
|
+
<LastUpdatedTime>2012-10-19T21:57:46Z</LastUpdatedTime>
|
10
|
+
</MetaData>
|
11
|
+
<ExternalKey idDomain="QB">157</ExternalKey>
|
12
|
+
<Synchronized>true</Synchronized>
|
13
|
+
<Name>Bugay</Name>
|
14
|
+
<Active>true</Active>
|
15
|
+
</Class>
|
16
|
+
<Class>
|
17
|
+
<Id idDomain="QB">356</Id>
|
18
|
+
<SyncToken>1</SyncToken>
|
19
|
+
<MetaData>
|
20
|
+
<CreateTime>2012-10-17T22:07:11Z</CreateTime>
|
21
|
+
<LastUpdatedTime>2012-10-17T22:07:11Z</LastUpdatedTime>
|
22
|
+
</MetaData>
|
23
|
+
<ExternalKey idDomain="QB">356</ExternalKey>
|
24
|
+
<Synchronized>true</Synchronized>
|
25
|
+
<Name>Nudo Petit</Name>
|
26
|
+
<Active>true</Active>
|
27
|
+
</Class>
|
28
|
+
<Class>
|
29
|
+
<Id idDomain="QB">955</Id>
|
30
|
+
<SyncToken>1</SyncToken>
|
31
|
+
<MetaData>
|
32
|
+
<CreateTime>2012-10-17T21:51:30Z</CreateTime>
|
33
|
+
<LastUpdatedTime>2012-10-17T21:51:30Z</LastUpdatedTime>
|
34
|
+
</MetaData>
|
35
|
+
<ExternalKey idDomain="QB">955</ExternalKey>
|
36
|
+
<Synchronized>true</Synchronized>
|
37
|
+
<Name>Radog</Name>
|
38
|
+
<Active>true</Active>
|
39
|
+
</Class>
|
40
|
+
</Classes>
|
41
|
+
</RestResponse>
|
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.0.
|
4
|
+
version: 0.0.8
|
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: 2012-10-
|
12
|
+
date: 2012-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: roxml
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- lib/quickeebooks/windows/model/account_detail_type.rb
|
226
226
|
- lib/quickeebooks/windows/model/account_reference.rb
|
227
227
|
- lib/quickeebooks/windows/model/address.rb
|
228
|
+
- lib/quickeebooks/windows/model/clazz.rb
|
228
229
|
- lib/quickeebooks/windows/model/company_meta_data.rb
|
229
230
|
- lib/quickeebooks/windows/model/credit_card.rb
|
230
231
|
- lib/quickeebooks/windows/model/credit_charge_info.rb
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- lib/quickeebooks/windows/model/vendor_reference.rb
|
268
269
|
- lib/quickeebooks/windows/model/web_site.rb
|
269
270
|
- lib/quickeebooks/windows/service/account.rb
|
271
|
+
- lib/quickeebooks/windows/service/clazz.rb
|
270
272
|
- lib/quickeebooks/windows/service/company_meta_data.rb
|
271
273
|
- lib/quickeebooks/windows/service/customer.rb
|
272
274
|
- lib/quickeebooks/windows/service/customer_msg.rb
|
@@ -297,6 +299,7 @@ files:
|
|
297
299
|
- spec/quickeebooks/online/services/service_base_spec.rb
|
298
300
|
- spec/quickeebooks/online/services/sort_spec.rb
|
299
301
|
- spec/quickeebooks/windows/customer_spec.rb
|
302
|
+
- spec/quickeebooks/windows/services/class_spec.rb
|
300
303
|
- spec/quickeebooks/windows/services/company_meta_data_spec.rb
|
301
304
|
- spec/quickeebooks/windows/services/customer_spec.rb
|
302
305
|
- spec/quickeebooks/windows/services/invoice_spec.rb
|
@@ -318,6 +321,7 @@ files:
|
|
318
321
|
- spec/xml/online/invoice.xml
|
319
322
|
- spec/xml/online/payment.xml
|
320
323
|
- spec/xml/online/user.xml
|
324
|
+
- spec/xml/windows/classes.xml
|
321
325
|
- spec/xml/windows/company_meta_data.xml
|
322
326
|
- spec/xml/windows/customer.xml
|
323
327
|
- spec/xml/windows/customer_create_success.xml
|