Class: Twinfield::Create::GeneralLedger
- Inherits:
-
Object
- Object
- Twinfield::Create::GeneralLedger
- Defined in:
- lib/twinfield/create/general_ledger.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ GeneralLedger
constructor
A new instance of GeneralLedger.
- #save ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ GeneralLedger
Returns a new instance of GeneralLedger.
6 7 8 |
# File 'lib/twinfield/create/general_ledger.rb', line 6 def initialize(hash = {}) hash.each { |k, v| send(:"#{k}=", CGI.escapeHTML(v)) } end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/twinfield/create/general_ledger.rb', line 4 def code @code end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/twinfield/create/general_ledger.rb', line 4 def name @name end |
Instance Method Details
#save ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/twinfield/create/general_ledger.rb', line 10 def save response = Twinfield::Api::Process.request do %( <dimension> <office>#{Twinfield.configuration.company}</office> <type>PNL</type> <name>#{name}</name> <code>#{code}</code> </dimension> ) end xml = Nokogiri::XML(response.body[:process_xml_string_response][:process_xml_string_result]) if xml.at_css("dimension").attributes["result"].value == "1" { code: code, status: 1 } else { code: code, status: 0, messages: xml.css("[msg]").map { |x| x.attributes["msg"].value } } end end |