quickeebooks 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +18 -18
- data/README.md +9 -2
- data/Rakefile +1 -1
- data/lib/quickeebooks.rb +37 -1
- data/lib/quickeebooks/online/model/account.rb +12 -1
- data/lib/quickeebooks/online/model/company_meta_data.rb +30 -0
- data/lib/quickeebooks/online/model/credit_card.rb +14 -0
- data/lib/quickeebooks/online/model/credit_charge_info.rb +17 -0
- data/lib/quickeebooks/online/model/credit_charge_response.rb +13 -0
- data/lib/quickeebooks/online/model/customer.rb +13 -4
- data/lib/quickeebooks/online/model/id.rb +21 -0
- data/lib/quickeebooks/online/model/intuit_type.rb +17 -0
- data/lib/quickeebooks/online/model/invoice.rb +25 -2
- data/lib/quickeebooks/online/model/invoice_header.rb +4 -2
- data/lib/quickeebooks/online/model/invoice_line_item.rb +7 -6
- data/lib/quickeebooks/online/model/item.rb +8 -2
- data/lib/quickeebooks/online/model/payment.rb +58 -0
- data/lib/quickeebooks/online/model/payment_detail.rb +12 -0
- data/lib/quickeebooks/online/model/payment_header.rb +24 -0
- data/lib/quickeebooks/online/model/payment_line_item.rb +15 -0
- data/lib/quickeebooks/online/service/account.rb +5 -5
- data/lib/quickeebooks/online/service/company_meta_data.rb +24 -0
- data/lib/quickeebooks/online/service/customer.rb +5 -5
- data/lib/quickeebooks/online/service/invoice.rb +39 -10
- data/lib/quickeebooks/online/service/item.rb +5 -5
- data/lib/quickeebooks/online/service/payment.rb +63 -0
- data/lib/quickeebooks/online/service/service_base.rb +62 -31
- data/lib/quickeebooks/version.rb +1 -1
- data/lib/quickeebooks/windows/model/account.rb +7 -0
- data/lib/quickeebooks/windows/model/address.rb +8 -0
- data/lib/quickeebooks/windows/model/custom_field.rb +1 -1
- data/lib/quickeebooks/windows/model/customer.rb +12 -1
- data/lib/quickeebooks/windows/model/customer_msg.rb +31 -0
- data/lib/quickeebooks/windows/model/error.rb +19 -0
- data/lib/quickeebooks/windows/model/external_key.rb +21 -0
- data/lib/quickeebooks/windows/model/id.rb +21 -0
- data/lib/quickeebooks/windows/model/invoice.rb +10 -2
- data/lib/quickeebooks/windows/model/invoice_header.rb +13 -15
- data/lib/quickeebooks/windows/model/invoice_line_item.rb +7 -7
- data/lib/quickeebooks/windows/model/item.rb +6 -3
- data/lib/quickeebooks/windows/model/object_ref.rb +14 -0
- data/lib/quickeebooks/windows/model/other_name.rb +16 -0
- data/lib/quickeebooks/windows/model/other_name_id.rb +21 -0
- data/lib/quickeebooks/windows/model/rest_response.rb +34 -0
- data/lib/quickeebooks/windows/model/sales_rep.rb +40 -0
- data/lib/quickeebooks/windows/model/sales_tax.rb +33 -0
- data/lib/quickeebooks/windows/model/ship_method.rb +31 -0
- data/lib/quickeebooks/windows/model/success.rb +17 -0
- data/lib/quickeebooks/windows/model/vendor.rb +16 -0
- data/lib/quickeebooks/windows/model/vendor_id.rb +21 -0
- data/lib/quickeebooks/windows/service/customer.rb +1 -1
- data/lib/quickeebooks/windows/service/customer_msg.rb +15 -0
- data/lib/quickeebooks/windows/service/invoice.rb +19 -1
- data/lib/quickeebooks/windows/service/item.rb +1 -1
- data/lib/quickeebooks/windows/service/sales_rep.rb +16 -0
- data/lib/quickeebooks/windows/service/sales_tax.rb +15 -0
- data/lib/quickeebooks/windows/service/service_base.rb +47 -8
- data/lib/quickeebooks/windows/service/ship_method.rb +15 -0
- data/quickeebooks.gemspec +2 -1
- data/spec/quickeebooks/online/company_meta_data_spec.rb +30 -0
- data/spec/quickeebooks/online/invoice_spec.rb +2 -2
- data/spec/quickeebooks/online/payment_spec.rb +23 -0
- data/spec/quickeebooks/online/services/account_spec.rb +28 -20
- data/spec/quickeebooks/online/services/company_meta_data_spec.rb +40 -0
- data/spec/quickeebooks/online/services/customer_spec.rb +32 -28
- data/spec/quickeebooks/online/services/invoice_spec.rb +52 -0
- data/spec/quickeebooks/online/services/service_base_spec.rb +17 -7
- data/spec/quickeebooks/windows/services/customer_spec.rb +49 -0
- data/spec/quickeebooks/windows/services/invoice_spec.rb +133 -0
- data/spec/quickeebooks/windows/services/sales_rep_spec.rb +47 -0
- data/spec/quickeebooks/windows/services/sales_taxes_spec.rb +41 -0
- data/spec/quickeebooks/windows/services/ship_method_spec.rb +38 -0
- data/spec/quickeebooks_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/xml/online/api_error.xml +6 -0
- data/spec/xml/online/company_meta_data.xml +37 -0
- data/spec/xml/online/determine_base_url.xml +10 -0
- data/spec/xml/online/invoice.xml +26 -31
- data/spec/xml/online/payment.xml +24 -0
- data/spec/xml/windows/invoice_success_create.xml +11 -0
- data/spec/xml/windows/invoices.xml +436 -0
- data/spec/xml/windows/sales_reps.xml +204 -0
- data/spec/xml/windows/sales_taxes.xml +34 -0
- data/spec/xml/windows/ship_methods.xml +139 -0
- metadata +80 -22
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'quickeebooks/windows/service/service_base'
|
2
|
+
|
3
|
+
module Quickeebooks
|
4
|
+
module Windows
|
5
|
+
module Service
|
6
|
+
class ShipMethod < Quickeebooks::Windows::Service::ServiceBase
|
7
|
+
|
8
|
+
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
|
9
|
+
fetch_collection(Quickeebooks::Windows::Model::ShipMethod, nil, filters, page, per_page, sort, options)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/quickeebooks.gemspec
CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'oauth'
|
19
19
|
gem.add_dependency 'nokogiri'
|
20
20
|
gem.add_dependency 'activemodel'
|
21
|
+
gem.add_dependency 'uuidtools'
|
21
22
|
|
22
23
|
gem.add_development_dependency 'rake'
|
23
24
|
gem.add_development_dependency 'rcov', '~> 0.9.8'
|
24
25
|
gem.add_development_dependency 'rr', '~> 1.0.2'
|
25
|
-
gem.add_development_dependency 'rspec', '
|
26
|
+
gem.add_development_dependency 'rspec', '2.11.0'
|
26
27
|
gem.add_development_dependency 'fakeweb'
|
27
28
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "quickeebooks/online/model/company_meta_data"
|
3
|
+
|
4
|
+
describe "Quickeebooks::Online::Model::CompanyMetaData" do
|
5
|
+
|
6
|
+
it "parse company meta data from XML" do
|
7
|
+
xml = File.read(File.dirname(__FILE__) + "/../../xml/online/company_meta_data.xml")
|
8
|
+
company_meta_data = Quickeebooks::Online::Model::CompanyMetaData.from_xml(xml)
|
9
|
+
|
10
|
+
company_meta_data.external_realm_id.should be_nil
|
11
|
+
|
12
|
+
company_meta_data.registered_company_name.should == "Bay Area landscape services"
|
13
|
+
|
14
|
+
company_meta_data.industry_type.should == "Landscaping Services"
|
15
|
+
|
16
|
+
company_meta_data.addresses.count.should == 2
|
17
|
+
|
18
|
+
company_meta_data.addresses.first.line1.should == "2600 Service Street"
|
19
|
+
|
20
|
+
company_meta_data.legal_address.line1.should == "2602 Service Street"
|
21
|
+
|
22
|
+
company_meta_data.phone.free_form_number.should == "(669)111-2222"
|
23
|
+
|
24
|
+
company_meta_data.emails.size.should == 2
|
25
|
+
company_meta_data.emails.first.address.should == "john@bayarealandscapeservices.com"
|
26
|
+
|
27
|
+
# Tag not supported yet in Quickeebooks::Online::Model::Email
|
28
|
+
# company_meta_data.emails.first.tag.should == "COMPANY_EMAIL"
|
29
|
+
end
|
30
|
+
end
|
@@ -7,9 +7,9 @@ describe "Quickeebooks::Online::Model::Invoice" do
|
|
7
7
|
describe "parse invoice from XML" do
|
8
8
|
xml = File.read(File.dirname(__FILE__) + "/../../xml/online/invoice.xml")
|
9
9
|
invoice = Quickeebooks::Online::Model::Invoice.from_xml(xml)
|
10
|
-
invoice.id.should ==
|
10
|
+
invoice.id.value.should == "13"
|
11
11
|
invoice.line_items.count.should == 1
|
12
|
-
invoice.line_items.first.unit_price.should ==
|
12
|
+
invoice.line_items.first.unit_price.should == 225
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "quickeebooks/online/model/payment"
|
4
|
+
|
5
|
+
describe "Quickeebooks::Online::Model::Payment" do
|
6
|
+
|
7
|
+
describe "parse invoice from XML" do
|
8
|
+
xml = File.read(File.dirname(__FILE__) + "/../../xml/online/payment.xml")
|
9
|
+
invoice = Quickeebooks::Online::Model::Payment.from_xml(xml)
|
10
|
+
invoice.id.value.should == "47"
|
11
|
+
invoice.header.doc_number.should == "54"
|
12
|
+
invoice.header.customer_id.value.should == "5"
|
13
|
+
invoice.header.note.should == "Payment against Invoice"
|
14
|
+
invoice.header.total_amount.should == 20.0
|
15
|
+
|
16
|
+
invoice.line_items.count.should == 1
|
17
|
+
invoice.line_items.first.amount.should == 20.0
|
18
|
+
invoice.line_items.first.txn_id.value.should == "8"
|
19
|
+
|
20
|
+
invoice.line_items.first.amount.should == invoice.header.total_amount
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
2
|
require "fakeweb"
|
3
3
|
require "oauth"
|
4
4
|
require "quickeebooks/online/service/account"
|
@@ -18,20 +18,30 @@ describe "Quickeebooks::Online::Service::Account" do
|
|
18
18
|
:access_token_path => "/oauth/v1/get_access_token"
|
19
19
|
})
|
20
20
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
|
+
|
22
|
+
@service = Quickeebooks::Online::Service::Account.new
|
23
|
+
@service.access_token = @oauth
|
24
|
+
@service.instance_eval {
|
25
|
+
@realm_id = "9991111222"
|
26
|
+
}
|
27
|
+
@service.base_uri = @base_uri
|
28
|
+
determine_base_url = @service.qb_base_uri_with_realm_id
|
29
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/determine_base_url.xml")
|
30
|
+
FakeWeb.register_uri(:get, determine_base_url, :status => ["200", "OK"], :body => xml)
|
21
31
|
end
|
22
32
|
|
23
33
|
it "receives 404 from invalid base URL" do
|
24
34
|
uri = "https://qbo.intuit.com/invalid"
|
25
|
-
|
26
|
-
FakeWeb.register_uri(:post,
|
27
|
-
lambda { service.list }.should raise_error(IntuitRequestException)
|
35
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Account.resource_for_collection)
|
36
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => "blah")
|
37
|
+
lambda { @service.list }.should raise_error(IntuitRequestException)
|
28
38
|
end
|
29
39
|
|
30
40
|
it "can fetch a list of accounts" do
|
31
41
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/accounts.xml")
|
32
|
-
|
33
|
-
FakeWeb.register_uri(:post,
|
34
|
-
accounts = service.list
|
42
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Account.resource_for_collection)
|
43
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
44
|
+
accounts = @service.list
|
35
45
|
accounts.current_page.should == 1
|
36
46
|
accounts.entries.count.should == 10
|
37
47
|
accounts.entries.first.current_balance.should == 6200
|
@@ -39,45 +49,43 @@ describe "Quickeebooks::Online::Service::Account" do
|
|
39
49
|
|
40
50
|
it "can create an account" do
|
41
51
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/account.xml")
|
42
|
-
|
43
|
-
FakeWeb.register_uri(:post,
|
52
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)
|
53
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
44
54
|
account = Quickeebooks::Online::Model::Account.new
|
45
55
|
account.name = "Billy Bob"
|
46
56
|
account.sub_type = "AccountsPayable"
|
47
57
|
account.valid?.should == true
|
48
|
-
result = service.create(account)
|
58
|
+
result = @service.create(account)
|
49
59
|
result.id.to_i.should > 0
|
50
60
|
end
|
51
61
|
|
52
62
|
it "can delete an account" do
|
53
|
-
|
54
|
-
url = "#{
|
63
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)
|
64
|
+
url = "#{url}/99"
|
55
65
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"])
|
56
66
|
account = Quickeebooks::Online::Model::Account.new
|
57
67
|
account.id = 99
|
58
68
|
account.sync_token = 0
|
59
|
-
result = service.delete(account)
|
69
|
+
result = @service.delete(account)
|
60
70
|
result.should == true
|
61
71
|
end
|
62
72
|
|
63
73
|
it "cannot delete an account with missing required fields for deletion" do
|
64
|
-
service = Quickeebooks::Online::Service::Account.new(@oauth, @realm_id, @base_uri)
|
65
74
|
account = Quickeebooks::Online::Model::Account.new
|
66
|
-
lambda { service.delete(account) }.should raise_error(InvalidModelException, "Missing required parameters for delete")
|
75
|
+
lambda { @service.delete(account) }.should raise_error(InvalidModelException, "Missing required parameters for delete")
|
67
76
|
end
|
68
77
|
|
69
78
|
it "exception is raised when we try to create an invalid account" do
|
70
79
|
account = Quickeebooks::Online::Model::Account.new
|
71
|
-
|
72
|
-
lambda { service.create(account) }.should raise_error(InvalidModelException)
|
80
|
+
lambda { @service.create(account) }.should raise_error(InvalidModelException)
|
73
81
|
end
|
74
82
|
|
75
83
|
it "can fetch an account by id" do
|
76
84
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/account.xml")
|
77
|
-
|
78
|
-
url = "#{
|
85
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)
|
86
|
+
url = "#{url}/99"
|
79
87
|
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
80
|
-
account = service.fetch_by_id(99)
|
88
|
+
account = @service.fetch_by_id(99)
|
81
89
|
account.name.should == "Billy Bob"
|
82
90
|
end
|
83
91
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakeweb"
|
3
|
+
require "oauth"
|
4
|
+
require "quickeebooks"
|
5
|
+
|
6
|
+
describe "Quickeebooks::Online::Service::CompanyMetaData" 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
|
+
|
22
|
+
@service = Quickeebooks::Online::Service::CompanyMetaData.new
|
23
|
+
@service.access_token = @oauth
|
24
|
+
@service.instance_eval {
|
25
|
+
@realm_id = "9991111222"
|
26
|
+
}
|
27
|
+
@service.base_uri = @base_uri
|
28
|
+
determine_base_url = @service.qb_base_uri_with_realm_id
|
29
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/determine_base_url.xml")
|
30
|
+
FakeWeb.register_uri(:get, determine_base_url, :status => ["200", "OK"], :body => xml)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can get the realm's company_meta_data record" do
|
34
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/company_meta_data.xml")
|
35
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::CompanyMetaData.resource_for_singular)
|
36
|
+
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
37
|
+
company_meta_data_response = @service.load
|
38
|
+
company_meta_data_response.registered_company_name.should == "Bay Area landscape services"
|
39
|
+
end
|
40
|
+
end
|
@@ -18,13 +18,23 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
18
18
|
:access_token_path => "/oauth/v1/get_access_token"
|
19
19
|
})
|
20
20
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
|
+
|
22
|
+
@service = Quickeebooks::Online::Service::Customer.new
|
23
|
+
@service.access_token = @oauth
|
24
|
+
@service.instance_eval {
|
25
|
+
@realm_id = "9991111222"
|
26
|
+
}
|
27
|
+
@service.base_uri = @base_uri
|
28
|
+
determine_base_url = @service.qb_base_uri_with_realm_id
|
29
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/determine_base_url.xml")
|
30
|
+
FakeWeb.register_uri(:get, determine_base_url, :status => ["200", "OK"], :body => xml)
|
21
31
|
end
|
22
32
|
|
23
33
|
it "can fetch a list of customers" do
|
24
34
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/customers.xml")
|
25
|
-
|
26
|
-
FakeWeb.register_uri(:post,
|
27
|
-
accounts = service.list
|
35
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_collection)
|
36
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
37
|
+
accounts = @service.list
|
28
38
|
accounts.current_page.should == 1
|
29
39
|
accounts.entries.count.should == 3
|
30
40
|
accounts.entries.first.name.should == "John Doe"
|
@@ -32,9 +42,9 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
32
42
|
|
33
43
|
it "can fetch a list of customers with filters" do
|
34
44
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/customers.xml")
|
35
|
-
|
36
|
-
FakeWeb.register_uri(:post,
|
37
|
-
accounts = service.list
|
45
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_collection)
|
46
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
47
|
+
accounts = @service.list
|
38
48
|
accounts.current_page.should == 1
|
39
49
|
accounts.entries.count.should == 3
|
40
50
|
accounts.entries.first.name.should == "John Doe"
|
@@ -42,50 +52,45 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
42
52
|
|
43
53
|
it "can create a customer" do
|
44
54
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/customer.xml")
|
45
|
-
|
46
|
-
FakeWeb.register_uri(:post,
|
55
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)
|
56
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
47
57
|
customer = Quickeebooks::Online::Model::Customer.new
|
48
58
|
customer.name = "Billy Bob"
|
49
|
-
result = service.create(customer)
|
50
|
-
result.id.to_i.should > 0
|
59
|
+
result = @service.create(customer)
|
60
|
+
result.id.value.to_i.should > 0
|
51
61
|
end
|
52
62
|
|
53
63
|
it "can delete a customer" do
|
54
|
-
|
55
|
-
url = "#{service.url_for_resource("customer")}/99?methodx=delete"
|
64
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/99"
|
56
65
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"])
|
57
66
|
customer = Quickeebooks::Online::Model::Customer.new
|
58
|
-
customer.id = 99
|
67
|
+
customer.id = Quickeebooks::Online::Model::Id.new("99")
|
59
68
|
customer.sync_token = 0
|
60
|
-
result = service.delete(customer)
|
69
|
+
result = @service.delete(customer)
|
61
70
|
result.should == true
|
62
71
|
end
|
63
72
|
|
64
73
|
it "cannot delete a customer with missing required fields for deletion" do
|
65
|
-
service = Quickeebooks::Online::Service::Customer.new(@oauth, @realm_id, @base_uri)
|
66
74
|
customer = Quickeebooks::Online::Model::Customer.new
|
67
|
-
lambda { service.delete(customer) }.should raise_error(InvalidModelException, "Missing required parameters for delete")
|
75
|
+
lambda { @service.delete(customer) }.should raise_error(InvalidModelException, "Missing required parameters for delete")
|
68
76
|
end
|
69
77
|
|
70
78
|
it "exception is raised when we try to create an invalid account" do
|
71
79
|
customer = Quickeebooks::Online::Model::Customer.new
|
72
|
-
|
73
|
-
lambda { service.create(customer) }.should raise_error(InvalidModelException)
|
80
|
+
lambda { @service.create(customer) }.should raise_error(InvalidModelException)
|
74
81
|
end
|
75
82
|
|
76
83
|
it "cannot update an invalid customer" do
|
77
84
|
customer = Quickeebooks::Online::Model::Customer.new
|
78
85
|
customer.name = "John Doe"
|
79
|
-
|
80
|
-
lambda { service.update(customer) }.should raise_error(InvalidModelException)
|
86
|
+
lambda { @service.update(customer) }.should raise_error(InvalidModelException)
|
81
87
|
end
|
82
88
|
|
83
|
-
it "can fetch
|
89
|
+
it "can fetch a customer by id" do
|
84
90
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/customer.xml")
|
85
|
-
|
86
|
-
url = "#{service.url_for_resource("customer")}/99"
|
91
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/99"
|
87
92
|
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
88
|
-
customer = service.fetch_by_id(99)
|
93
|
+
customer = @service.fetch_by_id(99)
|
89
94
|
customer.name.should == "John Doe"
|
90
95
|
end
|
91
96
|
|
@@ -93,13 +98,12 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
93
98
|
xml2 = File.read(File.dirname(__FILE__) + "/../../../xml/online/customer2.xml")
|
94
99
|
customer = Quickeebooks::Online::Model::Customer.new
|
95
100
|
customer.name = "John Doe"
|
96
|
-
customer.id = 1
|
101
|
+
customer.id = Quickeebooks::Online::Model::Id.new("1")
|
97
102
|
customer.sync_token = 2
|
98
103
|
|
99
|
-
|
100
|
-
url = "#{service.url_for_resource("customer")}/#{customer.id}"
|
104
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/#{customer.id.value}"
|
101
105
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml2)
|
102
|
-
updated = service.update(customer)
|
106
|
+
updated = @service.update(customer)
|
103
107
|
updated.name.should == "Billy Bob"
|
104
108
|
end
|
105
109
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakeweb"
|
3
|
+
require "oauth"
|
4
|
+
require "quickeebooks"
|
5
|
+
|
6
|
+
describe "Quickeebooks::Online::Service::Invoice" 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
|
+
@service = Quickeebooks::Online::Service::Invoice.new
|
22
|
+
@service.access_token = @oauth
|
23
|
+
@service.instance_eval {
|
24
|
+
@realm_id = "9991111222"
|
25
|
+
}
|
26
|
+
@service.base_uri = @base_uri
|
27
|
+
determine_base_url = @service.qb_base_uri_with_realm_id
|
28
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/determine_base_url.xml")
|
29
|
+
FakeWeb.register_uri(:get, determine_base_url, :status => ["200", "OK"], :body => xml)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can create an invoice" do
|
33
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/invoice.xml")
|
34
|
+
|
35
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Invoice.resource_for_singular)
|
36
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
37
|
+
invoice = Quickeebooks::Online::Model::Invoice.new
|
38
|
+
invoice.header = Quickeebooks::Online::Model::InvoiceHeader.new
|
39
|
+
invoice.header.doc_number = "123"
|
40
|
+
|
41
|
+
line_item = Quickeebooks::Online::Model::InvoiceLineItem.new
|
42
|
+
line_item.item_id = Quickeebooks::Online::Model::Id.new("123")
|
43
|
+
line_item.desc = "Pinor Noir 2005"
|
44
|
+
line_item.unit_price = 188
|
45
|
+
line_item.quantity = 2
|
46
|
+
invoice.line_items << line_item
|
47
|
+
|
48
|
+
result = @service.create(invoice)
|
49
|
+
result.id.value.to_i.should > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -16,15 +16,25 @@ describe "Quickeebooks::Online::Service::ServiceBase" do
|
|
16
16
|
:authorize_path => "/oauth/v1/get_access_token",
|
17
17
|
:access_token_path => "/oauth/v1/get_access_token"
|
18
18
|
})
|
19
|
-
|
20
|
-
|
21
|
-
it "can determine base url" do
|
19
|
+
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
20
|
+
|
22
21
|
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/user.xml")
|
23
22
|
user_url = Quickeebooks::Online::Service::ServiceBase::QB_BASE_URI + "/" + @realm_id
|
24
23
|
FakeWeb.register_uri(:get, user_url, :status => ["200", "OK"], :body => xml)
|
25
|
-
service = Quickeebooks::Online::Service::ServiceBase.new
|
26
|
-
service.
|
27
|
-
service.
|
24
|
+
@service = Quickeebooks::Online::Service::ServiceBase.new
|
25
|
+
@service.access_token = @oauth
|
26
|
+
@service.instance_eval {
|
27
|
+
@realm_id = "9991111222"
|
28
|
+
}
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
+
it "can determine base url" do
|
32
|
+
@service.determine_base_url
|
33
|
+
@service.base_uri.should_not == nil
|
34
|
+
@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_collection).should == "https://qbo.intuit.com/qbo36/resource/customers/v2/#{@realm_id}"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can determine login_name" do
|
38
|
+
@service.login_name.should == 'foo@example.com'
|
39
|
+
end
|
40
|
+
end
|