Class: Twinfield::Customer::Bank
- Inherits:
-
Object
- Object
- Twinfield::Customer::Bank
- Defined in:
- lib/twinfield/customer.rb
Instance Attribute Summary collapse
-
#accountnumber ⇒ Object
Returns the value of attribute accountnumber.
-
#address ⇒ Object
Returns the value of attribute address.
-
#ascription ⇒ Object
Returns the value of attribute ascription.
-
#bankname ⇒ Object
Returns the value of attribute bankname.
-
#biccode ⇒ Object
Returns the value of attribute biccode.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#default ⇒ Object
Returns the value of attribute default.
-
#iban ⇒ Object
Returns the value of attribute iban.
-
#id ⇒ Object
Returns the value of attribute id.
-
#natbiccode ⇒ Object
Returns the value of attribute natbiccode.
-
#postcode ⇒ Object
Returns the value of attribute postcode.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ascription: nil, accountnumber: nil, address: nil, bankname: nil, biccode: nil, city: nil, country: nil, iban: nil, natbiccode: nil, postcode: nil, state: nil, id: nil, default: nil) ⇒ Bank
constructor
A new instance of Bank.
- #to_h ⇒ Object (also: #to_hash)
- #to_xml ⇒ Object
Constructor Details
#initialize(ascription: nil, accountnumber: nil, address: nil, bankname: nil, biccode: nil, city: nil, country: nil, iban: nil, natbiccode: nil, postcode: nil, state: nil, id: nil, default: nil) ⇒ Bank
Returns a new instance of Bank.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/twinfield/customer.rb', line 70 def initialize(ascription: nil, accountnumber: nil, address: nil, bankname: nil, biccode: nil, city: nil, country: nil, iban: nil, natbiccode: nil, postcode: nil, state: nil, id: nil, default: nil) @ascription = ascription @accountnumber = accountnumber @address = (address.is_a?(Hash) && address != {}) ? Address.new(**address) : address @bankname = bankname @biccode = biccode @city = city @country = country @iban = iban @natbiccode = natbiccode @postcode = postcode @state = state @default = ["true", true, 1, "1"].include?(default) @id = id end |
Instance Attribute Details
#accountnumber ⇒ Object
Returns the value of attribute accountnumber.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def accountnumber @accountnumber end |
#address ⇒ Object
Returns the value of attribute address.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def address @address end |
#ascription ⇒ Object
Returns the value of attribute ascription.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def ascription @ascription end |
#bankname ⇒ Object
Returns the value of attribute bankname.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def bankname @bankname end |
#biccode ⇒ Object
Returns the value of attribute biccode.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def biccode @biccode end |
#city ⇒ Object
Returns the value of attribute city.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def country @country end |
#default ⇒ Object
Returns the value of attribute default.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def default @default end |
#iban ⇒ Object
Returns the value of attribute iban.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def iban @iban end |
#id ⇒ Object
Returns the value of attribute id.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def id @id end |
#natbiccode ⇒ Object
Returns the value of attribute natbiccode.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def natbiccode @natbiccode end |
#postcode ⇒ Object
Returns the value of attribute postcode.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def postcode @postcode end |
#state ⇒ Object
Returns the value of attribute state.
68 69 70 |
# File 'lib/twinfield/customer.rb', line 68 def state @state end |
Class Method Details
.from_xml(nokogiri_xml) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/twinfield/customer.rb', line 126 def self.from_xml(nokogiri_xml) obj = new(id: nokogiri_xml.attributes["id"].text, default: nokogiri_xml.attributes["default"].text) obj.ascription = nokogiri_xml.css("ascription").text obj.accountnumber = nokogiri_xml.css("accountnumber").text obj.address = Address.from_xml(nokogiri_xml.css("address")[0]) if nokogiri_xml.css("address")[0] && nokogiri_xml.css("address")[0].children.count > 0 obj.bankname = nokogiri_xml.css("bankname").text obj.biccode = nokogiri_xml.css("biccode").text obj.city = nokogiri_xml.css("city").text obj.country = nokogiri_xml.css("country").text obj.iban = nokogiri_xml.css("iban").text obj.natbiccode = nokogiri_xml.css("natbiccode").text obj.postcode = nokogiri_xml.css("postcode").text obj.state = nokogiri_xml.css("state").text obj end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/twinfield/customer.rb', line 86 def to_h { address: address.to_h, ascription: ascription, accountnumber: accountnumber, bankname: bankname, biccode: biccode, city: city, country: country, iban: iban, natbiccode: natbiccode, postcode: postcode, state: state, id: id, default: default } end |
#to_xml ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/twinfield/customer.rb', line 105 def to_xml Nokogiri::XML::Builder.new do |xml| attributes = {default: default} attributes[:id] = id if id xml.bank(attributes) do xml.ascription ascription xml.accountnumber accountnumber xml.address address xml.bankname bankname xml.biccode biccode xml.city city xml.country country xml.iban iban xml.natbiccode natbiccode xml.postcode postcode xml.state state end end.doc.root.to_xml end |