quickeebooks 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -0
- data/lib/quickeebooks.rb +16 -1
- data/lib/quickeebooks/online/model/invoice.rb +1 -2
- data/lib/quickeebooks/online/model/invoice_header.rb +2 -1
- data/lib/quickeebooks/online/service/filter.rb +4 -90
- data/lib/quickeebooks/online/service/service_base.rb +5 -3
- data/lib/quickeebooks/shared/service/filter.rb +96 -0
- data/lib/quickeebooks/version.rb +1 -1
- data/lib/quickeebooks/windows/model/company_meta_data.rb +29 -0
- data/lib/quickeebooks/windows/model/credit_card.rb +14 -0
- data/lib/quickeebooks/windows/model/credit_charge_info.rb +17 -0
- data/lib/quickeebooks/windows/model/credit_charge_response.rb +13 -0
- data/lib/quickeebooks/windows/model/customer.rb +37 -7
- data/lib/quickeebooks/windows/model/party_role_ref.rb +12 -0
- data/lib/quickeebooks/windows/model/payment.rb +41 -0
- data/lib/quickeebooks/windows/model/payment_detail.rb +12 -0
- data/lib/quickeebooks/windows/model/payment_header.rb +24 -0
- data/lib/quickeebooks/windows/model/payment_line_item.rb +15 -0
- data/lib/quickeebooks/windows/model/rest_response.rb +2 -1
- data/lib/quickeebooks/windows/model/success.rb +3 -0
- data/lib/quickeebooks/windows/service/company_meta_data.rb +14 -0
- data/lib/quickeebooks/windows/service/customer.rb +17 -0
- data/lib/quickeebooks/windows/service/filter.rb +10 -0
- data/lib/quickeebooks/windows/service/payment.rb +26 -0
- data/spec/quickeebooks/online/invoice_spec.rb +2 -1
- data/spec/quickeebooks/online/services/service_base_spec.rb +14 -0
- data/spec/quickeebooks/windows/services/company_meta_data_spec.rb +34 -0
- data/spec/quickeebooks/windows/services/customer_spec.rb +98 -0
- data/spec/quickeebooks/windows/services/payment_spec.rb +48 -0
- data/spec/xml/online/invalid_user.xml +7 -0
- data/spec/xml/windows/company_meta_data.xml +30 -0
- data/spec/xml/windows/customer_create_success.xml +13 -0
- data/spec/xml/windows/payments.xml +39 -0
- data/tmp/create_customer_windows.rb +41 -0
- data/tmp/online.rb +23 -0
- metadata +23 -2
data/README.md
CHANGED
@@ -300,6 +300,13 @@ _Note:_ it is up to you the caller to remove or clean up the file when you are d
|
|
300
300
|
|
301
301
|
Cody Caughlan
|
302
302
|
|
303
|
+
## Credits
|
304
|
+
|
305
|
+
Thank you for the contributions:
|
306
|
+
|
307
|
+
* [Walter McGinnis](https://github.com/walter)
|
308
|
+
* [Simon Wistow](https://github.com/simonwistow)
|
309
|
+
|
303
310
|
## License
|
304
311
|
|
305
312
|
The MIT License
|
data/lib/quickeebooks.rb
CHANGED
@@ -51,6 +51,11 @@ module ROXML
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
#== Shared
|
55
|
+
|
56
|
+
# Services
|
57
|
+
require 'quickeebooks/shared/service/filter'
|
58
|
+
|
54
59
|
#== Online
|
55
60
|
|
56
61
|
# Models
|
@@ -111,9 +116,17 @@ require 'quickeebooks/windows/model/external_key'
|
|
111
116
|
require 'quickeebooks/windows/model/ship_method'
|
112
117
|
require 'quickeebooks/windows/model/sales_tax'
|
113
118
|
require 'quickeebooks/windows/model/customer_msg'
|
114
|
-
|
119
|
+
require 'quickeebooks/windows/model/company_meta_data'
|
120
|
+
require 'quickeebooks/windows/model/payment'
|
121
|
+
require 'quickeebooks/windows/model/payment_header'
|
122
|
+
require 'quickeebooks/windows/model/payment_line_item'
|
123
|
+
require 'quickeebooks/windows/model/payment_detail'
|
124
|
+
require 'quickeebooks/windows/model/credit_card'
|
125
|
+
require 'quickeebooks/windows/model/credit_charge_info'
|
126
|
+
require 'quickeebooks/windows/model/credit_charge_response'
|
115
127
|
|
116
128
|
# Services
|
129
|
+
require 'quickeebooks/windows/service/filter'
|
117
130
|
require 'quickeebooks/windows/service/service_base'
|
118
131
|
require 'quickeebooks/windows/service/account'
|
119
132
|
require 'quickeebooks/windows/service/customer'
|
@@ -123,3 +136,5 @@ require 'quickeebooks/windows/service/sales_rep'
|
|
123
136
|
require 'quickeebooks/windows/service/ship_method'
|
124
137
|
require 'quickeebooks/windows/service/sales_tax'
|
125
138
|
require 'quickeebooks/windows/service/customer_msg'
|
139
|
+
require 'quickeebooks/windows/service/company_meta_data'
|
140
|
+
require 'quickeebooks/windows/service/payment'
|
@@ -26,7 +26,6 @@ module Quickeebooks
|
|
26
26
|
xml_accessor :bill_email, :from => 'BillEmail'
|
27
27
|
xml_accessor :ship_method_id, :from => 'ShipMethodId', :as => Quickeebooks::Online::Model::Id
|
28
28
|
xml_accessor :ship_method_name, :from => 'ShipMethodName'
|
29
|
-
xml_accessor :balance, :from => 'Balance', :as => Float
|
30
29
|
xml_accessor :discount_amount, :from => 'DiscountAmt', :as => Float
|
31
30
|
xml_accessor :discount_rate, :from => 'DiscountRate', :as => Float
|
32
31
|
xml_accessor :discount_taxable, :from => 'DiscountTaxable'
|
@@ -70,4 +69,4 @@ module Quickeebooks
|
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
73
|
-
end
|
72
|
+
end
|
@@ -17,6 +17,7 @@ module Quickeebooks
|
|
17
17
|
xml_accessor :sales_tax_code_name, :from => 'SalesTaxCodeName'
|
18
18
|
xml_accessor :sub_total_amount, :from => 'SubTotalAmt', :as => Float
|
19
19
|
xml_accessor :tax_rate, :from => 'TaxRate', :as => Float
|
20
|
+
xml_accessor :balance, :from => 'Balance', :as => Float
|
20
21
|
xml_accessor :total_amount, :from => 'TotalAmt', :as => Float
|
21
22
|
xml_accessor :due_date, :from => 'DueDate', :as => Time
|
22
23
|
xml_accessor :bill_email, :from => 'BillEmail'
|
@@ -28,4 +29,4 @@ module Quickeebooks
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
end
|
32
|
+
end
|
@@ -1,96 +1,10 @@
|
|
1
|
+
require 'quickeebooks/shared/service/filter'
|
2
|
+
|
1
3
|
module Quickeebooks
|
2
4
|
module Online
|
3
5
|
module Service
|
4
|
-
class Filter
|
5
|
-
|
6
|
-
DATE_FORMAT = '%Y-%m-%d'
|
7
|
-
DATE_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S%z'
|
8
|
-
|
9
|
-
attr_reader :type
|
10
|
-
attr_accessor :field, :value
|
11
|
-
|
12
|
-
# For Date/Time filtering
|
13
|
-
attr_accessor :before, :after
|
14
|
-
|
15
|
-
# For number comparisons
|
16
|
-
attr_accessor :gt, :lt, :eq
|
17
|
-
|
18
|
-
def initialize(type, *args)
|
19
|
-
@type = type
|
20
|
-
if args.first.is_a?(Hash)
|
21
|
-
args.first.each_pair do |key, value|
|
22
|
-
instance_variable_set("@#{key}", value)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_s
|
28
|
-
case @type.to_sym
|
29
|
-
when :date, :datetime
|
30
|
-
date_time_to_s
|
31
|
-
when :text
|
32
|
-
text_to_s
|
33
|
-
when :boolean
|
34
|
-
boolean_to_s
|
35
|
-
when :number
|
36
|
-
number_to_s
|
37
|
-
else
|
38
|
-
raise ArgumentError, "Don't know how to generate a Filter for type #{@type}"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def number_to_s
|
45
|
-
clauses = []
|
46
|
-
if @eq
|
47
|
-
clauses << "#{@field} :EQUALS: #{@value}"
|
48
|
-
end
|
49
|
-
if @gt
|
50
|
-
clauses << "#{@field} :GreaterThan: #{@value}"
|
51
|
-
end
|
52
|
-
if @lt
|
53
|
-
clauses << "#{@field} :LessThan: #{@value}"
|
54
|
-
end
|
55
|
-
clauses.join(" :AND: ")
|
56
|
-
end
|
57
|
-
|
58
|
-
def date_time_to_s
|
59
|
-
clauses = []
|
60
|
-
if @before
|
61
|
-
raise ':before is not a valid DateTime/Time object' unless (@before.is_a?(Time) || @before.is_a?(DateTime))
|
62
|
-
clauses << "#{@field} :BEFORE: #{formatted_time(@before)}"
|
63
|
-
end
|
64
|
-
if @after
|
65
|
-
raise ':after is not a valid DateTime/Time object' unless (@after.is_a?(Time) || @after.is_a?(DateTime))
|
66
|
-
clauses << "#{@field} :AFTER: #{formatted_time(@after)}"
|
67
|
-
end
|
68
|
-
|
69
|
-
if @before.nil? && @after.nil?
|
70
|
-
clauses << "#{@field} :EQUALS: #{formatted_time(@value)}"
|
71
|
-
end
|
72
|
-
|
73
|
-
clauses.join(" :AND: ")
|
74
|
-
end
|
75
|
-
|
76
|
-
def text_to_s
|
77
|
-
"#{@field} :EQUALS: #{@value}"
|
78
|
-
end
|
79
|
-
|
80
|
-
def boolean_to_s
|
81
|
-
"#{@field} :EQUALS: #{@value}"
|
82
|
-
end
|
83
|
-
|
84
|
-
def formatted_time(time)
|
85
|
-
if time.is_a?(Date)
|
86
|
-
time.strftime(DATE_FORMAT)
|
87
|
-
elsif time.is_a?(DateTime) || time.is_a?(Time)
|
88
|
-
time.strftime(DATE_TIME_FORMAT)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
|
6
|
+
class Filter < Quickeebooks::Shared::Service::Filter
|
93
7
|
end
|
94
8
|
end
|
95
9
|
end
|
96
|
-
end
|
10
|
+
end
|
@@ -39,9 +39,9 @@ module Quickeebooks
|
|
39
39
|
|
40
40
|
def realm_id=(realm_id)
|
41
41
|
@realm_id = realm_id
|
42
|
-
determine_base_url
|
43
42
|
end
|
44
43
|
|
44
|
+
# uri is of the form `https://qbo.intuit.com/qbo36`
|
45
45
|
def base_url=(uri)
|
46
46
|
@base_uri = uri
|
47
47
|
end
|
@@ -55,19 +55,21 @@ module Quickeebooks
|
|
55
55
|
element = base_doc.xpath("//qbo:QboUser/qbo:CurrentCompany/qbo:BaseURI")[0]
|
56
56
|
if element
|
57
57
|
@base_uri = element.text
|
58
|
+
else
|
59
|
+
raise IntuitRequestException.new("Response error: Could not extract BaseURI from response. Invalid XML: #{service_response.body}")
|
58
60
|
end
|
59
61
|
else
|
60
|
-
raise IntuitRequestException.new("Response error: invalid code #{
|
62
|
+
raise IntuitRequestException.new("Response error: invalid code #{service_response.code}")
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
def url_for_resource(resource)
|
66
68
|
url_for_base("resource/#{resource}")
|
67
|
-
#{}"#{@base_uri}/resource/#{resource}/v2/#{@realm_id}"
|
68
69
|
end
|
69
70
|
|
70
71
|
def url_for_base(raw)
|
72
|
+
determine_base_url unless determined_base_url?
|
71
73
|
"#{@base_uri}/#{raw}/v2/#{@realm_id}"
|
72
74
|
end
|
73
75
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Quickeebooks
|
2
|
+
module Shared
|
3
|
+
module Service
|
4
|
+
class Filter
|
5
|
+
|
6
|
+
DATE_FORMAT = '%Y-%m-%d'
|
7
|
+
DATE_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S%z'
|
8
|
+
|
9
|
+
attr_reader :type
|
10
|
+
attr_accessor :field, :value
|
11
|
+
|
12
|
+
# For Date/Time filtering
|
13
|
+
attr_accessor :before, :after
|
14
|
+
|
15
|
+
# For number comparisons
|
16
|
+
attr_accessor :gt, :lt, :eq
|
17
|
+
|
18
|
+
def initialize(type, *args)
|
19
|
+
@type = type
|
20
|
+
if args.first.is_a?(Hash)
|
21
|
+
args.first.each_pair do |key, value|
|
22
|
+
instance_variable_set("@#{key}", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
case @type.to_sym
|
29
|
+
when :date, :datetime
|
30
|
+
date_time_to_s
|
31
|
+
when :text
|
32
|
+
text_to_s
|
33
|
+
when :boolean
|
34
|
+
boolean_to_s
|
35
|
+
when :number
|
36
|
+
number_to_s
|
37
|
+
else
|
38
|
+
raise ArgumentError, "Don't know how to generate a Filter for type #{@type}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def number_to_s
|
45
|
+
clauses = []
|
46
|
+
if @eq
|
47
|
+
clauses << "#{@field} :EQUALS: #{@value}"
|
48
|
+
end
|
49
|
+
if @gt
|
50
|
+
clauses << "#{@field} :GreaterThan: #{@value}"
|
51
|
+
end
|
52
|
+
if @lt
|
53
|
+
clauses << "#{@field} :LessThan: #{@value}"
|
54
|
+
end
|
55
|
+
clauses.join(" :AND: ")
|
56
|
+
end
|
57
|
+
|
58
|
+
def date_time_to_s
|
59
|
+
clauses = []
|
60
|
+
if @before
|
61
|
+
raise ':before is not a valid DateTime/Time object' unless (@before.is_a?(Time) || @before.is_a?(DateTime))
|
62
|
+
clauses << "#{@field} :BEFORE: #{formatted_time(@before)}"
|
63
|
+
end
|
64
|
+
if @after
|
65
|
+
raise ':after is not a valid DateTime/Time object' unless (@after.is_a?(Time) || @after.is_a?(DateTime))
|
66
|
+
clauses << "#{@field} :AFTER: #{formatted_time(@after)}"
|
67
|
+
end
|
68
|
+
|
69
|
+
if @before.nil? && @after.nil?
|
70
|
+
clauses << "#{@field} :EQUALS: #{formatted_time(@value)}"
|
71
|
+
end
|
72
|
+
|
73
|
+
clauses.join(" :AND: ")
|
74
|
+
end
|
75
|
+
|
76
|
+
def text_to_s
|
77
|
+
"#{@field} :EQUALS: #{@value}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def boolean_to_s
|
81
|
+
"#{@field} :EQUALS: #{@value}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def formatted_time(time)
|
85
|
+
if time.is_a?(Date)
|
86
|
+
time.strftime(DATE_FORMAT)
|
87
|
+
elsif time.is_a?(DateTime) || time.is_a?(Time)
|
88
|
+
time.strftime(DATE_TIME_FORMAT)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/quickeebooks/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
# see https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0400_QuickBooks_Online/CompanyMetaData
|
2
|
+
require "quickeebooks"
|
3
|
+
require "quickeebooks/windows/model/address"
|
4
|
+
require "quickeebooks/windows/model/phone"
|
5
|
+
require "quickeebooks/windows/model/email"
|
6
|
+
|
7
|
+
module Quickeebooks
|
8
|
+
module Windows
|
9
|
+
module Model
|
10
|
+
class CompanyMetaData < Quickeebooks::Windows::Model::IntuitType
|
11
|
+
include ActiveModel::Validations
|
12
|
+
|
13
|
+
XML_COLLECTION_NODE = 'CompaniesMetaData'
|
14
|
+
XML_NODE = 'CompanyMetaData'
|
15
|
+
|
16
|
+
REST_RESOURCE = "company"
|
17
|
+
|
18
|
+
xml_convention :camelcase
|
19
|
+
xml_accessor :external_realm_id, :from => 'ExternalRealmId'
|
20
|
+
xml_accessor :registered_company_name, :from => 'QBNRegisteredCompanyName'
|
21
|
+
xml_accessor :industry_type, :from => 'IndustryType'
|
22
|
+
xml_accessor :addresses, :from => 'Address', :as => [Quickeebooks::Windows::Model::Address]
|
23
|
+
xml_accessor :legal_address, :from => 'LegalAddress', :as => Quickeebooks::Windows::Model::Address
|
24
|
+
xml_accessor :emails, :from => 'Email', :as => [Quickeebooks::Windows::Model::Email]
|
25
|
+
xml_accessor :phone, :from => 'Phone', :as => Quickeebooks::Windows::Model::Phone
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'quickeebooks/windows/model/credit_charge_info'
|
2
|
+
require 'quickeebooks/windows/model/credit_charge_response'
|
3
|
+
|
4
|
+
module Quickeebooks
|
5
|
+
module Windows
|
6
|
+
module Model
|
7
|
+
class CreditCard < Quickeebooks::Windows::Model::IntuitType
|
8
|
+
xml_name 'CreditCard'
|
9
|
+
xml_accessor :credit_charge_info, :from => 'CreditChargeInfo', :as => Quickeebooks::Windows::Model::CreditChargeInfo
|
10
|
+
xml_accessor :credit_charge_response, :from => 'CreditChargeResponse', :as => Quickeebooks::Windows::Model::CreditChargeResponse
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Quickeebooks
|
2
|
+
module Windows
|
3
|
+
module Model
|
4
|
+
class CreditChargeInfo < Quickeebooks::Windows::Model::IntuitType
|
5
|
+
xml_name 'CreditChargeInfo'
|
6
|
+
xml_accessor :number, :from => 'Number'
|
7
|
+
xml_accessor :type, :from => 'Type'
|
8
|
+
xml_accessor :name_on_acct, :from => 'NameOnAcct'
|
9
|
+
xml_accessor :cc_expiration_month, :from => 'CcExpireMn', :as => Integer
|
10
|
+
xml_accessor :cc_expiration_year, :from => 'CcExpireYr', :as => Integer
|
11
|
+
xml_accessor :billing_address_street, :from => 'BillAddrStreet'
|
12
|
+
xml_accessor :zip_code, :from => 'ZipCode'
|
13
|
+
xml_accessor :cvv, :from => 'Ccv'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Quickeebooks
|
2
|
+
module Windows
|
3
|
+
module Model
|
4
|
+
class CreditChargeResponse < Quickeebooks::Windows::Model::IntuitType
|
5
|
+
xml_name 'CreditChargeResponse'
|
6
|
+
xml_accessor :cc_transaction_id, :from => 'CCTransId'
|
7
|
+
xml_accessor :status, :from => 'Status'
|
8
|
+
xml_accessor :auth_code, :from => 'AuthCode'
|
9
|
+
xml_accessor :avs_street, :from => 'AvsStreet'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -73,7 +73,9 @@ module Quickeebooks
|
|
73
73
|
xml_accessor :total_expense, :from => 'TotalExpense', :as => Quickeebooks::Windows::Model::Price
|
74
74
|
|
75
75
|
validates_length_of :name, :minimum => 1
|
76
|
-
validate :
|
76
|
+
validate :require_an_address
|
77
|
+
validate :name_cannot_contain_invalid_characters
|
78
|
+
validate :email_address_is_valid
|
77
79
|
|
78
80
|
def active?
|
79
81
|
active == 'true'
|
@@ -87,18 +89,20 @@ module Quickeebooks
|
|
87
89
|
addresses.detect { |address| address.tag == "Shipping" }
|
88
90
|
end
|
89
91
|
|
90
|
-
def has_required_attributes
|
91
|
-
if name.is_a?(String) && name.index(':') != nil
|
92
|
-
errors.add(:name, "Attribute :name cannot contain a colon")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
92
|
def valid_for_update?
|
97
93
|
if sync_token.nil?
|
98
94
|
errors.add(:sync_token, "Missing required attribute SyncToken for update")
|
99
95
|
end
|
100
96
|
errors.empty?
|
101
97
|
end
|
98
|
+
|
99
|
+
def valid_for_create?
|
100
|
+
valid?
|
101
|
+
if type_of.nil?
|
102
|
+
errors.add(:type_of, "Missing required attribute TypeOf for Create")
|
103
|
+
end
|
104
|
+
errors.empty?
|
105
|
+
end
|
102
106
|
|
103
107
|
def to_xml_ns(options = {})
|
104
108
|
to_xml
|
@@ -107,12 +111,38 @@ module Quickeebooks
|
|
107
111
|
def email_address=(email_address)
|
108
112
|
self.email = Quickeebooks::Windows::Model::Email.new(email_address)
|
109
113
|
end
|
114
|
+
|
115
|
+
def address=(address)
|
116
|
+
self.addresses ||= []
|
117
|
+
self.addresses << address
|
118
|
+
end
|
110
119
|
|
111
120
|
# To delete an account Intuit requires we provide Id and SyncToken fields
|
112
121
|
def valid_for_deletion?
|
113
122
|
return false if(id.nil? || sync_token.nil?)
|
114
123
|
id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
|
115
124
|
end
|
125
|
+
|
126
|
+
def name_cannot_contain_invalid_characters
|
127
|
+
if name.to_s.index(':')
|
128
|
+
errors.add(:name, "Name cannot contain a colon (:)")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def email_address_is_valid
|
133
|
+
if email
|
134
|
+
address = email.address
|
135
|
+
unless address.index('@') && address.index('.')
|
136
|
+
errors.add(:email, "Email address must contain @ and . (dot)")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def require_an_address
|
142
|
+
if addresses.nil? || (addresses.is_a?(Array) && addresses.empty?)
|
143
|
+
errors.add(:addresses, "Must provide at least one address for this Customer.")
|
144
|
+
end
|
145
|
+
end
|
116
146
|
|
117
147
|
end
|
118
148
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Quickeebooks
|
2
|
+
module Windows
|
3
|
+
module Model
|
4
|
+
class PartyRoleRef < Quickeebooks::Windows::Model::IntuitType
|
5
|
+
xml_convention :camelcase
|
6
|
+
xml_accessor :id, :as => Quickeebooks::Windows::Model::Id
|
7
|
+
xml_accessor :party_reference_id, :as => Quickeebooks::Windows::Model::Id
|
8
|
+
xml_accessor :last_updated_time, :as => Time
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'quickeebooks/windows/model/payment_header'
|
2
|
+
require 'quickeebooks/windows/model/payment_line_item'
|
3
|
+
require 'quickeebooks/windows/model/payment_detail'
|
4
|
+
require 'quickeebooks/windows/model/credit_card'
|
5
|
+
require 'quickeebooks/windows/model/credit_charge_info'
|
6
|
+
require 'quickeebooks/windows/model/credit_charge_response'
|
7
|
+
require 'quickeebooks/windows/model/meta_data'
|
8
|
+
|
9
|
+
module Quickeebooks
|
10
|
+
module Windows
|
11
|
+
module Model
|
12
|
+
class Payment < Quickeebooks::Windows::Model::IntuitType
|
13
|
+
include ActiveModel::Validations
|
14
|
+
|
15
|
+
XML_COLLECTION_NODE = 'Payments'
|
16
|
+
XML_NODE = "Payment"
|
17
|
+
REST_RESOURCE = "payment"
|
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 :meta_data, :from => 'MetaData', :as => Quickeebooks::Windows::Model::MetaData
|
23
|
+
xml_accessor :header, :from => 'Header', :as => Quickeebooks::Windows::Model::PaymentHeader
|
24
|
+
xml_accessor :line_items, :from => 'Line', :as => [Quickeebooks::Windows::Model::PaymentLineItem]
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
ensure_line_items_initialization
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def after_parse
|
33
|
+
end
|
34
|
+
|
35
|
+
def ensure_line_items_initialization
|
36
|
+
self.line_items ||= []
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'quickeebooks/windows/model/credit_card'
|
2
|
+
|
3
|
+
module Quickeebooks
|
4
|
+
module Windows
|
5
|
+
module Model
|
6
|
+
class PaymentDetail < Quickeebooks::Windows::Model::IntuitType
|
7
|
+
xml_name 'Detail'
|
8
|
+
xml_accessor :credit_card, :from => 'CreditCard', :as => Quickeebooks::Windows::Model::CreditCard
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'quickeebooks/windows/model/payment_detail'
|
3
|
+
|
4
|
+
module Quickeebooks
|
5
|
+
module Windows
|
6
|
+
module Model
|
7
|
+
class PaymentHeader < Quickeebooks::Windows::Model::IntuitType
|
8
|
+
xml_name 'Header'
|
9
|
+
xml_accessor :doc_number, :from => 'DocNumber'
|
10
|
+
xml_accessor :txn_date, :from => 'TxnDate', :as => Time
|
11
|
+
xml_accessor :note, :from => 'Note'
|
12
|
+
xml_accessor :status, :from => 'Status'
|
13
|
+
xml_accessor :customer_id, :from => 'CustomerId', :as => Quickeebooks::Windows::Model::Id
|
14
|
+
xml_accessor :customer_name, :from => 'CustomerName'
|
15
|
+
xml_accessor :deposit_to_account_id, :from => 'DepositToAccountId', :as => Quickeebooks::Windows::Model::Id
|
16
|
+
xml_accessor :payment_method_id, :from => 'PaymentMethodId', :as => Quickeebooks::Windows::Model::Id
|
17
|
+
xml_accessor :payment_method_name, :from => 'PaymentMethodName'
|
18
|
+
xml_accessor :detail, :from => 'Detail', :as => Quickeebooks::Windows::Model::PaymentDetail
|
19
|
+
xml_accessor :total_amount, :from => 'TotalAmt', :as => Float
|
20
|
+
xml_accessor :process_payment, :from => 'ProcessPayment'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'quickeebooks/windows/model/id'
|
2
|
+
|
3
|
+
module Quickeebooks
|
4
|
+
module Windows
|
5
|
+
module Model
|
6
|
+
class PaymentLineItem < Quickeebooks::Windows::Model::IntuitType
|
7
|
+
xml_name 'Line'
|
8
|
+
xml_accessor :id, :from => 'Id', :as => Integer
|
9
|
+
xml_accessor :amount, :from => 'Amount', :as => Float
|
10
|
+
xml_accessor :desc, :from => 'Desc'
|
11
|
+
xml_accessor :txn_id, :from => 'TxnId', :as => Quickeebooks::Windows::Model::Id
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -22,10 +22,11 @@ module Quickeebooks
|
|
22
22
|
s = "#<RestResponse>: "
|
23
23
|
if success?
|
24
24
|
s += "Success[#{success.request_name}] @ #{success.processed_time} - "
|
25
|
-
|
25
|
+
elsif error?
|
26
26
|
s += "Error[#{error.request_name}] @ #{error.processed_time} - "
|
27
27
|
s += "Code: #{error.code}, Desc: #{error.desc}"
|
28
28
|
end
|
29
|
+
s
|
29
30
|
end
|
30
31
|
|
31
32
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require "quickeebooks/windows/model/object_ref"
|
2
|
+
require "quickeebooks/windows/model/party_role_ref"
|
3
|
+
|
2
4
|
module Quickeebooks
|
3
5
|
module Windows
|
4
6
|
module Model
|
@@ -8,6 +10,7 @@ module Quickeebooks
|
|
8
10
|
|
9
11
|
xml_accessor :request_id, :from => '@RequestId'
|
10
12
|
xml_accessor :object_ref, :as => Quickeebooks::Windows::Model::ObjectRef
|
13
|
+
xml_accessor :party_role_ref, :as => Quickeebooks::Windows::Model::PartyRoleRef
|
11
14
|
xml_accessor :request_name
|
12
15
|
xml_accessor :processed_time, :as => Time
|
13
16
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'quickeebooks/windows/service/service_base'
|
2
|
+
|
3
|
+
module Quickeebooks
|
4
|
+
module Windows
|
5
|
+
module Service
|
6
|
+
class CompanyMetaData < Quickeebooks::Windows::Service::ServiceBase
|
7
|
+
def load
|
8
|
+
model = Quickeebooks::Windows::Model::CompanyMetaData
|
9
|
+
fetch_object(model, url_for_resource(model::REST_RESOURCE))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -17,6 +17,23 @@ module Quickeebooks
|
|
17
17
|
url = "#{url_for_resource(Quickeebooks::Windows::Model::Customer::REST_RESOURCE)}/#{id}"
|
18
18
|
fetch_object(Quickeebooks::Windows::Model::Customer, url, {:idDomain => idDomain})
|
19
19
|
end
|
20
|
+
|
21
|
+
def create(customer)
|
22
|
+
raise InvalidModelException unless customer.valid_for_create?
|
23
|
+
|
24
|
+
# XML is a wrapped 'object' where the type is specified as an attribute
|
25
|
+
# <Object xsi:type="Invoice">
|
26
|
+
xml_node = customer.to_xml(:name => 'Object')
|
27
|
+
xml_node.set_attribute('xsi:type', 'Customer')
|
28
|
+
xml = <<-XML
|
29
|
+
<Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="#{guid}" xmlns="http://www.intuit.com/sb/cdm/v2">
|
30
|
+
<ExternalRealmId>#{self.realm_id}</ExternalRealmId>
|
31
|
+
#{xml_node}
|
32
|
+
</Add>
|
33
|
+
XML
|
34
|
+
perform_write(Quickeebooks::Windows::Model::Customer, xml)
|
35
|
+
|
36
|
+
end
|
20
37
|
|
21
38
|
end
|
22
39
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'quickeebooks/windows/service/service_base'
|
2
|
+
require 'quickeebooks/windows/model/payment'
|
3
|
+
require 'quickeebooks/windows/model/payment_header'
|
4
|
+
require 'quickeebooks/windows/model/payment_line_item'
|
5
|
+
require 'quickeebooks/windows/model/payment_detail'
|
6
|
+
require 'quickeebooks/windows/model/credit_card'
|
7
|
+
require 'quickeebooks/windows/model/credit_charge_info'
|
8
|
+
require 'quickeebooks/windows/model/credit_charge_response'
|
9
|
+
require 'nokogiri'
|
10
|
+
|
11
|
+
module Quickeebooks
|
12
|
+
module Windows
|
13
|
+
module Service
|
14
|
+
class Payment < ServiceBase
|
15
|
+
def fetch_by_id(id, idDomain = 'QB', options = {})
|
16
|
+
url = "#{url_for_resource(Quickeebooks::Windows::Model::Payment::REST_RESOURCE)}/#{id}"
|
17
|
+
fetch_object(Quickeebooks::Windows::Model::Payment, url, { :idDomain => idDomain })
|
18
|
+
end
|
19
|
+
|
20
|
+
def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
|
21
|
+
fetch_collection(Quickeebooks::Windows::Model::Payment, nil, filters, page, per_page, sort, options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -7,9 +7,10 @@ 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.header.balance.should == 0
|
10
11
|
invoice.id.value.should == "13"
|
11
12
|
invoice.line_items.count.should == 1
|
12
13
|
invoice.line_items.first.unit_price.should == 225
|
13
14
|
end
|
14
15
|
|
15
|
-
end
|
16
|
+
end
|
@@ -37,4 +37,18 @@ describe "Quickeebooks::Online::Service::ServiceBase" do
|
|
37
37
|
it "can determine login_name" do
|
38
38
|
@service.login_name.should == 'foo@example.com'
|
39
39
|
end
|
40
|
+
|
41
|
+
it "throws exception when response XML is invalid when determining base url" do
|
42
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/online/invalid_user.xml")
|
43
|
+
user_url = Quickeebooks::Online::Service::ServiceBase::QB_BASE_URI + "/" + @realm_id
|
44
|
+
FakeWeb.register_uri(:get, user_url, :status => ["200", "OK"], :body => xml)
|
45
|
+
@service = Quickeebooks::Online::Service::ServiceBase.new
|
46
|
+
@service.access_token = @oauth
|
47
|
+
@service.instance_eval {
|
48
|
+
@realm_id = "9991111222"
|
49
|
+
}
|
50
|
+
lambda { @service.determine_base_url }.should raise_error(IntuitRequestException)
|
51
|
+
@service.base_uri.should == nil
|
52
|
+
end
|
53
|
+
|
40
54
|
end
|
@@ -0,0 +1,34 @@
|
|
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::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
|
+
end
|
22
|
+
|
23
|
+
it "can fetch the company meta data" do
|
24
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/windows/company_meta_data.xml")
|
25
|
+
model = Quickeebooks::Windows::Model::CompanyMetaData
|
26
|
+
service = Quickeebooks::Windows::Service::CompanyMetaData.new
|
27
|
+
service.access_token = @oauth
|
28
|
+
service.realm_id = @realm_id
|
29
|
+
FakeWeb.register_uri(:get, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
30
|
+
company_meta_data_response = service.load
|
31
|
+
|
32
|
+
company_meta_data_response.registered_company_name.should == "Castle Rock Construction"
|
33
|
+
end
|
34
|
+
end
|
@@ -56,5 +56,103 @@ describe "Quickeebooks::Windows::Service::Customer" do
|
|
56
56
|
customer = service.fetch_by_id(341)
|
57
57
|
customer.name.should == "Wine Stop"
|
58
58
|
end
|
59
|
+
|
60
|
+
it "cannot create a customer without a name" do
|
61
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
62
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
63
|
+
service.access_token = @oauth
|
64
|
+
service.realm_id = @realm_id
|
65
|
+
lambda do
|
66
|
+
service.create(customer)
|
67
|
+
end.should raise_error(InvalidModelException)
|
68
|
+
|
69
|
+
customer.valid?.should == false
|
70
|
+
customer.errors.keys.include?(:name).should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "cannot create a customer without a type_of attribute" do
|
74
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
75
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
76
|
+
service.access_token = @oauth
|
77
|
+
service.realm_id = @realm_id
|
78
|
+
lambda do
|
79
|
+
service.create(customer)
|
80
|
+
end.should raise_error(InvalidModelException)
|
81
|
+
customer.errors.keys.include?(:type_of).should == true
|
82
|
+
end
|
83
|
+
|
84
|
+
it "cannot create a customer with invalid name" do
|
85
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
86
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
87
|
+
service.access_token = @oauth
|
88
|
+
service.realm_id = @realm_id
|
89
|
+
customer.name = "Bobs:Plumbing"
|
90
|
+
lambda do
|
91
|
+
service.create(customer)
|
92
|
+
end.should raise_error(InvalidModelException)
|
93
|
+
|
94
|
+
customer.valid?.should == false
|
95
|
+
customer.errors.keys.include?(:name).should == true
|
96
|
+
end
|
97
|
+
|
98
|
+
it "cannot create a customer with no address" do
|
99
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
100
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
101
|
+
service.access_token = @oauth
|
102
|
+
service.realm_id = @realm_id
|
103
|
+
customer.name = "Bobs Plumbing"
|
104
|
+
lambda do
|
105
|
+
service.create(customer)
|
106
|
+
end.should raise_error(InvalidModelException)
|
107
|
+
|
108
|
+
customer.valid?.should == false
|
109
|
+
customer.errors.keys.include?(:addresses).should == true
|
110
|
+
end
|
111
|
+
|
112
|
+
it "cannot create a customer with an invalid email" do
|
113
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
114
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
115
|
+
service.access_token = @oauth
|
116
|
+
service.realm_id = @realm_id
|
117
|
+
customer.name = "Bobs Plumbing"
|
118
|
+
customer.email_address = "foobar.com"
|
119
|
+
lambda do
|
120
|
+
service.create(customer)
|
121
|
+
end.should raise_error(InvalidModelException)
|
122
|
+
|
123
|
+
customer.valid?.should == false
|
124
|
+
customer.errors.keys.include?(:email).should == true
|
125
|
+
end
|
126
|
+
|
127
|
+
it "can create a customer" do
|
128
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/windows/customer_create_success.xml")
|
129
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
130
|
+
model = Quickeebooks::Windows::Model::Customer
|
131
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
132
|
+
|
133
|
+
service.access_token = @oauth
|
134
|
+
service.realm_id = @realm_id
|
135
|
+
FakeWeb.register_uri(:post, service.url_for_resource(model::REST_RESOURCE), :status => ["200", "OK"], :body => xml)
|
136
|
+
|
137
|
+
customer.type_of = "Person"
|
138
|
+
customer.name = "Bobs Plumbing"
|
139
|
+
email = Quickeebooks::Windows::Model::Email.new
|
140
|
+
email.address = "foo@bar.com"
|
141
|
+
email.tag = "Business"
|
142
|
+
customer.email = email
|
143
|
+
billing_address = Quickeebooks::Windows::Model::Address.new
|
144
|
+
billing_address.tag = "Billing"
|
145
|
+
billing_address.line1 = "123 Main St."
|
146
|
+
billing_address.city = "San Francisco"
|
147
|
+
billing_address.country_sub_division_code = "CA"
|
148
|
+
billing_address.postal_code = "94117"
|
149
|
+
billing_address.country = "USA"
|
150
|
+
customer.address = billing_address
|
151
|
+
create_response = service.create(customer)
|
152
|
+
create_response.success?.should == true
|
153
|
+
create_response.success.party_role_ref.id.value.should == "6762304"
|
154
|
+
create_response.success.request_name.should == "CustomerAdd"
|
155
|
+
end
|
156
|
+
|
59
157
|
|
60
158
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
+
require "fakeweb"
|
3
|
+
require "oauth"
|
4
|
+
require "quickeebooks"
|
5
|
+
require "date"
|
6
|
+
|
7
|
+
describe "Quickeebooks::Windows::Service::Payment" do
|
8
|
+
before(:all) do
|
9
|
+
FakeWeb.allow_net_connect = false
|
10
|
+
qb_key = "key"
|
11
|
+
qb_secret = "secreet"
|
12
|
+
|
13
|
+
@realm_id = "9991111222"
|
14
|
+
@base_uri = "https://qbo.intuit.com/qbo36"
|
15
|
+
@oauth_consumer = OAuth::Consumer.new(qb_key, qb_key, {
|
16
|
+
:site => "https://oauth.intuit.com",
|
17
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
18
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
19
|
+
:access_token_path => "/oauth/v1/get_access_token"
|
20
|
+
})
|
21
|
+
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can fetch a list of payments" do
|
25
|
+
xml = File.read(File.dirname(__FILE__) + "/../../../xml/windows/payments.xml")
|
26
|
+
service = Quickeebooks::Windows::Service::Payment.new
|
27
|
+
service.access_token = @oauth
|
28
|
+
service.realm_id = @realm_id
|
29
|
+
|
30
|
+
model = Quickeebooks::Windows::Model::Payment
|
31
|
+
FakeWeb.register_uri(:get,
|
32
|
+
service.url_for_resource(model::REST_RESOURCE),
|
33
|
+
:status => ["200", "OK"],
|
34
|
+
:body => xml)
|
35
|
+
payments = service.list
|
36
|
+
payments.entries.count.should == 1
|
37
|
+
|
38
|
+
payment = payments.entries.first
|
39
|
+
payment.id.value.should == "4"
|
40
|
+
payment.header.should_not be_nil
|
41
|
+
header = payment.header
|
42
|
+
header.customer_name.should == "Davis"
|
43
|
+
|
44
|
+
line1 = payment.line_items.first
|
45
|
+
line1.should_not be_nil
|
46
|
+
line1.amount.should == header.total_amount
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<qbo:QboUser xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo">
|
3
|
+
<qbo:LoginName>foo@example.com</qbo:LoginName>
|
4
|
+
<qbo:Ticket>V1-162-alskdfasldkjfalsdkjf</qbo:Ticket>
|
5
|
+
<qbo:AgentId>9991111222</qbo:AgentId>
|
6
|
+
<qbo:Blah>Hello</qbo:Blah>
|
7
|
+
</qbo:QboUser>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--XML GENERATED by IntuitDataSyncEngine (IDS) using \\\\SBDomainServices\\CDM\\branches\\3.4.0-rel-1-->
|
3
|
+
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ../common/RestDataFilter.xsd">
|
4
|
+
<CompaniesMetaData>
|
5
|
+
<CompanyMetaData>
|
6
|
+
<ExternalRealmId>202720551</ExternalRealmId>
|
7
|
+
<QBNRegisteredCompanyName>Castle Rock Construction</QBNRegisteredCompanyName>
|
8
|
+
<CompanySignUpDateTime>2011-03-28T17:33:34.0Z</CompanySignUpDateTime>
|
9
|
+
<LatestUploadDateTime>2011-03-28T18:52:19.0Z</LatestUploadDateTime>
|
10
|
+
<QBVersion>21 0 6 4</QBVersion>
|
11
|
+
<CompanyFileName>Quality-Built Construction</CompanyFileName>
|
12
|
+
<FlavorStratum>standard_stratum</FlavorStratum>
|
13
|
+
<SampleFile>false</SampleFile>
|
14
|
+
<QBNCompanyUserAdminIdNumber>118149998</QBNCompanyUserAdminIdNumber>
|
15
|
+
<SyncEnabled>true</SyncEnabled>
|
16
|
+
<Address>
|
17
|
+
<Line1>100 Mason St.</Line1>
|
18
|
+
<Line2>Woodcrest, CA 94327</Line2>
|
19
|
+
</Address>
|
20
|
+
<LegalAddress>
|
21
|
+
<Line1>100 Mason St.</Line1>
|
22
|
+
<City>Woodcrest</City>
|
23
|
+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
|
24
|
+
<PostalCode>94327</PostalCode>
|
25
|
+
</LegalAddress>
|
26
|
+
<FiscalYearStart>1</FiscalYearStart>
|
27
|
+
<IncomeTaxYearStart>1</IncomeTaxYearStart>
|
28
|
+
</CompanyMetaData>
|
29
|
+
</CompaniesMetaData>
|
30
|
+
</RestResponse>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
|
3
|
+
<Success RequestId="48147b60b90e460893db27b32d9f2acf">
|
4
|
+
<PartyRoleRef>
|
5
|
+
<Id idDomain="NG">6762304</Id>
|
6
|
+
<SyncToken>1</SyncToken>
|
7
|
+
<LastUpdatedTime>2012-09-25T21:08:17Z</LastUpdatedTime>
|
8
|
+
<PartyReferenceId idDomain="NG">9270150</PartyReferenceId>
|
9
|
+
</PartyRoleRef>
|
10
|
+
<RequestName>CustomerAdd</RequestName>
|
11
|
+
<ProcessedTime>2012-09-25T21:08:17Z</ProcessedTime>
|
12
|
+
</Success>
|
13
|
+
</RestResponse>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--XML GENERATED by IntuitDataSyncEngine (IDS) using \\\\SBDomainServices\\CDM\\branches\\3.9.0-rel-1-->
|
3
|
+
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2"
|
4
|
+
xmlns:xdb ="http://xmlns.oracle.com/xdb"
|
5
|
+
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xsi:schemaLocation ="http://www.intuit.com/sb/cdm/v2 ../common/RestDataFilter.xsd"><Payments>
|
7
|
+
<Payment>
|
8
|
+
<Id idDomain="QB">4</Id>
|
9
|
+
<SyncToken>1</SyncToken>
|
10
|
+
<MetaData>
|
11
|
+
<CreatedBy>app</CreatedBy>
|
12
|
+
<CreateTime>2012-09-23T23:53:53.0Z</CreateTime>
|
13
|
+
<LastModifiedBy>app</LastModifiedBy>
|
14
|
+
<LastUpdatedTime>2012-09-23T23:53:53.0Z</LastUpdatedTime>
|
15
|
+
</MetaData>
|
16
|
+
<ExternalKey idDomain="QB">4</ExternalKey>
|
17
|
+
<Synchronized>true</Synchronized>
|
18
|
+
<Header>
|
19
|
+
<TxnDate>2012-09-23</TxnDate>
|
20
|
+
<Status>Paid</Status>
|
21
|
+
<CustomerId idDomain="QB">1</CustomerId>
|
22
|
+
<CustomerName>Davis</CustomerName>
|
23
|
+
<RemitToId idDomain="QB">1</RemitToId>
|
24
|
+
<RemitToName>Davis</RemitToName>
|
25
|
+
<ARAccountId idDomain="QB">33</ARAccountId>
|
26
|
+
<ARAccountName>Accounts Receivable</ARAccountName>
|
27
|
+
<DepositToAccountId idDomain="QB">34</DepositToAccountId>
|
28
|
+
<DepositToAccountName>Undeposited Funds</DepositToAccountName>
|
29
|
+
<PaymentMethodId idDomain="QB">1</PaymentMethodId>
|
30
|
+
<PaymentMethodName>Cash</PaymentMethodName>
|
31
|
+
<TotalAmt>100</TotalAmt>
|
32
|
+
</Header>
|
33
|
+
<Line>
|
34
|
+
<Amount>100</Amount>
|
35
|
+
<TxnId idDomain="QB">1</TxnId>
|
36
|
+
<TxnNum>1</TxnNum>
|
37
|
+
</Line>
|
38
|
+
</Payment>
|
39
|
+
</Payments></RestResponse>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'oauth'
|
3
|
+
$: << File.expand_path('./lib')
|
4
|
+
require 'quickeebooks'
|
5
|
+
|
6
|
+
consumer_key = 'qyprdL8NUDMYcCzwp8ea9KbIhaMSRk'
|
7
|
+
consumer_secret = 'FcE5kihBYMVQGvX9UNYMxsrM8mP7bfuxc36PLhJB'
|
8
|
+
qb_oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {
|
9
|
+
:site => "https://oauth.intuit.com",
|
10
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
11
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
12
|
+
:access_token_path => "/oauth/v1/get_access_token",
|
13
|
+
:proxy => 'http://127.0.0.1:8080'
|
14
|
+
})
|
15
|
+
realm_id = "524388660"
|
16
|
+
access_token = "qyprdBzoHRYCVSZg0z5DrX970E2uebeaXSRNnoIjPQMqAXAY"
|
17
|
+
access_secret = "W2oWdboxA9XqwEZrbSv7rNsatphhBs9Vi5byKBjT"
|
18
|
+
oauth = OAuth::AccessToken.new(qb_oauth_consumer, access_token, access_secret)
|
19
|
+
|
20
|
+
service = Quickeebooks::Windows::Service::Customer.new
|
21
|
+
|
22
|
+
service.access_token = oauth
|
23
|
+
service.realm_id = realm_id
|
24
|
+
|
25
|
+
customer = Quickeebooks::Windows::Model::Customer.new
|
26
|
+
customer.type_of = "Person"
|
27
|
+
customer.name = "Cody Test-#{Time.now.to_i}"
|
28
|
+
email = Quickeebooks::Windows::Model::Email.new
|
29
|
+
email.address = "foo@bar.com"
|
30
|
+
email.tag = "Business"
|
31
|
+
customer.email = email
|
32
|
+
billing_address = Quickeebooks::Windows::Model::Address.new
|
33
|
+
billing_address.tag = "Billing"
|
34
|
+
billing_address.line1 = "#{Time.now.to_i} Main St."
|
35
|
+
billing_address.city = "San Francisco"
|
36
|
+
billing_address.country_sub_division_code = "CA"
|
37
|
+
billing_address.postal_code = "94117"
|
38
|
+
billing_address.country = "USA"
|
39
|
+
customer.address = billing_address
|
40
|
+
result = service.create(customer)
|
41
|
+
puts result.inspect
|
data/tmp/online.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'oauth'
|
3
|
+
$: << File.expand_path('./lib')
|
4
|
+
require 'quickeebooks'
|
5
|
+
|
6
|
+
consumer_key = 'qyprdZrwArlbUcJX7SlxresbflsXKY'
|
7
|
+
consumer_secret = 'qhgNfrl9XX8JVztdu5z27idFHdNI5UOSHC5HcItt'
|
8
|
+
qb_oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {
|
9
|
+
:site => "https://oauth.intuit.com",
|
10
|
+
:request_token_path => "/oauth/v1/get_request_token",
|
11
|
+
:authorize_path => "/oauth/v1/get_access_token",
|
12
|
+
:access_token_path => "/oauth/v1/get_access_token",
|
13
|
+
:proxy => 'http://127.0.0.1:8080'
|
14
|
+
})
|
15
|
+
realm_id = "214483939"
|
16
|
+
access_token = "qyprdTrgSmjG8p8yAdBYJAZYEdGDlh5JyuNhBvKS3CSQUMjE"
|
17
|
+
access_secret = "4lAHnUImKT7a69iIjA19xQuk7UNUvs8d6fLcbO6F"
|
18
|
+
oauth = OAuth::AccessToken.new(qb_oauth_consumer, access_token, access_secret)
|
19
|
+
|
20
|
+
service = Quickeebooks::Online::Service::Customer.new
|
21
|
+
service.access_token = oauth
|
22
|
+
service.realm_id = realm_id
|
23
|
+
service.list([], 1, 2)
|
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.7
|
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-
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: roxml
|
@@ -219,11 +219,16 @@ files:
|
|
219
219
|
- lib/quickeebooks/online/service/payment.rb
|
220
220
|
- lib/quickeebooks/online/service/service_base.rb
|
221
221
|
- lib/quickeebooks/online/service/sort.rb
|
222
|
+
- lib/quickeebooks/shared/service/filter.rb
|
222
223
|
- lib/quickeebooks/version.rb
|
223
224
|
- lib/quickeebooks/windows/model/account.rb
|
224
225
|
- lib/quickeebooks/windows/model/account_detail_type.rb
|
225
226
|
- lib/quickeebooks/windows/model/account_reference.rb
|
226
227
|
- lib/quickeebooks/windows/model/address.rb
|
228
|
+
- lib/quickeebooks/windows/model/company_meta_data.rb
|
229
|
+
- lib/quickeebooks/windows/model/credit_card.rb
|
230
|
+
- lib/quickeebooks/windows/model/credit_charge_info.rb
|
231
|
+
- lib/quickeebooks/windows/model/credit_charge_response.rb
|
227
232
|
- lib/quickeebooks/windows/model/custom_field.rb
|
228
233
|
- lib/quickeebooks/windows/model/customer.rb
|
229
234
|
- lib/quickeebooks/windows/model/customer_msg.rb
|
@@ -242,6 +247,11 @@ files:
|
|
242
247
|
- lib/quickeebooks/windows/model/open_balance.rb
|
243
248
|
- lib/quickeebooks/windows/model/other_name.rb
|
244
249
|
- lib/quickeebooks/windows/model/other_name_id.rb
|
250
|
+
- lib/quickeebooks/windows/model/party_role_ref.rb
|
251
|
+
- lib/quickeebooks/windows/model/payment.rb
|
252
|
+
- lib/quickeebooks/windows/model/payment_detail.rb
|
253
|
+
- lib/quickeebooks/windows/model/payment_header.rb
|
254
|
+
- lib/quickeebooks/windows/model/payment_line_item.rb
|
245
255
|
- lib/quickeebooks/windows/model/phone.rb
|
246
256
|
- lib/quickeebooks/windows/model/price.rb
|
247
257
|
- lib/quickeebooks/windows/model/purchase_cost.rb
|
@@ -257,10 +267,13 @@ files:
|
|
257
267
|
- lib/quickeebooks/windows/model/vendor_reference.rb
|
258
268
|
- lib/quickeebooks/windows/model/web_site.rb
|
259
269
|
- lib/quickeebooks/windows/service/account.rb
|
270
|
+
- lib/quickeebooks/windows/service/company_meta_data.rb
|
260
271
|
- lib/quickeebooks/windows/service/customer.rb
|
261
272
|
- lib/quickeebooks/windows/service/customer_msg.rb
|
273
|
+
- lib/quickeebooks/windows/service/filter.rb
|
262
274
|
- lib/quickeebooks/windows/service/invoice.rb
|
263
275
|
- lib/quickeebooks/windows/service/item.rb
|
276
|
+
- lib/quickeebooks/windows/service/payment.rb
|
264
277
|
- lib/quickeebooks/windows/service/sales_rep.rb
|
265
278
|
- lib/quickeebooks/windows/service/sales_tax.rb
|
266
279
|
- lib/quickeebooks/windows/service/service_base.rb
|
@@ -284,8 +297,10 @@ files:
|
|
284
297
|
- spec/quickeebooks/online/services/service_base_spec.rb
|
285
298
|
- spec/quickeebooks/online/services/sort_spec.rb
|
286
299
|
- spec/quickeebooks/windows/customer_spec.rb
|
300
|
+
- spec/quickeebooks/windows/services/company_meta_data_spec.rb
|
287
301
|
- spec/quickeebooks/windows/services/customer_spec.rb
|
288
302
|
- spec/quickeebooks/windows/services/invoice_spec.rb
|
303
|
+
- spec/quickeebooks/windows/services/payment_spec.rb
|
289
304
|
- spec/quickeebooks/windows/services/sales_rep_spec.rb
|
290
305
|
- spec/quickeebooks/windows/services/sales_taxes_spec.rb
|
291
306
|
- spec/quickeebooks/windows/services/ship_method_spec.rb
|
@@ -299,18 +314,24 @@ files:
|
|
299
314
|
- spec/xml/online/customer2.xml
|
300
315
|
- spec/xml/online/customers.xml
|
301
316
|
- spec/xml/online/determine_base_url.xml
|
317
|
+
- spec/xml/online/invalid_user.xml
|
302
318
|
- spec/xml/online/invoice.xml
|
303
319
|
- spec/xml/online/payment.xml
|
304
320
|
- spec/xml/online/user.xml
|
321
|
+
- spec/xml/windows/company_meta_data.xml
|
305
322
|
- spec/xml/windows/customer.xml
|
323
|
+
- spec/xml/windows/customer_create_success.xml
|
306
324
|
- spec/xml/windows/customers.xml
|
307
325
|
- spec/xml/windows/fetch_customer_by_id.xml
|
308
326
|
- spec/xml/windows/http_401.xml
|
309
327
|
- spec/xml/windows/invoice_success_create.xml
|
310
328
|
- spec/xml/windows/invoices.xml
|
329
|
+
- spec/xml/windows/payments.xml
|
311
330
|
- spec/xml/windows/sales_reps.xml
|
312
331
|
- spec/xml/windows/sales_taxes.xml
|
313
332
|
- spec/xml/windows/ship_methods.xml
|
333
|
+
- tmp/create_customer_windows.rb
|
334
|
+
- tmp/online.rb
|
314
335
|
homepage: http://github.com/ruckus/quickeebooks
|
315
336
|
licenses: []
|
316
337
|
post_install_message:
|