NAME

Business::Monzo::Attachment

DESCRIPTION

A class for a Monzo attachment, extends Business::Monzo::Resource

ATTRIBUTES

The Attachment class has the following attributes (with their type).

id (Str)
user_id (Str)
external_id (Str)
upload_url (Str)
file_name (Str)
file_url (Str)
file_type (Str)
created (DateTime)

Note that when when a Str is passed to ->created this will be coerced to a DateTime object.

Operations on an attachment

upload

Gets the upload_url and file_url for the given file_name and file_type. Returns a new Business::Monzo::Attachment object with the attributes file_name, file_type, file_url, and upload_url populated. Note the required parameters:

my $file_details = $Attachment->upload(
    file_name => 'foo.png',   # REQUIRED
    file_type => 'image/png', # REQUIRED
);

TODO: should probably make this easier - upload should actually upload a given file (file handle?)

register

Registers an attachment against an entity (transaction, etc). Returns a new Business::Monzo::Attachment object with the details populated

my $file_details = $Attachment->webhooks(
    # the following are REQUIRED if not set on $Attachment
    file_url    => 'http://www.example.com/foo.png',  # REQUIRED
    file_type   => 'image/png',                       # REQUIRED

    # one of the following REQUIRED:
    external_id => $id,
    entity      => $object # Business::Monzo:: - Transaction, Account, etc
);

deregister

Removes an attachment

$attachment->deregister;

SEE ALSO

Business::Monzo

Business::Monzo::Resource

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