Sha256: 1fc8f18d0aa5660f28560bc04d4a0dd2a3e754be5a50366ddceeb42b3f003453
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
module WirecardSepa module DirectDebit class Response attr_reader :xml, :request def self.for_request(request) new(request.body, request: request) end def initialize(xml, request: nil) @xml = xml @request = request end def params { success: success?, transaction_id: transaction_id, transaction_state: transaction_state, status_code: status_code, status_description: status_description, due_date: due_date, reference_id: provider_transaction_reference_id, original_response_xml: xml, } end def success? transaction_state == 'success' end def transaction_id value_at 'transaction-id' end def transaction_state value_at 'transaction-state' end def status_code value_at 'status', attribute: :code end def status_description value_at 'status', attribute: :description end def due_date value_at 'due-date' end def provider_transaction_reference_id value_at 'provider-transaction-reference-id' end def to_s xml end private # Returns the text of a node with the given position. If # an additional attribute is given, this attribute is returned # instead. # This method provides mainly nil-safeness. def value_at(position, attribute: nil) node = xml_doc.at_css(position) node or return attribute ? node[attribute] : node.text end def xml_doc @xml_doc ||= Nokogiri::XML xml end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wirecard_sepa-0.1.6 | lib/wirecard_sepa/direct_debit/response.rb |