Class: Mundipagg::PostNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/mundipagg/post_notification.rb

Overview

Class who handles Mundipagg post notification XML

Class Method Summary collapse

Class Method Details

.ParseNotification(xml) ⇒ Hash<Symbol, String>

This method parse the Xml sent by Mundipagg when notify a change in a transaction.

Parameters:

  • request (String)

    XML received in the Mundipagg POST request.

Returns:

  • (Hash<Symbol, String>)

    A hash collection containing the XML data parsed.



11
12
13
14
15
16
17
# File 'lib/mundipagg/post_notification.rb', line 11

def self.ParseNotification(xml)

	nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
	xml_hash  = nori.parse(CGI::unescapeHTML(xml))

	return xml_hash
end

.to_underscore(camel_case_string) ⇒ Object

Converts a string in Camel Case format to lower case with underscore.

Parameters:

  • Example:outputs ('StatusNotification''status_notification')

    xample: ‘StatusNotification’ outputs ‘status_notification’



23
24
25
26
27
28
29
# File 'lib/mundipagg/post_notification.rb', line 23

def self.to_underscore(camel_case_string)
	return camel_case_string.gsub(/::/, '/').
		gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
		gsub(/([a-z\d])([A-Z])/,'\1_\2').
		tr("-", "_").
		downcase
end