Class: Wesabe::Upload
Overview
Encapsulates an upload and allows uploading files to wesabe.com.
Defined Under Namespace
Classes: Exception, StatementError
Instance Attribute Summary collapse
-
#accounts ⇒ Object
The accounts this upload is associated with.
-
#financial_institution ⇒ Object
The financial institution this upload is associated with.
-
#statement ⇒ Object
The raw statement to post.
-
#status ⇒ Object
Whether this upload succeeded or failed, or
nil
if it hasn’t started.
Attributes inherited from BaseModel
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Determines whether this upload failed or not.
-
#initialize {|upload| ... } ⇒ Upload
constructor
Initializes a
Wesabe::Upload
and yields itself. -
#successful? ⇒ Boolean
Determines whether this upload succeeded or not.
-
#upload! ⇒ Object
Uploads the statement to Wesabe, raising on problems.
Methods inherited from BaseModel
Methods included from Util
Constructor Details
#initialize {|upload| ... } ⇒ Upload
Initializes a Wesabe::Upload
and yields itself.
16 17 18 |
# File 'lib/wesabe/upload.rb', line 16 def initialize yield self if block_given? end |
Instance Attribute Details
#accounts ⇒ Object
The accounts this upload is associated with.
4 5 6 |
# File 'lib/wesabe/upload.rb', line 4 def accounts @accounts end |
#financial_institution ⇒ Object
The financial institution this upload is associated with.
6 7 8 |
# File 'lib/wesabe/upload.rb', line 6 def financial_institution @financial_institution end |
#statement ⇒ Object
The raw statement to post.
10 11 12 |
# File 'lib/wesabe/upload.rb', line 10 def statement @statement end |
#status ⇒ Object
Whether this upload succeeded or failed, or nil
if it hasn’t started.
8 9 10 |
# File 'lib/wesabe/upload.rb', line 8 def status @status end |
Instance Method Details
#failed? ⇒ Boolean
Determines whether this upload failed or not.
55 56 57 |
# File 'lib/wesabe/upload.rb', line 55 def failed? !successful? end |
#successful? ⇒ Boolean
Determines whether this upload succeeded or not.
47 48 49 |
# File 'lib/wesabe/upload.rb', line 47 def successful? status == "processed" end |
#upload! ⇒ Object
Uploads the statement to Wesabe, raising on problems. It can raise anything that is raised by Wesabe::Request#execute in addition to the list below.
begin
upload.upload!
rescue Wesabe::Upload::StatementError => e
$stderr.puts "The file you chose to upload couldn't be imported."
$stderr.puts "This is what Wesabe said: #{e.}"
rescue Wesabe::Request::Exception
$stderr.puts "There was a problem communicating with Wesabe."
end
37 38 39 40 41 |
# File 'lib/wesabe/upload.rb', line 37 def upload! process_response do post(:url => '/rest/upload/statement', :payload => pack_statement) end end |