Class: Twinfield::Create::Debtor
- Inherits:
-
Object
- Object
- Twinfield::Create::Debtor
- Defined in:
- lib/twinfield/create/debtor.rb
Instance Attribute Summary collapse
-
#bank_biccode ⇒ Object
Returns the value of attribute bank_biccode.
-
#bank_country ⇒ Object
Returns the value of attribute bank_country.
-
#bank_description ⇒ Object
Returns the value of attribute bank_description.
-
#bank_iban ⇒ Object
Returns the value of attribute bank_iban.
-
#code ⇒ Object
Returns the value of attribute code.
-
#country ⇒ Object
Returns the value of attribute country.
-
#financials_duedays ⇒ Object
Returns the value of attribute financials_duedays.
-
#iban ⇒ Object
Returns the value of attribute iban.
-
#invoice_address ⇒ Object
Returns the value of attribute invoice_address.
-
#invoice_city ⇒ Object
Returns the value of attribute invoice_city.
-
#invoice_contact_name ⇒ Object
Returns the value of attribute invoice_contact_name.
-
#invoice_country ⇒ Object
Returns the value of attribute invoice_country.
-
#invoice_name ⇒ Object
Returns the value of attribute invoice_name.
-
#invoice_zipcode ⇒ Object
Returns the value of attribute invoice_zipcode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#shortname ⇒ Object
Returns the value of attribute shortname.
-
#vatcode ⇒ Object
Returns the value of attribute vatcode.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Debtor
constructor
A new instance of Debtor.
- #save ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Debtor
Returns a new instance of Debtor.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/twinfield/create/debtor.rb', line 9 def initialize(hash = {}) # Escape all the things. hash.each do |k, v| val = if v.is_a?(String) CGI.escapeHTML(v) elsif v.is_a?(Hash) v.each_with_object({}) { |(k1, v1), h| h[k1] = CGI.escapeHTML(v1) } else v end send(:"#{k}=", val) end end |
Instance Attribute Details
#bank_biccode ⇒ Object
Returns the value of attribute bank_biccode.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def bank_biccode @bank_biccode end |
#bank_country ⇒ Object
Returns the value of attribute bank_country.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def bank_country @bank_country end |
#bank_description ⇒ Object
Returns the value of attribute bank_description.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def bank_description @bank_description end |
#bank_iban ⇒ Object
Returns the value of attribute bank_iban.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def bank_iban @bank_iban end |
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def code @code end |
#country ⇒ Object
Returns the value of attribute country.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def country @country end |
#financials_duedays ⇒ Object
Returns the value of attribute financials_duedays.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def financials_duedays @financials_duedays end |
#iban ⇒ Object
Returns the value of attribute iban.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def iban @iban end |
#invoice_address ⇒ Object
Returns the value of attribute invoice_address.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_address @invoice_address end |
#invoice_city ⇒ Object
Returns the value of attribute invoice_city.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_city @invoice_city end |
#invoice_contact_name ⇒ Object
Returns the value of attribute invoice_contact_name.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_contact_name @invoice_contact_name end |
#invoice_country ⇒ Object
Returns the value of attribute invoice_country.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_country @invoice_country end |
#invoice_name ⇒ Object
Returns the value of attribute invoice_name.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_name @invoice_name end |
#invoice_zipcode ⇒ Object
Returns the value of attribute invoice_zipcode.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def invoice_zipcode @invoice_zipcode end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def name @name end |
#shortname ⇒ Object
Returns the value of attribute shortname.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def shortname @shortname end |
#vatcode ⇒ Object
Returns the value of attribute vatcode.
4 5 6 |
# File 'lib/twinfield/create/debtor.rb', line 4 def vatcode @vatcode end |
Instance Method Details
#save ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/twinfield/create/debtor.rb', line 26 def save response = Twinfield::Api::Process.request do %( <dimension> <office>#{Twinfield.configuration.company}</office> <type>DEB</type> <code>#{code}</code> <name>#{name}</name> <shortname>#{shortname}</shortname> <financials> <duedays>#{financials_duedays}</duedays> </financials> <addresses> <address type="invoice"> <name>#{invoice_name}</name> <country>#{invoice_country}</country> <city>#{invoice_city}</city> <postcode>#{invoice_zipcode}</postcode> <field1>#{invoice_contact_name}</field1> <field2>#{invoice_address}</field2> <field4>#{vatcode}</field4> </address> </addresses> #{bank_xml} </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 |