NAME

Finance::DST::FAN::Mail::Download - Automate the downloading of FAN Mail files

DESCRIPTION

Finance::DST::FAN::Mail::Download is a pluggable, object-oriented interface to DST's FAN Mail service. It does most of the legwork necessary to securely log in, download, and delete files.

While all methods and attributes are documented, please treat any methods beginning with an underscore '_' as private methods. If you are using them directly then you are most likely doing something wrong.

SYNOPSIS

use Finance::DST::FAN::Mail::Download;

my $downloader = Finance::DST::FAN::Mail::Download->new(
                     username     => 'mycompany01',
                     password     => 'oursecret3',
                     requester    => 'My Company',
                     download_dir => '/data/files/dst/fan/mail',
                 );
$downloader->download($_) for $downloader->file_list;

#want files automatically unziped ?
$downloader->load_plugin('Unzip');

#want more descriptive filenames?
$downloader->load_plugins(qw/Unzip Rename/); #order is significant...

#want multiple logical files split into multiple physical files?
$downloader->load_plugins(qw/Unzip Rename Split/); #order is significant...

ATTRIBUTES

Unless noted, the accessor (or reader for read-only attributes) is a method of the same name as the attribute. Required attributes must be passed to the constructor in a key = value> form where the key is the name of the attribute, unless otherwise noted.

username

Required read-only string. This is your FAN Mail username.

password

Required read-only string. This is your FAN Mail password.

requester

Required read-only string. This is your Requester ID.

download_dir

Required read-only string. This is the directory where your files will be downloaded to.

delete_on_fail

_delete_on_fail - writer

Boolean. Indicates whether locally created files should be deleted in the event of failure. This only applies to local files, theremote file will NEVER be deleted without an explicit call to delete.

file_list

_file_list - writer
_build_file_list - builder.

The provided builder method will connect to DST, request the available file listing, and parse the XML response to build the list.

has_file_list - predicate
clear_file_list - clearer

This lazy building read-write attribute will be automatically filled upon first request and will return an array of valid file names that can be downloaded. If you would like to refresh the list of files you may do so by clearing the attribute via the clearer method. Please note that the reader method will automatically dereference the interneal arrayref for you and will return a list, not a reference.

_base_uri

_build__base_uri - Defaults to https://filetransfer.financialtrans.com/tf/FANMail
_clear_base_uri - clearer
_has_base_uri - predicate

Lazy building read only attribute which holds a URI object with the main address of DST FAN Mail's web interface.

_user_agent

_build__user_agent - Creates a new LWP::UserAgent instance with the 'X-File-Requester' header.
_clear_user_agenti - clearer
_has_user_agent - predicate

Lazy building read only attribute which holds a LWP::UserAgent object

_encoded_login

_build__encoded_login - builder
_clear_encoded_login - clearer
_has_encoded_login - predicate

Read-only lazy-building string containing a the username and password joined by a colon and encoded in base64.

authed

is_authed - reader
_authed - writer

Boolean indicating whether the current instance has authenticated.You will probably never need to use this.

_tidx

A transaction string used to mantain state and authentication. It is initially provided by DST upon the first transaction and after that this module will handle setting it or refreshing it as necessary as well as attaching it to requests when necessary.

METHODS

new %attributes

Create a new instance of the downloader

load_plugin $plugin

load_plugins @plugins

Load additional plugins.

download $file

Download $file from DST

delete $file

Delete $file from DST's servers.

meta

See Moose

_authed_request $uri, @request_args

Make an URI request that requires authentication. This method is a thin wrapper for $self->user_agent->get() which handles all authentication details for DST. The arguments passed to it are passed through, unchanged, to get;

TODO

Tests
POE integration for async event-triggered processing
better error checking capabilities at runtime

SEE ALSO

MooseX::Object::Pluggable, Finance::DST::FAN::Mail::Download::Plugin::Unzip, Finance::DST::FAN::Mail::Download::Plugin::Rename Finance::DST::FAN::Mail::Download::Plugin::Split

AUTHOR

Guillermo Roditi (groditi) <groditi@cpan.org>

BUGS, FEATURE REQUESTS AND CONTRIBUTIONS

Google Code Project Page - http://code.google.com/p/finance-dst-fan-mail/

LICENSE

You may distribute this code under the same terms as Perl itself.