# `MishkaPay.File`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/file.ex#L5)

A file the provider keeps (`file_...` at Stripe), uploaded with `MishkaPay.upload_file/1` or read
with `MishkaPay.fetch_file/3`. Put its `:id` in a dispute's evidence to send it to the bank. A
guarded_struct the provider fills in.

  * `:id`: the provider's id of the file.
  * `:purpose`: `:dispute_evidence`, or `:other` for a file kept for something else.
  * `:filename`, `:size` (in bytes), `:type` (the provider's word for its format, such as
    `"pdf"` or `"png"`).
  * `:url`: where the provider serves its bytes, when it does. At Stripe this address needs the
    secret key; `MishkaPay.file_link/4` makes one a page can show.
  * `:expires_at`: when the provider deletes it (Stripe keeps dispute evidence for 9 months).
  * `:created_at`.

# `t`

```elixir
@type t() :: %MishkaPay.File{
  created_at: DateTime.t() | nil,
  expires_at: DateTime.t() | nil,
  filename: String.t() | nil,
  id: String.t(),
  link: MishkaPay.File.Link.t() | nil,
  provider: String.t(),
  purpose: atom() | nil,
  size: non_neg_integer() | nil,
  tenant: term() | nil,
  type: String.t() | nil,
  upload: MishkaPay.File.Upload.t() | nil,
  url: String.t() | nil
}
```

The struct that `builder/1` returns.

| Field | Type | Required | Default | Description | Derives |
| --- | --- | --- | --- | --- | --- |
| `:provider` | `String.t()` | yes |  |  | `validate(not_nil_value, string)` |
| `:tenant` | `term()` \| `nil` | no |  |  |  |
| `:id` | `String.t()` | yes |  |  | `validate(not_nil_value, string, not_empty)` |
| `:purpose` | `atom()` \| `nil` | no |  |  | `validate(enum=Atom[dispute_evidence::other])` |
| `:filename` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:size` | `non_neg_integer()` \| `nil` | no |  |  | `validate(integer)` |
| `:type` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:url` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:expires_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:created_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:link` | [`MishkaPay.File.Link.t()`](`t:MishkaPay.File.Link.t/0`) \| `nil` | no |  | A public address of a `MishkaPay.File`, made with `MishkaPay.file_link/4`: anyone with `:url` can open the file without a key, so a site can show it to a person, until `:expires_at`. A guarded_struct the provider fills in. |  |
| `:upload` | [`MishkaPay.File.Upload.t()`](`t:MishkaPay.File.Upload.t/0`) \| `nil` | no |  | 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. |  |

# `builder`

# `enforce_keys`

# `enforce_keys`

# `example`

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

# `keys`

# `keys`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
