Class: IntacctRuby::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/intacct_ruby/function.rb

Overview

a function to be sent to Intacct. Defined by a function type (e.g. :create), an object type, (e.g. :customer), and arguments.

Constant Summary collapse

ALLOWED_TYPES =
%w(
  readByQuery
  read
  readByName
  readMore
  create
  update
  delete
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(function_type, object_type, arguments = {}) ⇒ Function

Returns a new instance of Function.



18
19
20
21
22
23
24
# File 'lib/intacct_ruby/function.rb', line 18

def initialize(function_type, object_type, arguments = {})
  @function_type = function_type.to_s
  @object_type = object_type.to_s
  @arguments = arguments

  validate_type!
end

Instance Method Details

#to_xmlObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/intacct_ruby/function.rb', line 26

def to_xml
  xml = Builder::XmlMarkup.new

  xml.function controlid: controlid do
    xml.tag!(@function_type) do
      xml.tag!(@object_type) do
        xml << argument_xml(@arguments)
      end
    end
  end

  xml.target!
end