quickbooks-ruby-base 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +3 -2
- data/lib/quickbooks/base.rb +4 -0
- data/quickbooks-ruby-base.gemspec +1 -1
- data/spec/fixtures/invoice.xml +69 -0
- data/spec/quickbooks_ruby_base_spec.rb +38 -23
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmEwMDFiYjNjMmVhZDcxMzAwOGU4Y2RjZDc5ZmY3YmExNTMyODI0Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWMwM2IyMTEwZjliZWI4OTUxYmE1NDY3OTJjYjk3MzlkYjk2MjlmNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzg4ZDE3MDNiMTJlYWM2ZTNlMmIyYTA1YjdkOTRlYjNjNDg0NTlhMzM5M2Ex
|
10
|
+
ZjExZmYxZDJlMDEyNjIwZWYxOGRjMDZhYTBhZDcxMmE0OTMyMWI0MjJjZTYz
|
11
|
+
ZjM5NWY0NWE0YzQ4NTdhMTA3MzIyZGE4MGMwNjlmYzkyNjg3ODU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmU5ODk0ZGE5ZTMwZGJiODY4NDQ3MjNmMTY4NTJiOTIwZDNmODlkMTAwZjEz
|
14
|
+
ZWVkMGM5ZDJiMmMyZDRiNjQxMzUwMTlhYTc5MWVlODA2M2MzYzMxYThkZmE3
|
15
|
+
Y2VmYjJlNTAzMzcxNzhiOTljMzFhODk1M2Y3YjY2NmRmYmNjZWM=
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
## Description
|
2
2
|
|
3
|
-
|
3
|
+
The `quickbooks-ruby-base` gem complements the [`quickbooks-ruby`](https://github.com/ruckus/quickbooks-ruby) library by providing a base class to handle routine tasks like creating a model, service, and displaying information.
|
4
|
+
See the [screencast](http://minimul.com/improve-your-quickbooks-ruby-integration-experience-with-the-quickbooks-ruby-base-gem.html) for more details.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
data/lib/quickbooks/base.rb
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'quickbooks-ruby-base'
|
7
|
-
spec.version = '1.0
|
7
|
+
spec.version = '1.1.0'
|
8
8
|
spec.authors = ["Christian"]
|
9
9
|
spec.email = ["christian@minimul.com"]
|
10
10
|
spec.summary = %q{Base class to provide common methods for the quickbooks-ruby gem}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2015-02-10T05:19:42.667-08:00">
|
3
|
+
<Invoice domain="QBO" sparse="false">
|
4
|
+
<Id>156</Id>
|
5
|
+
<SyncToken>0</SyncToken>
|
6
|
+
<MetaData>
|
7
|
+
<CreateTime>2015-02-10T05:07:43-08:00</CreateTime>
|
8
|
+
<LastUpdatedTime>2015-02-10T05:07:43-08:00</LastUpdatedTime>
|
9
|
+
</MetaData>
|
10
|
+
<CustomField>
|
11
|
+
<DefinitionId>1</DefinitionId>
|
12
|
+
<Name>Crew #</Name>
|
13
|
+
<Type>StringType</Type>
|
14
|
+
</CustomField>
|
15
|
+
<DocNumber>1049</DocNumber>
|
16
|
+
<TxnDate>2015-02-10</TxnDate>
|
17
|
+
<Line>
|
18
|
+
<Id>1</Id>
|
19
|
+
<LineNum>1</LineNum>
|
20
|
+
<Description>Plush Baby Doll</Description>
|
21
|
+
<Amount>50.00</Amount>
|
22
|
+
<DetailType>SalesItemLineDetail</DetailType>
|
23
|
+
<SalesItemLineDetail>
|
24
|
+
<ItemRef name="Services">1</ItemRef>
|
25
|
+
<UnitPrice>50</UnitPrice>
|
26
|
+
<Qty>1</Qty>
|
27
|
+
<TaxCodeRef>NON</TaxCodeRef>
|
28
|
+
</SalesItemLineDetail>
|
29
|
+
</Line>
|
30
|
+
<Line>
|
31
|
+
<Amount>50.00</Amount>
|
32
|
+
<DetailType>SubTotalLineDetail</DetailType>
|
33
|
+
<SubTotalLineDetail/>
|
34
|
+
</Line>
|
35
|
+
<TxnTaxDetail>
|
36
|
+
<TotalTax>0</TotalTax>
|
37
|
+
</TxnTaxDetail>
|
38
|
+
<CustomerRef name="Bill's Windsurf Shop">2</CustomerRef>
|
39
|
+
<BillAddr>
|
40
|
+
<Id>3</Id>
|
41
|
+
<Line1>12 Ocean Dr.</Line1>
|
42
|
+
<City>Half Moon Bay</City>
|
43
|
+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
|
44
|
+
<PostalCode>94213</PostalCode>
|
45
|
+
<Lat>37.4307072</Lat>
|
46
|
+
<Long>-122.4295234</Long>
|
47
|
+
</BillAddr>
|
48
|
+
<ShipAddr>
|
49
|
+
<Id>3</Id>
|
50
|
+
<Line1>12 Ocean Dr.</Line1>
|
51
|
+
<City>Half Moon Bay</City>
|
52
|
+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
|
53
|
+
<PostalCode>94213</PostalCode>
|
54
|
+
<Lat>37.4307072</Lat>
|
55
|
+
<Long>-122.4295234</Long>
|
56
|
+
</ShipAddr>
|
57
|
+
<DueDate>2015-03-12</DueDate>
|
58
|
+
<TotalAmt>50.00</TotalAmt>
|
59
|
+
<ApplyTaxAfterDiscount>false</ApplyTaxAfterDiscount>
|
60
|
+
<PrintStatus>NeedToPrint</PrintStatus>
|
61
|
+
<EmailStatus>NotSet</EmailStatus>
|
62
|
+
<Balance>50.00</Balance>
|
63
|
+
<Deposit>0</Deposit>
|
64
|
+
<AllowIPNPayment>false</AllowIPNPayment>
|
65
|
+
<AllowOnlinePayment>false</AllowOnlinePayment>
|
66
|
+
<AllowOnlineCreditCardPayment>false</AllowOnlineCreditCardPayment>
|
67
|
+
<AllowOnlineACHPayment>false</AllowOnlineACHPayment>
|
68
|
+
</Invoice>
|
69
|
+
</IntuitResponse>
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Quickbooks::Base do
|
4
4
|
let(:account) { double }
|
5
|
+
let(:full_account) { account = double(settings: double( qb_token: 'tttttttttt', qb_secret: 'ssssssss', qb_company_id: '1234567')) }
|
5
6
|
let(:qr_base) { Quickbooks::Base.new(account) }
|
6
7
|
|
7
8
|
describe ".quickbooks_ruby_namespace" do
|
@@ -27,46 +28,41 @@ describe Quickbooks::Base do
|
|
27
28
|
end
|
28
29
|
|
29
30
|
describe ".show" do
|
30
|
-
let(:account) { account = double(settings: double( qb_token: 'tttttttttt', qb_secret: 'ssssssss', qb_company_id: '1234567')) }
|
31
31
|
|
32
32
|
it "description should display using the dispay_name for vendor" do
|
33
|
-
xml =
|
34
|
-
|
35
|
-
|
36
|
-
qr = Quickbooks::Base.new(account, :vendor)
|
33
|
+
xml = read_fixture('vendors')
|
34
|
+
stub_response(xml)
|
35
|
+
qr = Quickbooks::Base.new(full_account, :vendor)
|
37
36
|
expect(qr.show.first).to match /Catherines Cupcakes/
|
38
37
|
end
|
39
38
|
|
40
39
|
it "description should display using the name for tax_code" do
|
41
|
-
xml =
|
42
|
-
|
43
|
-
|
44
|
-
qr = Quickbooks::Base.new(account, :tax_code)
|
40
|
+
xml = read_fixture('tax_codes')
|
41
|
+
stub_response(xml)
|
42
|
+
qr = Quickbooks::Base.new(full_account, :tax_code)
|
45
43
|
expect(qr.show.last).to match /New York City/
|
46
44
|
end
|
47
45
|
|
48
46
|
it "description should display using the doc_number for invoice" do
|
49
|
-
xml =
|
50
|
-
|
51
|
-
|
52
|
-
qr = Quickbooks::Base.new(account, :invoice)
|
47
|
+
xml = read_fixture('invoices')
|
48
|
+
stub_response(xml)
|
49
|
+
qr = Quickbooks::Base.new(full_account, :invoice)
|
53
50
|
expect(qr.show.last).to match /1234/
|
54
51
|
end
|
55
52
|
|
56
53
|
it "description should display using the total for payment" do
|
57
|
-
xml =
|
58
|
-
|
59
|
-
|
60
|
-
qr = Quickbooks::Base.new(account, :payment)
|
54
|
+
xml = read_fixture('payments')
|
55
|
+
stub_response(xml)
|
56
|
+
qr = Quickbooks::Base.new(full_account, :payment)
|
61
57
|
expect(qr.show.last).to match /100\.0/
|
62
58
|
end
|
63
59
|
|
64
60
|
it "description should display 'nil' as no description fits" do
|
65
|
-
|
61
|
+
pending 'Need to find a transaction or name entity that does not match txn_date'
|
62
|
+
xml = read_fixture('dummy')
|
66
63
|
xml.gsub!('Dummy', 'SalesReceipt')
|
67
|
-
|
68
|
-
|
69
|
-
qr = Quickbooks::Base.new(account, :sales_receipt)
|
64
|
+
stub_response(xml)
|
65
|
+
qr = Quickbooks::Base.new(full_account, :sales_receipt)
|
70
66
|
expect(qr.show.last).to match /nil/
|
71
67
|
end
|
72
68
|
|
@@ -106,10 +102,29 @@ describe Quickbooks::Base do
|
|
106
102
|
|
107
103
|
describe ".create_service_for" do
|
108
104
|
it "creates a access_token service" do
|
109
|
-
|
110
|
-
qb = Quickbooks::Base.new(account)
|
105
|
+
qb = Quickbooks::Base.new(full_account)
|
111
106
|
service = qb.create_service_for :access_token
|
112
107
|
expect(service.class.name).to match /Service::AccessToken/
|
113
108
|
end
|
114
109
|
end
|
110
|
+
|
111
|
+
describe ".get" do
|
112
|
+
|
113
|
+
it 'grabs a object by id' do
|
114
|
+
xml = read_fixture('invoice')
|
115
|
+
stub_response(xml)
|
116
|
+
qr = Quickbooks::Base.new(full_account, :invoice)
|
117
|
+
result = qr.id(28)
|
118
|
+
expect(result.id).to eq 156
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def read_fixture(filename)
|
123
|
+
File.read(File.join('spec', 'fixtures', "#{filename}.xml"))
|
124
|
+
end
|
125
|
+
|
126
|
+
def stub_response(xml)
|
127
|
+
response = Struct.new(:plain_body, :code).new(xml, 200)
|
128
|
+
allow_any_instance_of(OAuth::AccessToken).to receive(:get).and_return(response)
|
129
|
+
end
|
115
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbooks-ruby-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: quickbooks-ruby
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/quickbooks/base/configuration.rb
|
84
84
|
- quickbooks-ruby-base.gemspec
|
85
85
|
- spec/fixtures/dummy.xml
|
86
|
+
- spec/fixtures/invoice.xml
|
86
87
|
- spec/fixtures/invoices.xml
|
87
88
|
- spec/fixtures/payments.xml
|
88
89
|
- spec/fixtures/tax_codes.xml
|
@@ -115,6 +116,7 @@ specification_version: 4
|
|
115
116
|
summary: Base class to provide common methods for the quickbooks-ruby gem
|
116
117
|
test_files:
|
117
118
|
- spec/fixtures/dummy.xml
|
119
|
+
- spec/fixtures/invoice.xml
|
118
120
|
- spec/fixtures/invoices.xml
|
119
121
|
- spec/fixtures/payments.xml
|
120
122
|
- spec/fixtures/tax_codes.xml
|