Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "http://rubygems.org"

gemspec
gem "rake"
gem "rake"
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ PATH
specs:
efax (1.4.2)
builder (~> 3.0.0)
hpricot (~> 0.8.1)
nokogiri (~> 1.6)

GEM
remote: http://rubygems.org/
specs:
builder (3.0.0)
hpricot (0.8.6)
builder (3.0.4)
mini_portile2 (2.0.0)
mocha (0.9.12)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
rake (0.9.2)
test-unit (2.3.2)

Expand All @@ -22,3 +24,6 @@ DEPENDENCIES
mocha (~> 0.9.12)
rake
test-unit (~> 2.3.2)

BUNDLED WITH
1.10.6
4 changes: 2 additions & 2 deletions efax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = EFax::VERSION

gem.add_runtime_dependency "builder", "~> 3.0.0"
gem.add_runtime_dependency "hpricot", "~> 0.8.1"
gem.add_runtime_dependency "builder", "~> 3.1"
gem.add_runtime_dependency "nokogiri", "~> 1.6"

gem.add_development_dependency "test-unit", "~> 2.3.2"
gem.add_development_dependency "mocha", "~> 0.9.12"
Expand Down
32 changes: 16 additions & 16 deletions lib/efax/inbound.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'hpricot'
require 'nokogiri'
require 'base64'
require 'tempfile'
require 'date'
Expand Down Expand Up @@ -27,21 +27,21 @@ class InboundPostRequest
alias_method :sender_fax_number, :ani

def initialize(xml)
doc = Hpricot(xml)
@encoded_file_contents = doc.at(:filecontents).inner_text
@file_type = doc.at(:filetype).inner_text.to_sym
@ani = doc.at(:ani).inner_text
@account_id = doc.at(:accountid).inner_text
@fax_name = doc.at(:faxname).inner_text
@csid = doc.at(:csid).inner_text
@status = doc.at(:status).inner_text.to_i
@mcfid = doc.at(:mcfid).inner_text.to_i
@page_count = doc.at(:pagecount).inner_text.to_i
@request_type = doc.at(:requesttype).inner_text
@date_received = datetime_to_time(DateTime.strptime("#{doc.at(:datereceived).inner_text} -08:00", "%m/%d/%Y %H:%M:%S %z"))
@request_date = datetime_to_time(DateTime.strptime("#{doc.at(:requestdate).inner_text} -08:00", "%m/%d/%Y %H:%M:%S %z"))
@barcodes = doc.search("//barcode/key").map { |key| key.inner_html }
@barcode_pages = doc.search("//barcode/AdditionalInfo/CodeLocation/PageNumber").map { |key| key.inner_html }
doc = Nokogiri::XML(xml)
@encoded_file_contents = doc.at(:FileContents).inner_text
@file_type = doc.at(:FileType).inner_text.to_sym
@ani = doc.at(:ANI).inner_text
@account_id = doc.at(:AccountID).inner_text
@fax_name = doc.at(:FaxName).inner_text
@csid = doc.at(:CSID).inner_text
@status = doc.at(:Status).inner_text.to_i
@mcfid = doc.at(:MCFID).inner_text.to_i
@page_count = doc.at(:PageCount).inner_text.to_i
@request_type = doc.at(:RequestType).inner_text
@date_received = datetime_to_time(DateTime.strptime("#{doc.at(:DateReceived).inner_text} -08:00", "%m/%d/%Y %H:%M:%S %z"))
@request_date = datetime_to_time(DateTime.strptime("#{doc.at(:RequestDate).inner_text} -08:00", "%m/%d/%Y %H:%M:%S %z"))
@barcodes = doc.xpath("//Barcode/Key").map { |key| key.inner_html }
@barcode_pages = doc.xpath("//Barcode/AdditionalInfo/CodeLocation/PageNumber").map { |key| key.inner_html }
end

def file_contents
Expand Down
20 changes: 10 additions & 10 deletions lib/efax/outbound.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'net/http'
require 'net/https'
require 'builder'
require 'hpricot'
require 'nokogiri'
require 'base64'

module Net #:nodoc:
Expand Down Expand Up @@ -118,13 +118,13 @@ class OutboundResponse

def initialize(response) #:nodoc:
if response.is_a? Net::HTTPOK
doc = Hpricot(response.body)
@status_code = doc.at(:statuscode).inner_text.to_i
@error_message = doc.at(:errormessage)
doc = Nokogiri::XML(response.body)
@status_code = doc.at(:StatusCode).inner_text.to_i
@error_message = doc.at(:ErrorMessage)
@error_message = @error_message.inner_text if @error_message
@error_level = doc.at(:errorlevel)
@error_level = doc.at(:ErrorLevel)
@error_level = @error_level.inner_text if @error_level
@doc_id = doc.at(:docid).inner_text
@doc_id = doc.at(:DOCID).inner_text
@doc_id = @doc_id.empty? ? nil : @doc_id
else
@status_code = RequestStatus::HTTP_FAILURE
Expand Down Expand Up @@ -178,10 +178,10 @@ class OutboundStatusResponse

def initialize(response) #:nodoc:
if response.is_a? Net::HTTPOK
doc = Hpricot(response.body)
@message = doc.at(:message).innerText
@classification = doc.at(:classification).innerText.delete('"')
@outcome = doc.at(:outcome).innerText.delete('"')
doc = Nokogiri::XML(response.body)
@message = doc.at(:Message).inner_text
@classification = doc.at(:Classification).inner_text.delete('"')
@outcome = doc.at(:Outcome).inner_text.delete('"')
if !sent_yet?(classification, outcome) || busy_signal?(classification)
@status_code = QueryStatus::PENDING
elsif @classification == "Success" && @outcome == "Success"
Expand Down