<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># NAME

Business::Monzo - Perl library for interacting with the Monzo API
(https://api.monzo.com)

&lt;div&gt;

    &lt;a href='https://travis-ci.org/leejo/business-monzo?branch=master'&gt;&lt;img src='https://travis-ci.org/leejo/business-monzo.svg?branch=master' alt='Build Status' /&gt;&lt;/a&gt;
    &lt;a href='https://coveralls.io/r/leejo/business-monzo?branch=master'&gt;&lt;img src='https://coveralls.io/repos/leejo/business-monzo/badge.png?branch=master' alt='Coverage Status' /&gt;&lt;/a&gt;
&lt;/div&gt;

# VERSION

0.08

# DESCRIPTION

Business::Monzo is a library for easy interface to the Monzo banking API,
it implements all of the functionality currently found in the service's API
documentation: [https://monzo.com/docs](https://monzo.com/docs)

**You should refer to the official Monzo API documentation in conjunction**
**with this perldoc**, as the official API documentation explains in more depth
some of the functionality including required / optional parameters for certain
methods.

Please note this library is very much a work in progress, as is the Monzo API.
Also note the Monzo were previously called Mondo, so if you see any references
to Mondo they are either typos or historical references that have not yet been
updated to reflect the changes.

All objects within the Business::Monzo namespace are immutable. Calls to methods
will, for the most part, return new instances of objects.

# SYNOPSIS

    my $monzo = Business::Monzo-&gt;new(
        token   =&gt; $token, # REQUIRED
        api_url =&gt; $url,   # optional
    );

    # transaction related information
    my @transactions = $monzo-&gt;transactions( account_id =&gt; $account_id );

    my $Transaction  = $monzo-&gt;transaction( id =&gt; 1 );

    $Transaction-&gt;annotate(
        foo =&gt; 'bar',
        baz =&gt; 'boz,
    );

    my $annotations = $Transaction-&gt;annotations;

    # account related information
    my @accounts = $monzo-&gt;accounts;

    foreach my $Account ( @accounts ) {

        my @transactions = $Account-&gt;transactions;

        $Account-&gt;add_feed_item(
            params =&gt; {
                title     =&gt; 'My Feed Item',
                image_url =&gt; 'http://...',
            }
        );

        # balance information
        my $Balance = $Account-&gt;balance;

        # webhooks
        my @webhooks = $Account-&gt;webhooks;

        my $Webhook = $Account-&gt;register_webhook(
            callback_url =&gt; 'http://www.foo.com',
        );

        $Webhook-&gt;delete
    }

    # attachments
    my $Attachment = $monzo-&gt;upload_attachment(
        file_name =&gt; 'foo.png',
        file_type =&gt; 'image/png',
    );

    $Attachment-&gt;register(
        external_id =&gt; 'my_id'
    );

    $Attachment-&gt;deregister;

# ERROR HANDLING

Any problems or errors will result in a Business::Monzo::Exception
object being thrown, so you should wrap any calls to the library in the
appropriate error catching code (ideally a module from CPAN):

    try {
        ...
    }
    catch ( Business::Monzo::Exception $e ) {
        # error specific to Business::Monzo
        ...
        say $e-&gt;message;  # error message
        say $e-&gt;code;     # HTTP status code
        say $e-&gt;response; # HTTP status message

        # -&gt;request may not always be present
        say $e-&gt;request-&gt;{path}    if $e-&gt;request
        say $e-&gt;request-&gt;{params}  if $e-&gt;request
        say $e-&gt;request-&gt;{headers} if $e-&gt;request
        say $e-&gt;request-&gt;{content} if $e-&gt;request
    }
    catch ( $e ) {
        # some other failure?
        ...
    }

You can view some useful debugging information by setting the MONZO\_DEBUG
env varible, this will show the calls to the Monzo endpoints as well as a
stack trace in the event of exceptions:

    $ENV{MONZO_DEBUG} = 1;

# ATTRIBUTES

## token

Your Monzo access token, this is required

## api\_url

The Monzo url, which will default to https://api.monzo.com

## client

A Business::Monzo::Client object, this will be constructed for you so
you shouldn't need to pass this

# METHODS

In the following %query\_params refers to the possible query params as shown in
the Monzo API documentation. For example: limit=100.

    # transactions in the previous month
    my @transactions = $monzo-&gt;transactions(
        since =&gt; DateTime-&gt;now-&gt;subtract( months =&gt; 1 ),
    );

## transactions

    $monzo-&gt;transactions( %query_params );

Get a list of transactions. Will return a list of [Business::Monzo::Transaction](https://metacpan.org/pod/Business::Monzo::Transaction)
objects. Note you must supply an account\_id in the params hash;

## balance

    my $Balance = $monzo-&gt;balance( account_id =&gt; $account_id );

Get an account balance Returns a [Business::Monzo::Balance](https://metacpan.org/pod/Business::Monzo::Balance) object.

## transaction

    my $Transaction = $monzo-&gt;transaction(
        id     =&gt; $id,
        expand =&gt; 'merchant'
    );

Get a transaction. Will return a [Business::Monzo::Transaction](https://metacpan.org/pod/Business::Monzo::Transaction) object

## accounts

    $monzo-&gt;accounts;

Get a list of accounts. Will return a list of [Business::Monzo::Account](https://metacpan.org/pod/Business::Monzo::Account)
objects

# EXAMPLES

See the t/002\_end\_to\_end.t test included with this distribution. you can run
this test against the Monzo emulator by running end\_to\_end\_emulated.sh (this
is advised, don't run it against a live endpoint).

# SEE ALSO

[Business::Monzo::Account](https://metacpan.org/pod/Business::Monzo::Account)

[Business::Monzo::Attachment](https://metacpan.org/pod/Business::Monzo::Attachment)

[Business::Monzo::Balance](https://metacpan.org/pod/Business::Monzo::Balance)

[Business::Monzo::Transaction](https://metacpan.org/pod/Business::Monzo::Transaction)

[Business::Monzo::Webhook](https://metacpan.org/pod/Business::Monzo::Webhook)

# AUTHOR

Lee Johnson - `leejo@cpan.org`

# LICENSE

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. If you would like to contribute documentation,
features, bug fixes, or anything else then please raise an issue / pull request:

    https://github.com/leejo/business-monzo
</pre></body></html>