Finance::OFX::Response - An OFX-specific subclass of L<HTTP::Response>.


p5-Finance-OFX documentation Contained in the p5-Finance-OFX distribution.

Index


Code Index:

NAME

Top

Finance::OFX::Response - An OFX-specific subclass of HTTP::Response.

SYNOPSIS

Top

 use Finance::OFX::Response

 my $r = OFX::Response->from_http_response($response);

DESCRIPTION

Top

Finance::OFX::Response encapsulates information about an OFX Financial Institution.

CONSTRUCTOR

Top

$r = Finance::OFX::Response->new( %options )

Constructs a new Finance::OFX::Response object and returns it. This is merely a default constructor that does nothing in particular. Don't use it.

$r = Finance::OFX::Response->from_http_response( $response )

Converts the given HTTP::Response object into an Finance::OFX::Response object and uses Finance::OFX::Parse to parse the response content.

ATTRIBUTES

Top

$r->ofx
$r->ofx( $fid )

Get/Set the OFX branch of the parsed content tree.

$r->ofx_header
$r->ofx_header( $fi )

Get/Set the OFX header branch of the parsed content tree.

$r->signon_status_code( $fi )

Get the status code from the SONRS block.

SEE ALSO

Top

Finance::OFX::Parse HTTP::Response http://ofx.net

WARNING

Top

From Finance::Bank::LloydsTSB:

This is code for online banking, and that means your money, and that means BE CAREFUL. You are encouraged, nay, expected, to audit the source of this module yourself to reassure yourself that I am not doing anything untoward with your banking data. This software is useful to me, but is provided under NO GUARANTEE, explicit or implied.

AUTHOR

Top

Brandon Fosdick, <bfoz@bfoz.net>

COPYRIGHT AND LICENSE

Top


p5-Finance-OFX documentation Contained in the p5-Finance-OFX distribution.

# Filename: Response.pm
#
# OFX response
# http://www.ofx.net/
# 
# Created February 16, 2008  Brandon Fosdick <bfoz@bfoz.net>
#
# Copyright 2008 Brandon Fosdick <bfoz@bfoz.net> (BSD License)
#
# $Id: Response.pm,v 1.2 2008/03/04 04:22:27 bfoz Exp $

package Finance::OFX::Response;

use strict;
use warnings;
use vars qw($VERSION);
use base qw(HTTP::Response);

$VERSION = sprintf("%d.%03d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);

use Finance::OFX::Parse;

sub new
{
    my ($this, %options) = @_;
    my $class = ref($this) || $this;
    my $self = $class->SUPER::new(%options);
    bless $self, $class;
    return $self;
}

# Create a new OFX::Response from an HTTP::Response object
# NOTE: Re-blesses the passed reference
sub from_http_response
{
    my ($this, $self) = @_;
    my $class = ref($this) || $this;
    bless $self, $class;

    return $self unless $self->is_success;

    # Parse the HTTP response into an OFX tree
    $self->{tree} = Finance::OFX::Parse::parse($self->content);
    $self->{ofx} = $self->{tree}{ofx};
    $self->{ofxHeader} = $self->{tree}{header};

    return $self;
}

sub ofx
{
    my $s = shift;
    $s->{ofx} = shift if scalar @_;
    $s->{ofx};
}

sub ofx_header
{
    my $s = shift;
    $s->{ofxHeader} = shift if scalar @_;
    $s->{ofxHeader};
}

sub signonInstitution
{
    my $s = shift;
    return $s->{ofx}{signonmsgsrsv1}{sonrs}{fi};
}

sub signon_status_code
{
    my $s = shift;
    return $s->{ofx}{signonmsgsrsv1}{sonrs}{status}{code};
}

1;

__END__