Class: Intacct::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/intacct/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(transaction_operation: false) ⇒ Request

Returns a new instance of Request.



9
10
11
12
13
# File 'lib/intacct/request.rb', line 9

def initialize(transaction_operation: false)
  @functions = []
  @authentication = nil
  @transaction_operation = transaction_operation
end

Instance Method Details

#add_function(function, control_id) ⇒ Object



15
16
17
# File 'lib/intacct/request.rb', line 15

def add_function(function, control_id)
  @functions << { function:, control_id: }
end

#to_xml(control_config) ⇒ Object

Raises:

  • (MissingAuthenticationException)


29
30
31
32
33
34
35
36
37
38
# File 'lib/intacct/request.rb', line 29

def to_xml(control_config)
  raise MissingAuthenticationException unless @authentication

  builder = Builder::XmlMarkup.new
  builder.instruct!
  builder.request do
    add_control_block(builder, control_config)
    add_operation_block(builder)
  end
end

#use_credentials_authentication(user_id:, company_id:, user_password:) ⇒ Object



19
20
21
22
23
# File 'lib/intacct/request.rb', line 19

def use_credentials_authentication(user_id:, company_id:, user_password:)
  @authentication = Intacct::AuthenticationMethods::Credentials.new(
    user_id:, company_id:, password: user_password
  )
end

#use_session_authentication(session_token) ⇒ Object



25
26
27
# File 'lib/intacct/request.rb', line 25

def use_session_authentication(session_token)
  @authentication = Intacct::AuthenticationMethods::Session.new(session_token)
end