intacct_ruby 1.8.2 → 2.0.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -7
- data/intacct_ruby.gemspec +3 -3
- data/lib/intacct_ruby.rb +0 -22
- data/lib/intacct_ruby/function.rb +16 -16
- data/lib/intacct_ruby/response.rb +3 -3
- data/lib/intacct_ruby/version.rb +1 -1
- metadata +5 -25
- data/lib/intacct_ruby/functions/base_function.rb +0 -48
- data/lib/intacct_ruby/functions/create_aradjustment.rb +0 -48
- data/lib/intacct_ruby/functions/create_customer.rb +0 -23
- data/lib/intacct_ruby/functions/create_employee.rb +0 -21
- data/lib/intacct_ruby/functions/create_gltransaction.rb +0 -28
- data/lib/intacct_ruby/functions/create_item.rb +0 -21
- data/lib/intacct_ruby/functions/create_location.rb +0 -21
- data/lib/intacct_ruby/functions/create_project.rb +0 -20
- data/lib/intacct_ruby/functions/create_statgltransaction.rb +0 -28
- data/lib/intacct_ruby/functions/customer_base_function.rb +0 -27
- data/lib/intacct_ruby/functions/employee_base_function.rb +0 -36
- data/lib/intacct_ruby/functions/gltransaction_base_function.rb +0 -64
- data/lib/intacct_ruby/functions/item_base_function.rb +0 -29
- data/lib/intacct_ruby/functions/location_base_function.rb +0 -24
- data/lib/intacct_ruby/functions/project_base_function.rb +0 -22
- data/lib/intacct_ruby/functions/update_customer.rb +0 -22
- data/lib/intacct_ruby/functions/update_employee.rb +0 -20
- data/lib/intacct_ruby/functions/update_item.rb +0 -20
- data/lib/intacct_ruby/functions/update_location.rb +0 -20
- data/lib/intacct_ruby/functions/update_project.rb +0 -20
- data/lib/intacct_ruby/helpers/contacts_helper.rb +0 -32
- data/lib/intacct_ruby/helpers/date_helper.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d37404ab1cd29e71d19ff93958db3d09ba2f811
|
4
|
+
data.tar.gz: 403b879bfc5645a921779e0c10344befea433a0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f54943581d44599a57b68d0b4bd46a10cd194733a66d14c7fabfb542ef150f682fdb33ec2933bd7154f34686995adfc8fc1e7496a9984570ab545ed7c4b079cf
|
7
|
+
data.tar.gz: 59baae1a3c747df587619ad0bb46f94840647a756f0317e090086b26466a1ff4fd1c634062232330c849969ae91ab80615666bf595e7a97fa0aca261a2917eb2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 2.0.0 (May 18, 2018)
|
2
|
+
|
3
|
+
* Use keyword-args ([@bezoar17](https://github.com/bezoar17) in [#20](https://github.com/privateprep/intacct-ruby/pull/20))
|
4
|
+
* Renames param to reflect true nature ([@toddsiegel](https://github.com/toddsiegel) in [#21](https://github.com/privateprep/intacct-ruby/pull/21))
|
5
|
+
* Cleans up dead code ([@danielpowell4](https://github.com/danielpowell4) in [#22](https://github.com/privateprep/intacct-ruby/pull/22))
|
6
|
+
|
1
7
|
# 1.8.2 (March 20, 2018)
|
2
8
|
|
3
9
|
* Fixup object_type nil bug for read requests ([@bezoar17](https://github.com/bezoar17) in [#16](https://github.com/privateprep/intacct-ruby/pull/16))
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
[](https://travis-ci.org/privateprep/intacct-ruby)
|
2
3
|
|
3
4
|
# IntacctRuby
|
@@ -21,7 +22,7 @@ Let's say you want to create a project and a customer associated with that proje
|
|
21
22
|
# for more information.
|
22
23
|
request = IntacctRuby::Request.new(REQUEST_OPTS)
|
23
24
|
|
24
|
-
request.create :CUSTOMER, {
|
25
|
+
request.create object_type: :CUSTOMER, parameters: {
|
25
26
|
CUSTOMERID: '1',
|
26
27
|
FIRST_NAME: 'Han',
|
27
28
|
LAST_NAME: 'Solo',
|
@@ -30,7 +31,7 @@ request.create :CUSTOMER, {
|
|
30
31
|
STATUS: 'active'
|
31
32
|
}
|
32
33
|
|
33
|
-
request.create :PROJECT, {
|
34
|
+
request.create object_type: :PROJECT, parameters: {
|
34
35
|
PROJECTID: '1',
|
35
36
|
NAME: 'Get Chewie a Haircut',
|
36
37
|
PROJECTCATEGORY: 'Improve Wookie Hygene',
|
@@ -84,15 +85,15 @@ This will fire off a request that looks something like this:
|
|
84
85
|
|
85
86
|
### Read Requests
|
86
87
|
|
87
|
-
The read requests follow a slightly different pattern. The object-type is mentioned inside the object tag as seen here [Intacct List Journal Entries](https://developer.intacct.com/api/general-ledger/journal-entries/#list-journal-entry-lines). The following code will read all GLENTRY objects in a specific interval
|
88
|
+
The read requests follow a slightly different pattern. The object-type is mentioned inside the `object` tag as seen here [Intacct List Journal Entries](https://developer.intacct.com/api/general-ledger/journal-entries/#list-journal-entry-lines). Hence, read requests don't accept a `object_type:` argument directly, the object type is passed through the parameters argument. The following code will read all GLENTRY objects in a specific interval
|
88
89
|
|
89
90
|
**Note:** The gem encodes the queries to a valid XML so that you don't have to. You can query using the `&, >, <` operators as seen below.
|
90
91
|
|
91
92
|
```ruby
|
92
93
|
request = IntacctRuby::Request.new(REQUEST_OPTS)
|
93
94
|
|
94
|
-
# Object-Type GLENTRY is sent through
|
95
|
-
request.readByQuery
|
95
|
+
# Object-Type GLENTRY is sent through the parameters arguments
|
96
|
+
request.readByQuery parameters: {
|
96
97
|
object: 'GLENTRY',
|
97
98
|
query: "BATCH_DATE >= '03-01-2018' AND BATCH_DATE <= '03-15-2018'",
|
98
99
|
fields: '*',
|
@@ -129,7 +130,7 @@ Similarly, for pagination use the `readMore` function as mentioned here [Intacct
|
|
129
130
|
```ruby
|
130
131
|
request = IntacctRuby::Request.new(REQUEST_OPTS)
|
131
132
|
|
132
|
-
request.readMore
|
133
|
+
request.readMore parameters: {
|
133
134
|
resultId: '7765623332WU1hh8CoA4QAAHxI9i8AAAAA5'
|
134
135
|
}
|
135
136
|
|
@@ -257,7 +258,7 @@ Or install it yourself as:
|
|
257
258
|
|
258
259
|
## Contributing
|
259
260
|
|
260
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
261
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/privateprep/intacct-ruby/.
|
261
262
|
|
262
263
|
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
263
264
|
|
data/intacct_ruby.gemspec
CHANGED
@@ -7,14 +7,14 @@ require 'intacct_ruby/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'intacct_ruby'
|
9
9
|
spec.version = IntacctRuby::VERSION
|
10
|
-
spec.authors = ['Jeremy Zornow']
|
11
|
-
spec.email = ['jeremy@zornow.com']
|
10
|
+
spec.authors = ['Jeremy Zornow', 'Dan Powell']
|
11
|
+
spec.email = ['jeremy@zornow.com', 'dan.powell@privateprep.com']
|
12
12
|
spec.required_ruby_version = '>= 2.2.0'
|
13
13
|
spec.summary = 'A Ruby wrapper for the Intacct API'
|
14
14
|
spec.description = 'Allows for multi-function API calls, the ' \
|
15
15
|
'addition of custom fields, and more. All in ' \
|
16
16
|
'an easy-to-use package!'
|
17
|
-
spec.homepage = 'https://github.com/
|
17
|
+
spec.homepage = 'https://github.com/privateprep/intacct-ruby'
|
18
18
|
spec.license = 'MIT'
|
19
19
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/intacct_ruby.rb
CHANGED
@@ -3,25 +3,3 @@ require 'intacct_ruby/version'
|
|
3
3
|
|
4
4
|
require 'intacct_ruby/request'
|
5
5
|
require 'intacct_ruby/response'
|
6
|
-
|
7
|
-
require 'intacct_ruby/functions/base_function'
|
8
|
-
|
9
|
-
require 'intacct_ruby/functions/create_customer'
|
10
|
-
require 'intacct_ruby/functions/update_customer'
|
11
|
-
|
12
|
-
require 'intacct_ruby/functions/create_project'
|
13
|
-
require 'intacct_ruby/functions/update_project'
|
14
|
-
|
15
|
-
require 'intacct_ruby/functions/create_employee'
|
16
|
-
require 'intacct_ruby/functions/update_employee'
|
17
|
-
|
18
|
-
require 'intacct_ruby/functions/create_location'
|
19
|
-
require 'intacct_ruby/functions/update_location'
|
20
|
-
|
21
|
-
require 'intacct_ruby/functions/create_item'
|
22
|
-
require 'intacct_ruby/functions/update_item'
|
23
|
-
|
24
|
-
require 'intacct_ruby/functions/create_aradjustment'
|
25
|
-
|
26
|
-
require 'intacct_ruby/functions/create_gltransaction'
|
27
|
-
require 'intacct_ruby/functions/create_statgltransaction'
|
@@ -3,7 +3,7 @@ require 'intacct_ruby/exceptions/unknown_function_type'
|
|
3
3
|
|
4
4
|
module IntacctRuby
|
5
5
|
# a function to be sent to Intacct. Defined by a function type (e.g. :create),
|
6
|
-
# an object type, (e.g. :customer), and
|
6
|
+
# an object type, (e.g. :customer), and parameters.
|
7
7
|
class Function
|
8
8
|
ALLOWED_TYPES = %w(
|
9
9
|
readByQuery
|
@@ -17,10 +17,10 @@ module IntacctRuby
|
|
17
17
|
|
18
18
|
CU_TYPES = %w(create update).freeze
|
19
19
|
|
20
|
-
def initialize(function_type, object_type,
|
20
|
+
def initialize(function_type, object_type: nil, parameters: )
|
21
21
|
@function_type = function_type.to_s
|
22
22
|
@object_type = object_type.to_s
|
23
|
-
@
|
23
|
+
@parameters = parameters
|
24
24
|
|
25
25
|
validate_type!
|
26
26
|
end
|
@@ -32,10 +32,10 @@ module IntacctRuby
|
|
32
32
|
xml.tag!(@function_type) do
|
33
33
|
if CU_TYPES.include?(@function_type)
|
34
34
|
xml.tag!(@object_type) do
|
35
|
-
xml <<
|
35
|
+
xml << parameter_xml(@parameters)
|
36
36
|
end
|
37
37
|
else
|
38
|
-
xml <<
|
38
|
+
xml << parameter_xml(@parameters)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -53,36 +53,36 @@ module IntacctRuby
|
|
53
53
|
"#{@function_type}-#{@object_type}-#{timestamp}"
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def parameter_xml(parameters_to_convert)
|
57
57
|
xml = Builder::XmlMarkup.new
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
parameters_to_convert.each do |key, value|
|
60
|
+
parameter_key = key.to_s
|
61
61
|
|
62
|
-
xml.tag!(
|
63
|
-
xml <<
|
62
|
+
xml.tag!(parameter_key) do
|
63
|
+
xml << parameter_value_as_xml(value)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
xml.target!
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def parameter_value_as_xml(value)
|
71
71
|
case value
|
72
72
|
when Hash
|
73
|
-
|
73
|
+
parameter_xml(value) # recursive case
|
74
74
|
when Array
|
75
|
-
|
75
|
+
parameter_value_list_xml(value) # recursive case
|
76
76
|
else
|
77
77
|
value.to_s.encode(xml: :text) # end case
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
81
|
+
def parameter_value_list_xml(array_of_hashes)
|
82
82
|
xml = Builder::XmlMarkup.new
|
83
83
|
|
84
|
-
array_of_hashes.each do |
|
85
|
-
xml <<
|
84
|
+
array_of_hashes.each do |parameter_hash|
|
85
|
+
xml << parameter_xml(parameter_hash)
|
86
86
|
end
|
87
87
|
|
88
88
|
xml.target!
|
@@ -13,11 +13,11 @@ module IntacctRuby
|
|
13
13
|
class Response
|
14
14
|
attr_reader :response_body
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
@response_body = Nokogiri::XML(
|
16
|
+
def initialize(http_response)
|
17
|
+
@response_body = Nokogiri::XML(http_response.body)
|
18
18
|
|
19
19
|
# raises an error unless the response is in the 2xx range.
|
20
|
-
|
20
|
+
http_response.value
|
21
21
|
|
22
22
|
# in case the response is a success, but one of the included functions
|
23
23
|
# failed and the transaction was rolled back
|
data/lib/intacct_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intacct_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Zornow
|
8
|
+
- Dan Powell
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2018-
|
12
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -150,6 +151,7 @@ description: Allows for multi-function API calls, the addition of custom fields,
|
|
150
151
|
more. All in an easy-to-use package!
|
151
152
|
email:
|
152
153
|
- jeremy@zornow.com
|
154
|
+
- dan.powell@privateprep.com
|
153
155
|
executables: []
|
154
156
|
extensions: []
|
155
157
|
extra_rdoc_files: []
|
@@ -175,32 +177,10 @@ files:
|
|
175
177
|
- lib/intacct_ruby/exceptions/insufficient_credentials_exception.rb
|
176
178
|
- lib/intacct_ruby/exceptions/unknown_function_type.rb
|
177
179
|
- lib/intacct_ruby/function.rb
|
178
|
-
- lib/intacct_ruby/functions/base_function.rb
|
179
|
-
- lib/intacct_ruby/functions/create_aradjustment.rb
|
180
|
-
- lib/intacct_ruby/functions/create_customer.rb
|
181
|
-
- lib/intacct_ruby/functions/create_employee.rb
|
182
|
-
- lib/intacct_ruby/functions/create_gltransaction.rb
|
183
|
-
- lib/intacct_ruby/functions/create_item.rb
|
184
|
-
- lib/intacct_ruby/functions/create_location.rb
|
185
|
-
- lib/intacct_ruby/functions/create_project.rb
|
186
|
-
- lib/intacct_ruby/functions/create_statgltransaction.rb
|
187
|
-
- lib/intacct_ruby/functions/customer_base_function.rb
|
188
|
-
- lib/intacct_ruby/functions/employee_base_function.rb
|
189
|
-
- lib/intacct_ruby/functions/gltransaction_base_function.rb
|
190
|
-
- lib/intacct_ruby/functions/item_base_function.rb
|
191
|
-
- lib/intacct_ruby/functions/location_base_function.rb
|
192
|
-
- lib/intacct_ruby/functions/project_base_function.rb
|
193
|
-
- lib/intacct_ruby/functions/update_customer.rb
|
194
|
-
- lib/intacct_ruby/functions/update_employee.rb
|
195
|
-
- lib/intacct_ruby/functions/update_item.rb
|
196
|
-
- lib/intacct_ruby/functions/update_location.rb
|
197
|
-
- lib/intacct_ruby/functions/update_project.rb
|
198
|
-
- lib/intacct_ruby/helpers/contacts_helper.rb
|
199
|
-
- lib/intacct_ruby/helpers/date_helper.rb
|
200
180
|
- lib/intacct_ruby/request.rb
|
201
181
|
- lib/intacct_ruby/response.rb
|
202
182
|
- lib/intacct_ruby/version.rb
|
203
|
-
homepage: https://github.com/
|
183
|
+
homepage: https://github.com/privateprep/intacct-ruby
|
204
184
|
licenses:
|
205
185
|
- MIT
|
206
186
|
metadata: {}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'builder'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# Creates the basic structure for all functions.
|
6
|
-
# Meant to be an interface: this should not be implemented on its own.
|
7
|
-
class BaseFunction
|
8
|
-
def initialize(controlid, attrs = {})
|
9
|
-
@controlid = controlid
|
10
|
-
@attrs = attrs
|
11
|
-
|
12
|
-
@xml = Builder::XmlMarkup.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_xml
|
16
|
-
@to_xml ||= begin
|
17
|
-
@xml.function controlid: @controlid do
|
18
|
-
yield(@xml)
|
19
|
-
end
|
20
|
-
|
21
|
-
# converts xml to string
|
22
|
-
@xml.target!
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def timestamp
|
29
|
-
@timestamp ||= Time.now.utc.to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
def custom_field_params(custom_fields)
|
33
|
-
xml = Builder::XmlMarkup.new
|
34
|
-
|
35
|
-
xml.customfields do
|
36
|
-
custom_fields.each do |name, value|
|
37
|
-
xml.customfield do
|
38
|
-
xml.customfieldname name.to_s
|
39
|
-
xml.customfieldvalue value.to_s
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
xml.target!
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# creates ar adjustment instance in Intacct
|
7
|
-
class CreateARAdjustment < BaseFunction
|
8
|
-
include DateHelper
|
9
|
-
|
10
|
-
def initialize(attrs = {})
|
11
|
-
super "create_aradjustment (Customer \##{attrs[:customerid]}, " \
|
12
|
-
"(#{timestamp})", attrs
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_xml
|
16
|
-
super do |xml|
|
17
|
-
xml.create_aradjustment do
|
18
|
-
xml.customerid @attrs[:customerid]
|
19
|
-
|
20
|
-
xml << date_params(:datecreated, @attrs[:datecreated])
|
21
|
-
|
22
|
-
xml.description @attrs[:description]
|
23
|
-
|
24
|
-
xml.aradjustmentitems do
|
25
|
-
xml << line_item_params(@attrs[:aradjustmentitems])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def line_item_params(adjustment_item_attrs)
|
34
|
-
xml = Builder::XmlMarkup.new
|
35
|
-
|
36
|
-
adjustment_item_attrs.each do |item_params|
|
37
|
-
xml.lineitem do
|
38
|
-
[:glaccountno, :amount, :memo, :locationid].each do |param_key|
|
39
|
-
xml.tag!(param_key) { xml << item_params[param_key].to_s }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
xml.target!
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/helpers/contacts_helper'
|
2
|
-
require 'intacct_ruby/functions/customer_base_function'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# function that creates customer instance
|
7
|
-
class CreateCustomer < CustomerBaseFunction
|
8
|
-
def initialize(attrs = {})
|
9
|
-
super "create_customer_#{attrs[:customerid]}", attrs
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_xml
|
13
|
-
super do |xml|
|
14
|
-
xml.create_customer do
|
15
|
-
xml.customerid @attrs[:customerid]
|
16
|
-
|
17
|
-
xml << customer_params
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/employee_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# Function that creates an employee instance in Intacct
|
6
|
-
class CreateEmployee < EmployeeBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("create_employee_#{attrs[:employeeid]}", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.create_employee do
|
14
|
-
xml.employeeid @attrs[:employeeid]
|
15
|
-
xml << employee_params
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/gltransaction_base_function'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# creates gltransaction instance in Intacct
|
7
|
-
class CreateGLTransaction < GLTransactionBaseFunction
|
8
|
-
include DateHelper
|
9
|
-
|
10
|
-
def initialize(attrs = {})
|
11
|
-
super "create_gltransaction (#{attrs[:description]} #{timestamp})",
|
12
|
-
attrs
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_xml
|
16
|
-
super do |xml|
|
17
|
-
xml.create_gltransaction do
|
18
|
-
xml << gltransaction_header_params(@attrs)
|
19
|
-
|
20
|
-
xml.gltransactionentries do
|
21
|
-
xml << gltransactionentry_params(@attrs[:gltransactionentries])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/item_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# creates an item instance in Intacct
|
6
|
-
class CreateItem < ItemBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super "create_item_#{attrs[:itemid]}", attrs
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.create_item do
|
14
|
-
xml.itemid @attrs[:itemid]
|
15
|
-
xml << item_params
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/location_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# Function that creates a location instance in Intacct
|
6
|
-
class CreateLocation < LocationBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("create_location_#{attrs[:locationid]}", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.create_location do
|
14
|
-
xml.locationid @attrs[:locationid]
|
15
|
-
xml << location_params
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/project_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# creates a project instance in Intacct
|
6
|
-
class CreateProject < ProjectBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("create_project_#{attrs[:projectid]}", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.create_project do
|
14
|
-
xml << project_params
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/gltransaction_base_function'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# creates gltransaction instance in Intacct
|
7
|
-
class CreateStatGLTransaction < GLTransactionBaseFunction
|
8
|
-
include DateHelper
|
9
|
-
|
10
|
-
def initialize(attrs = {})
|
11
|
-
super "create_statgltransaction (#{attrs[:description]} #{timestamp})",
|
12
|
-
attrs
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_xml
|
16
|
-
super do |xml|
|
17
|
-
xml.create_statgltransaction do
|
18
|
-
xml << gltransaction_header_params(@attrs)
|
19
|
-
|
20
|
-
xml.statgltransactionentries do
|
21
|
-
xml << gltransactionentry_params(@attrs[:statgltransactionentries])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
require 'intacct_ruby/helpers/contacts_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# the parent for all customer-related functions. Includes methods that
|
7
|
-
# cut down on duplicate code
|
8
|
-
class CustomerBaseFunction < BaseFunction
|
9
|
-
include ContactsHelper
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def customer_params
|
14
|
-
xml = Builder::XmlMarkup.new
|
15
|
-
|
16
|
-
xml.name full_name(@attrs)
|
17
|
-
xml.custrepid @attrs[:custrepid]
|
18
|
-
xml.status @attrs[:status]
|
19
|
-
xml.contactinfo do
|
20
|
-
xml << contact_params(@attrs, @attrs[:customerid], 'Customer')
|
21
|
-
end
|
22
|
-
|
23
|
-
xml.target!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/helpers/contacts_helper'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
require 'intacct_ruby/functions/base_function'
|
4
|
-
|
5
|
-
module IntacctRuby
|
6
|
-
module Functions
|
7
|
-
# contains code shared by all employee functions
|
8
|
-
class EmployeeBaseFunction < BaseFunction
|
9
|
-
include IntacctRuby::ContactsHelper
|
10
|
-
include IntacctRuby::DateHelper
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def employee_params
|
15
|
-
xml = Builder::XmlMarkup.new
|
16
|
-
|
17
|
-
xml.locationid @attrs[:locationid]
|
18
|
-
xml.supervisorid @attrs[:supervisorid]
|
19
|
-
|
20
|
-
xml << start_date_params
|
21
|
-
|
22
|
-
xml.status @attrs[:status]
|
23
|
-
|
24
|
-
xml.personalinfo do
|
25
|
-
xml << employee_contact_params
|
26
|
-
end
|
27
|
-
|
28
|
-
xml.target!
|
29
|
-
end
|
30
|
-
|
31
|
-
def employee_contact_params
|
32
|
-
contact_params(@attrs, @attrs[:employeeid], 'Employee')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# creates gltransaction instance in Intacct
|
7
|
-
class GLTransactionBaseFunction < BaseFunction
|
8
|
-
include DateHelper
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def gltransaction_header_params(attributes)
|
13
|
-
xml = Builder::XmlMarkup.new
|
14
|
-
|
15
|
-
xml << extract_from_attrs(attributes, :journalid)
|
16
|
-
xml << date_params(:datecreated, attributes[:datecreated])
|
17
|
-
xml << extract_from_attrs(attributes, :description)
|
18
|
-
|
19
|
-
xml.target!
|
20
|
-
end
|
21
|
-
|
22
|
-
def gltransactionentry_params(transaction_entries)
|
23
|
-
xml = Builder::XmlMarkup.new
|
24
|
-
|
25
|
-
transaction_entries.each do |entry_attrs|
|
26
|
-
xml << glentry_params(entry_attrs)
|
27
|
-
end
|
28
|
-
|
29
|
-
xml.target!
|
30
|
-
end
|
31
|
-
|
32
|
-
def glentry_params(attrs)
|
33
|
-
xml = Builder::XmlMarkup.new
|
34
|
-
|
35
|
-
xml.glentry do
|
36
|
-
xml << extract_from_attrs(attrs, :trtype, :amount, :glaccountno)
|
37
|
-
xml << date_params(:datecreated, attrs[:datecreated])
|
38
|
-
xml << extract_from_attrs(
|
39
|
-
attrs,
|
40
|
-
:memo,
|
41
|
-
:locationid,
|
42
|
-
:customerid,
|
43
|
-
:employeeid,
|
44
|
-
:projectid,
|
45
|
-
:itemid
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
xml.target!
|
50
|
-
end
|
51
|
-
|
52
|
-
def extract_from_attrs(attributes_hash, *keys)
|
53
|
-
xml = Builder::XmlMarkup.new
|
54
|
-
|
55
|
-
keys.each do |key|
|
56
|
-
value = attributes_hash[key]
|
57
|
-
xml.tag!(key) { xml << value.to_s } if value
|
58
|
-
end
|
59
|
-
|
60
|
-
xml.target!
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# function that all item functions are built off of, to decreate dupe code
|
6
|
-
class ItemBaseFunction < BaseFunction
|
7
|
-
ALL_PARAMS = [
|
8
|
-
:name,
|
9
|
-
:itemtype,
|
10
|
-
:extended_description,
|
11
|
-
:productlineid,
|
12
|
-
:standard_cost,
|
13
|
-
:glgroup,
|
14
|
-
:uomgrp
|
15
|
-
].freeze
|
16
|
-
|
17
|
-
def item_params
|
18
|
-
xml = Builder::XmlMarkup.new
|
19
|
-
|
20
|
-
ALL_PARAMS.each do |param_name|
|
21
|
-
param_value = @attrs[param_name]
|
22
|
-
xml.tag!(param_name) { xml << param_value } if param_value
|
23
|
-
end
|
24
|
-
|
25
|
-
xml.target!
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
require 'intacct_ruby/helpers/date_helper'
|
3
|
-
|
4
|
-
module IntacctRuby
|
5
|
-
module Functions
|
6
|
-
# base for all location-related functions, to cut down on duplicate code
|
7
|
-
class LocationBaseFunction < BaseFunction
|
8
|
-
include IntacctRuby::DateHelper
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def location_params
|
13
|
-
xml = Builder::XmlMarkup.new
|
14
|
-
|
15
|
-
xml.name @attrs[:name]
|
16
|
-
xml.parentid @attrs[:parentid]
|
17
|
-
|
18
|
-
xml << start_date_params
|
19
|
-
|
20
|
-
xml.target!
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# contains shared code for creating and updating projects
|
6
|
-
class ProjectBaseFunction < BaseFunction
|
7
|
-
private
|
8
|
-
|
9
|
-
def project_params
|
10
|
-
xml = Builder::XmlMarkup.new
|
11
|
-
|
12
|
-
[:projectid, :name, :projectcategory, :customerid].each do |key|
|
13
|
-
xml.tag!(key.to_s) { xml << @attrs[key].to_s }
|
14
|
-
end
|
15
|
-
|
16
|
-
xml << custom_field_params(@attrs[:customfields])
|
17
|
-
|
18
|
-
xml.target!
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/customer_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# update customer instance
|
6
|
-
class UpdateCustomer < CustomerBaseFunction
|
7
|
-
include ContactsHelper
|
8
|
-
|
9
|
-
def initialize(attrs = {})
|
10
|
-
super "update_customer_#{attrs[:customerid]} (#{timestamp})", attrs
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_xml
|
14
|
-
super do |xml|
|
15
|
-
xml.update_customer customerid: @attrs[:customerid] do
|
16
|
-
xml << customer_params
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/employee_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# function used to update employee instances
|
6
|
-
class UpdateEmployee < EmployeeBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("update_employee_#{attrs[:employeeid]} (#{timestamp})", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.update_employee employeeid: @attrs[:employeeid] do
|
14
|
-
xml << employee_params
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/item_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# updates item instance in Intacct
|
6
|
-
class UpdateItem < ItemBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super "update_item_#{attrs[:itemid]} (#{timestamp})", attrs
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.update_item itemid: @attrs[:itemid] do
|
14
|
-
xml << item_params
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/location_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# used to update location instances in Intacct
|
6
|
-
class UpdateLocation < LocationBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("update_location_#{attrs[:locationid]} (#{timestamp})", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.update_location locationid: @attrs[:locationid] do
|
14
|
-
xml << location_params
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'intacct_ruby/functions/project_base_function'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
module Functions
|
5
|
-
# creates a project instance in Intacct
|
6
|
-
class UpdateProject < ProjectBaseFunction
|
7
|
-
def initialize(attrs = {})
|
8
|
-
super("update_project_#{attrs[:projectid]} (#{timestamp})", attrs)
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_xml
|
12
|
-
super do |xml|
|
13
|
-
xml.update_project key: @attrs[:projectid] do
|
14
|
-
xml << project_params
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module IntacctRuby
|
2
|
-
# methods to avoid duplication when creating and updating contact records
|
3
|
-
module ContactsHelper
|
4
|
-
def contact_params(attributes, id, person_type)
|
5
|
-
xml = Builder::XmlMarkup.new
|
6
|
-
|
7
|
-
name = full_name(attributes)
|
8
|
-
|
9
|
-
xml.contact do
|
10
|
-
xml.contactname contactname(name, id, person_type)
|
11
|
-
xml.printas full_name(attributes)
|
12
|
-
xml.firstname attributes[:first_name]
|
13
|
-
xml.lastname attributes[:last_name]
|
14
|
-
xml.email1 attributes[:email1]
|
15
|
-
end
|
16
|
-
|
17
|
-
xml.target!
|
18
|
-
end
|
19
|
-
|
20
|
-
def contactname(name, id, person_type)
|
21
|
-
# a unique identifier for a contact, to be used for Intacct's
|
22
|
-
# contactname field. Person Type required to ensure that there aren't
|
23
|
-
# duplicates (e.g. a customer and employee w/ ID 1 both named
|
24
|
-
# 'John Smith')
|
25
|
-
"#{name} (#{person_type} \##{id})"
|
26
|
-
end
|
27
|
-
|
28
|
-
def full_name(attrs = {})
|
29
|
-
"#{attrs[:first_name]} #{attrs[:last_name]}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'builder'
|
2
|
-
|
3
|
-
module IntacctRuby
|
4
|
-
# methods to help generate date XML for calls
|
5
|
-
module DateHelper
|
6
|
-
def date_params(block_name, attrs = {})
|
7
|
-
xml = Builder::XmlMarkup.new
|
8
|
-
|
9
|
-
xml.tag!(block_name) do
|
10
|
-
xml.year attrs[:year]
|
11
|
-
xml.month attrs[:month]
|
12
|
-
xml.day attrs[:day]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Note: @attrs[:startdate] MUST be defined in the invoking context for this
|
17
|
-
# bad boy to work
|
18
|
-
def start_date_params
|
19
|
-
date_params :startdate, @attrs[:startdate]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|