Skip to content

Instantly share code, notes, and snippets.

@kinsteronline
Created February 15, 2012 19:14
Show Gist options
  • Save kinsteronline/1838254 to your computer and use it in GitHub Desktop.
Save kinsteronline/1838254 to your computer and use it in GitHub Desktop.
monkey patched efax
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
@kinsteronline
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment