intacctrb 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/intacctrb.rb +1 -0
- data/lib/intacctrb/base.rb +54 -44
- data/lib/intacctrb/logger.rb +11 -0
- data/lib/intacctrb/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cebe8f8462674253ac9513ae003769f24442edba
|
4
|
+
data.tar.gz: c69679328b21385369513d1021ea63c0a3d7e87a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c0d2b780a3f13999a5e945c8dbc8fe4b34149c4fd5a6022f413bd099945ec196985ed540390821161409017684aeb21e40231e6f788e1a6ea7c735be1ae6fa
|
7
|
+
data.tar.gz: fd801253a5d2c4b6b783c2927cbf05912e4d2ded774667f4084c6b508fda9c023a3784ee8b7ce9a5875c3ccdc677effd045091d0d9b490c08175e6899b9ccf35
|
data/Gemfile.lock
CHANGED
data/lib/intacctrb.rb
CHANGED
data/lib/intacctrb/base.rb
CHANGED
@@ -29,57 +29,67 @@ module IntacctRB
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def send_xml action
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
xml.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
xml.authentication {
|
46
|
-
xml.login {
|
47
|
-
xml.userid IntacctRB.app_user_id
|
48
|
-
xml.companyid IntacctRB.app_company_id
|
49
|
-
xml.password IntacctRB.app_password
|
50
|
-
}
|
32
|
+
retry_count = 0
|
33
|
+
begin
|
34
|
+
@intacct_action = action.to_s
|
35
|
+
run_hook :"before_#{intacct_action}" if action=="create"
|
36
|
+
|
37
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
38
|
+
xml.request {
|
39
|
+
xml.control {
|
40
|
+
xml.senderid IntacctRB.xml_sender_id
|
41
|
+
xml.password IntacctRB.xml_password
|
42
|
+
xml.controlid "INVOICE XML"
|
43
|
+
xml.uniqueid "false"
|
44
|
+
xml.dtdversion "3.0"
|
51
45
|
}
|
52
|
-
xml.
|
53
|
-
|
46
|
+
xml.operation(transaction: "false") {
|
47
|
+
xml.authentication {
|
48
|
+
xml.login {
|
49
|
+
xml.userid IntacctRB.app_user_id
|
50
|
+
xml.companyid IntacctRB.app_company_id
|
51
|
+
xml.password IntacctRB.app_password
|
52
|
+
}
|
53
|
+
}
|
54
|
+
xml.content {
|
55
|
+
yield xml
|
56
|
+
}
|
54
57
|
}
|
55
58
|
}
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
xml = builder.doc.root.to_xml
|
60
|
-
puts xml
|
61
|
-
@sent_xml = xml
|
59
|
+
end
|
62
60
|
|
63
|
-
|
64
|
-
|
61
|
+
xml = builder.doc.root.to_xml
|
62
|
+
IntacctRB.logger.info xml
|
63
|
+
@sent_xml = xml
|
64
|
+
|
65
|
+
url = "https://www.intacct.com/ia/xml/xmlgw.phtml"
|
66
|
+
uri = URI(url)
|
67
|
+
retry_count += 1
|
68
|
+
res = Net::HTTP.post_form(uri, 'xmlrequest' => xml)
|
69
|
+
@response = Nokogiri::XML(res.body)
|
70
|
+
IntacctRB.logger.info res.body
|
71
|
+
if successful?
|
72
|
+
if key = response.at('//result//RECORDNO') || response.at('//result//key')
|
73
|
+
set_intacct_id key.content if object
|
74
|
+
end
|
65
75
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
if intacct_action
|
77
|
+
run_hook :after_send_xml, intacct_action
|
78
|
+
#run_hook :"after_#{intacct_action}"
|
79
|
+
end
|
80
|
+
else
|
81
|
+
run_hook :on_error
|
72
82
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
83
|
+
@response
|
84
|
+
rescue Net::ReadTimeout => e
|
85
|
+
if retry_count <= 3
|
86
|
+
IntacctRB.logger.warning "Net::ReadTimeout in IntacctRB; retrying"
|
87
|
+
retry
|
88
|
+
else
|
89
|
+
IntacctRB.logger.error "Net::ReadTimeout in IntacctRB; retries exhausted"
|
90
|
+
raise e
|
77
91
|
end
|
78
|
-
else
|
79
|
-
run_hook :on_error
|
80
92
|
end
|
81
|
-
|
82
|
-
@response
|
83
93
|
end
|
84
94
|
|
85
95
|
def successful?
|
@@ -92,7 +102,7 @@ module IntacctRB
|
|
92
102
|
|
93
103
|
def return_result(response)
|
94
104
|
if successful?
|
95
|
-
data = OpenStruct.new({result: true})
|
105
|
+
data = OpenStruct.new({result: true, object: response})
|
96
106
|
else
|
97
107
|
data = OpenStruct.new({result: false})
|
98
108
|
response.xpath("//result/errormessage/error").each do |error|
|
data/lib/intacctrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intacctrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Hale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/intacctrb/exceptions/vendor.rb
|
185
185
|
- lib/intacctrb/invoice.rb
|
186
186
|
- lib/intacctrb/journal_entry.rb
|
187
|
+
- lib/intacctrb/logger.rb
|
187
188
|
- lib/intacctrb/vendor.rb
|
188
189
|
- lib/intacctrb/version.rb
|
189
190
|
- pkg/intacctrb-0.1.gem
|