module Monzo::Client::Attachments
Overview
Exposes methods for dealing with and manipulating Attachment
s as defined in the
Attachments API documentation.
Attachment
s can be registered with a remote URL for their image content, but it is also possible to host that
image with Monzo
directly, the full flow for doing so is as follows:
- Generate a temporary upload URL, which includes a
file_url
. - Form-post the file to the upload URL.
- Register an
Attachment
with thefile_url
generated in the first step.
NOTE: This client does not perform any upload on behalf of the user, as there is nothing special about posting to the S3 bucket URL, choices regarding how to do so are left to the developer.
Direct including types
Defined in:
monzo/client/attachments.crInstance Method Summary
-
#deregister_attachment(attachment : Monzo::Attachment)
Unregisters the specified attachment.
-
#deregister_attachment(attachment_id : String)
Unregisters an
Attachment
with the specified attachment_id. -
#register_attachment(transaction_id : String, file_url : String, file_type : String)
Registers an
Attachment
against the specified transacion_id. -
#register_attachment(transaction : Monzo::Transaction, file_url : String, file_type : String)
Registers an
Attachment
against the specified transaction. -
#upload_attachment(filename : String, file_type : String)
Generates a
TemporaryAttachmentData
object.
Instance Method Detail
Unregisters the specified attachment.
account = client.accounts.first
transaction = client.transactions(account)
attachment = transaction.attachments.first
client.deregister_attachment(attachment) # => true
Unregisters an Attachment
with the specified attachment_id.
Registers an Attachment
against the specified transacion_id.
Registers an Attachment
against the specified transaction.
account = client.accounts.first
transaction = client.transactions.first
attachment = client.register_attachment(transaction, "https://www.github.com/logo.png", "image/png")
attachment # => #<Monzo::Attachment:0x110bc9700 @id="attach_ATTACHMENTID", @user_id="user_USERID", ...>
Generates a TemporaryAttachmentData
object.
data = client.upload_attachment("avatar.png", "image/png")
data # => #<Monzo::TemporaryAttachmentData:0x10e76f540 @file_url="...-avatar.png", @upload_url="...avatar.png">