MishkaPay.File.Upload (Mishka Pay v0.0.1)

Copy Markdown View Source

A file to upload to the provider with MishkaPay.upload_file/1, such as a receipt, a download log or a screenshot that answers a dispute. The provider keeps it and answers a MishkaPay.File; its :id then goes in the dispute's evidence (MishkaPay.update_dispute/1). A guarded_struct.

  • :provider, :tenant: as for a checkout.
  • :purpose: what the file is for. :dispute_evidence, evidence for a dispute.
  • :filename: the file's name, such as "receipt.pdf"; a plain name with no folder.
  • :content_type: its MIME type, such as "application/pdf", "image/jpeg" or "image/png".
  • :content: the file's bytes. Read the file first (File.read/1); Mishka Pay never reads a path.

Each provider takes its own types and sizes, and refuses others before any request: Stripe takes dispute evidence as PDF, JPEG or PNG, up to 5 MB. inspect/1 leaves out :content.

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.File.Upload{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.File.Upload{
  content: binary(),
  content_type: String.t(),
  filename: String.t(),
  provider: String.t(),
  purpose: :dispute_evidence,
  tenant: term() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:purpose:dispute_evidenceyesvalidate(not_nil_value, enum=Atom[dispute_evidence])<br>validator {MishkaPay.File, :purpose}
:filenameString.t()yessanitize(trim) validate(not_nil_value, string, not_empty, max_len=255)<br>validator {MishkaPay.File, :filename}
:content_typeString.t()yessanitize(trim, downcase) validate(not_nil_value, string, not_empty, max_len=255)
:contentbinary()yesvalidator {MishkaPay.File, :content}

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.File.Upload{} populated from defaults + type-based fallbacks.

keys()

keys(field)