Class: IntacctRuby::Request
- Inherits:
-
Object
- Object
- IntacctRuby::Request
- Defined in:
- lib/intacct_ruby/request.rb
Overview
An outgoing request to the Intacct API. Can have multiple functions. Complete with send method that gets (and wraps) response from Intacct.
Constant Summary collapse
- DEFAULTS =
{ uniqueid: false, dtdversion: 3.0, includewhitespace: false, transaction: true }.freeze
- REQUIRED_AUTHENTICATION_KEYS =
[ :senderid, :sender_password, :userid, :companyid, :user_password ].freeze
Instance Method Summary collapse
-
#initialize(*functions, request_params) ⇒ Request
constructor
A new instance of Request.
- #send(api = nil) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(*functions, request_params) ⇒ Request
Returns a new instance of Request.
27 28 29 30 31 32 33 34 |
# File 'lib/intacct_ruby/request.rb', line 27 def initialize(*functions, request_params) # request_params should contain all req'd authentication information. If # not, an error will be thrown on #send @opts = DEFAULTS.dup.merge request_params # If a hash is provided + popped, the remaining attrs are functions @functions = functions end |
Instance Method Details
#send(api = nil) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/intacct_ruby/request.rb', line 48 def send(api = nil) api ||= Api.new validate_keys! validate_functions! Response.new api.send(self) end |
#to_xml ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/intacct_ruby/request.rb', line 36 def to_xml @to_xml ||= begin @request = Builder::XmlMarkup.new request.instruct! request.request do control_block operation_block end end end |