intacct_ruby_team 1.7.1
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +179 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/intacct_ruby.gemspec +36 -0
- data/lib/intacct_ruby.rb +27 -0
- data/lib/intacct_ruby/api.rb +31 -0
- data/lib/intacct_ruby/exceptions/empty_request_exception.rb +5 -0
- data/lib/intacct_ruby/exceptions/function_failure_exception.rb +5 -0
- data/lib/intacct_ruby/exceptions/insufficient_credentials_exception.rb +5 -0
- data/lib/intacct_ruby/exceptions/unknown_function_type.rb +5 -0
- data/lib/intacct_ruby/function.rb +92 -0
- data/lib/intacct_ruby/functions/base_function.rb +48 -0
- data/lib/intacct_ruby/functions/create_aradjustment.rb +48 -0
- data/lib/intacct_ruby/functions/create_customer.rb +23 -0
- data/lib/intacct_ruby/functions/create_employee.rb +21 -0
- data/lib/intacct_ruby/functions/create_gltransaction.rb +28 -0
- data/lib/intacct_ruby/functions/create_item.rb +21 -0
- data/lib/intacct_ruby/functions/create_location.rb +21 -0
- data/lib/intacct_ruby/functions/create_project.rb +20 -0
- data/lib/intacct_ruby/functions/create_statgltransaction.rb +28 -0
- data/lib/intacct_ruby/functions/customer_base_function.rb +27 -0
- data/lib/intacct_ruby/functions/employee_base_function.rb +36 -0
- data/lib/intacct_ruby/functions/gltransaction_base_function.rb +64 -0
- data/lib/intacct_ruby/functions/item_base_function.rb +29 -0
- data/lib/intacct_ruby/functions/location_base_function.rb +24 -0
- data/lib/intacct_ruby/functions/project_base_function.rb +22 -0
- data/lib/intacct_ruby/functions/update_customer.rb +22 -0
- data/lib/intacct_ruby/functions/update_employee.rb +20 -0
- data/lib/intacct_ruby/functions/update_item.rb +20 -0
- data/lib/intacct_ruby/functions/update_location.rb +20 -0
- data/lib/intacct_ruby/functions/update_project.rb +20 -0
- data/lib/intacct_ruby/helpers/contacts_helper.rb +32 -0
- data/lib/intacct_ruby/helpers/date_helper.rb +22 -0
- data/lib/intacct_ruby/request.rb +138 -0
- data/lib/intacct_ruby/response.rb +43 -0
- data/lib/intacct_ruby/version.rb +3 -0
- metadata +205 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'builder'
|
|
2
|
+
require 'intacct_ruby/exceptions/unknown_function_type'
|
|
3
|
+
|
|
4
|
+
module IntacctRuby
|
|
5
|
+
# a function to be sent to Intacct. Defined by a function type (e.g. :create),
|
|
6
|
+
# an object type, (e.g. :customer), and arguments.
|
|
7
|
+
class Function
|
|
8
|
+
ALLOWED_TYPES = %w(
|
|
9
|
+
readByQuery
|
|
10
|
+
read
|
|
11
|
+
readByName
|
|
12
|
+
create
|
|
13
|
+
update
|
|
14
|
+
delete
|
|
15
|
+
).freeze
|
|
16
|
+
|
|
17
|
+
def initialize(function_type, object_type, arguments = {})
|
|
18
|
+
@function_type = function_type.to_s
|
|
19
|
+
@object_type = object_type.to_s
|
|
20
|
+
@arguments = arguments
|
|
21
|
+
|
|
22
|
+
validate_type!
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def to_xml
|
|
26
|
+
xml = Builder::XmlMarkup.new
|
|
27
|
+
|
|
28
|
+
xml.function controlid: controlid do
|
|
29
|
+
xml.tag!(@function_type) do
|
|
30
|
+
xml.tag!(@object_type.upcase) do
|
|
31
|
+
xml << argument_xml(@arguments)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
xml.target!
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def timestamp
|
|
42
|
+
@timestamp ||= Time.now.utc.to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def controlid
|
|
46
|
+
"#{@function_type}-#{@object_type}-#{timestamp}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def argument_xml(arguments_to_convert)
|
|
50
|
+
xml = Builder::XmlMarkup.new
|
|
51
|
+
|
|
52
|
+
arguments_to_convert.each do |key, value|
|
|
53
|
+
argument_key = key.to_s.upcase
|
|
54
|
+
|
|
55
|
+
xml.tag!(argument_key) do
|
|
56
|
+
xml << argument_value_as_xml(value)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
xml.target!
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def argument_value_as_xml(value)
|
|
64
|
+
case value
|
|
65
|
+
when Hash
|
|
66
|
+
argument_xml(value) # recursive case
|
|
67
|
+
when Array
|
|
68
|
+
argument_value_list_xml(value) # recursive case
|
|
69
|
+
else
|
|
70
|
+
value.to_s # end case
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def argument_value_list_xml(array_of_hashes)
|
|
75
|
+
xml = Builder::XmlMarkup.new
|
|
76
|
+
|
|
77
|
+
array_of_hashes.each do |argument_hash|
|
|
78
|
+
xml << argument_xml(argument_hash)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
xml.target!
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def validate_type!
|
|
85
|
+
unless ALLOWED_TYPES.include?(@function_type)
|
|
86
|
+
raise Exceptions::UnknownFunctionType,
|
|
87
|
+
"Type #{@object_type} not recognized. Function Type must be " \
|
|
88
|
+
"one of #{ALLOWED_TYPES}."
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|