lib/dineromail/status_report.rb in dineromail-0.1.1 vs lib/dineromail/status_report.rb in dineromail-0.1.2
- old
+ new
@@ -19,20 +19,29 @@
INVALID_REQUEST_TYPE_STATUS = 5
INVALID_TRANSACTION_ID_REQUEST_STATUS = 6
INVALID_PASSWORD_OR_ACCOUNT_NUMBER_REQUEST_STATUS = 7
TRANSACTION_NOT_FOUND_REQUEST_STATUS = 8
+
def valid_report?
report_status == VALID_REPORT_STATUS
end
- def self.get_report_for(transaction_id)
- account_number = Dineromail.configuration.account_number
- password = Dineromail.configuration.password
- ipn_url = Dineromail.configuration.ipn_webservice_url
- request_data = "<REPORTE>
+ def self.get_report_for(transaction_id,options = {})
+ options = options.symbolize_keys
+ ipn_url = options[:ipn_webservice_url] || Dineromail.configuration.ipn_webservice_url
+ request_data = xml_request_for(transaction_id,options)
+ response = HTTParty.get ipn_url , :query => {:data => request_data}
+ self.parse response.body
+ end
+
+ def self.xml_request_for(transaction_id,options = {})
+ options = options.symbolize_keys
+ account_number = options[:account_number] || Dineromail.configuration.account_number
+ password = options[:password] || Dineromail.configuration.password
+ "<REPORTE>
<NROCTA>#{account_number}</NROCTA>
<DETALLE>
<CONSULTA>
<CLAVE>#{password}</CLAVE>
<TIPO>1</TIPO>
@@ -40,11 +49,9 @@
<ID>#{transaction_id}</ID>
</OPERACIONES>
</CONSULTA>
</DETALLE>
</REPORTE>"
- response = HTTParty.get ipn_url , :query => {:data => request_data}
- self.parse response.body
end
end
end
\ No newline at end of file