Class: Twinfield::Customer::CollectMandate
- Inherits:
-
Object
- Object
- Twinfield::Customer::CollectMandate
- Extended by:
- Helpers::Parsers
- Defined in:
- lib/twinfield/customer.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#signaturedate ⇒ Object
Returns the value of attribute signaturedate.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(signaturedate: nil, id: nil) ⇒ CollectMandate
constructor
A new instance of CollectMandate.
- #to_h ⇒ Object (also: #to_hash)
- #to_xml ⇒ Object
Methods included from Helpers::Parsers
parse_date, parse_datetime, parse_float
Constructor Details
#initialize(signaturedate: nil, id: nil) ⇒ CollectMandate
Returns a new instance of CollectMandate.
10 11 12 13 |
# File 'lib/twinfield/customer.rb', line 10 def initialize(signaturedate: nil, id: nil) @signaturedate = signaturedate @id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/twinfield/customer.rb', line 8 def id @id end |
#signaturedate ⇒ Object
Returns the value of attribute signaturedate.
8 9 10 |
# File 'lib/twinfield/customer.rb', line 8 def signaturedate @signaturedate end |
Class Method Details
.from_xml(nokogiri) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/twinfield/customer.rb', line 29 def self.from_xml(nokogiri) obj = new obj.signaturedate = parse_date(nokogiri.css("signaturedate").text) obj.id = nokogiri.css("id").text obj end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
15 16 17 |
# File 'lib/twinfield/customer.rb', line 15 def to_h {signaturedate: signaturedate, id: id} end |
#to_xml ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/twinfield/customer.rb', line 20 def to_xml Nokogiri::XML::Builder.new do |xml| xml.collectmandate do xml.id id xml.signaturedate signaturedate&.strftime("%Y%m%d") end end.doc.root.to_xml end |