Class: EFax::InboundPostRequest
- Inherits:
-
Object
- Object
- EFax::InboundPostRequest
- Defined in:
- lib/efax/inbound.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#ani ⇒ Object
(also: #sender_fax_number)
readonly
Returns the value of attribute ani.
-
#barcode_pages ⇒ Object
readonly
Returns the value of attribute barcode_pages.
-
#barcodes ⇒ Object
readonly
Returns the value of attribute barcodes.
-
#csid ⇒ Object
readonly
Returns the value of attribute csid.
-
#date_received ⇒ Object
readonly
Returns the value of attribute date_received.
-
#encoded_file_contents ⇒ Object
readonly
Returns the value of attribute encoded_file_contents.
-
#fax_name ⇒ Object
readonly
Returns the value of attribute fax_name.
-
#file_type ⇒ Object
readonly
Returns the value of attribute file_type.
-
#mcfid ⇒ Object
readonly
Returns the value of attribute mcfid.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#request_date ⇒ Object
readonly
Returns the value of attribute request_date.
-
#request_type ⇒ Object
readonly
Returns the value of attribute request_type.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #file ⇒ Object
- #file_contents ⇒ Object
-
#initialize(xml) ⇒ InboundPostRequest
constructor
A new instance of InboundPostRequest.
- #post_successful_message ⇒ Object
Constructor Details
#initialize(xml) ⇒ InboundPostRequest
Returns a new instance of InboundPostRequest.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/efax/inbound.rb', line 29 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 } end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def account_id @account_id end |
#ani ⇒ Object (readonly) Also known as: sender_fax_number
Returns the value of attribute ani.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def ani @ani end |
#barcode_pages ⇒ Object (readonly)
Returns the value of attribute barcode_pages.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def @barcode_pages end |
#barcodes ⇒ Object (readonly)
Returns the value of attribute barcodes.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def @barcodes end |
#csid ⇒ Object (readonly)
Returns the value of attribute csid.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def csid @csid end |
#date_received ⇒ Object (readonly)
Returns the value of attribute date_received.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def date_received @date_received end |
#encoded_file_contents ⇒ Object (readonly)
Returns the value of attribute encoded_file_contents.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def encoded_file_contents @encoded_file_contents end |
#fax_name ⇒ Object (readonly)
Returns the value of attribute fax_name.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def fax_name @fax_name end |
#file_type ⇒ Object (readonly)
Returns the value of attribute file_type.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def file_type @file_type end |
#mcfid ⇒ Object (readonly)
Returns the value of attribute mcfid.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def mcfid @mcfid end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def page_count @page_count end |
#request_date ⇒ Object (readonly)
Returns the value of attribute request_date.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def request_date @request_date end |
#request_type ⇒ Object (readonly)
Returns the value of attribute request_type.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def request_type @request_type end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
12 13 14 |
# File 'lib/efax/inbound.rb', line 12 def status @status end |
Class Method Details
.receive_by_params(params) ⇒ Object
68 69 70 |
# File 'lib/efax/inbound.rb', line 68 def self.receive_by_params(params) receive_by_xml(params[:xml] || params["xml"]) end |
.receive_by_xml(xml) ⇒ Object
72 73 74 |
# File 'lib/efax/inbound.rb', line 72 def self.receive_by_xml(xml) new(xml) end |
Instance Method Details
#file ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/efax/inbound.rb', line 51 def file @file ||= begin if defined?(Encoding) file = Tempfile.new(fax_name, {:encoding => 'ascii-8bit'}) else file = Tempfile.new(fax_name) end file << file_contents file.rewind file end end |
#file_contents ⇒ Object
47 48 49 |
# File 'lib/efax/inbound.rb', line 47 def file_contents @file_contents ||= Base64.decode64(encoded_file_contents) end |
#post_successful_message ⇒ Object
64 65 66 |
# File 'lib/efax/inbound.rb', line 64 def "Post Successful" end |