Class: Twinfield::Customer::CollectMandate

Inherits:
Object
  • Object
show all
Extended by:
Helpers::Parsers
Defined in:
lib/twinfield/customer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/twinfield/customer.rb', line 8

def id
  @id
end

#signaturedateObject

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_hObject Also known as: to_hash



15
16
17
# File 'lib/twinfield/customer.rb', line 15

def to_h
  {signaturedate: signaturedate, id: id}
end

#to_xmlObject



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