Created
February 15, 2012 19:14
-
-
Save kinsteronline/1838254 to your computer and use it in GitHub Desktop.
monkey patched efax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EFax | |
class QueryStatus | |
RESOURCE_NOT_FOUND = 2 | |
end | |
class OutboundStatusResponse | |
alias_method :original_initialize, :initialize | |
def initialize(response) | |
unless response.is_a? Net::HTTPOK | |
@status_code = QueryStatus::HTTP_FAILURE | |
@error_message = "HTTP request failed (#{response.code})" | |
return | |
end | |
doc = Hpricot(response.body) | |
err_xml = doc.search("/outboundresponse/transmission/response") | |
if not err_xml.empty? | |
@classification = @outcome = "Not Found" | |
@status_code = EFax::QueryStatus::RESOURCE_NOT_FOUND | |
@message = doc.at(:errormessage).inner_text | |
else | |
original_initialize(response) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/szimek/efax/blob/master/lib/efax/outbound.rb