Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code block indentation for docs #455

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/bamboo/attachment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ defmodule Bamboo.Attachment do
Creates a new Attachment

Examples:
Bamboo.Attachment.new("/path/to/attachment.png")
Bamboo.Attachment.new("/path/to/attachment.png", filename: "image.png")
Bamboo.Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png")
Bamboo.Attachment.new(params["file"]) # Where params["file"] is a %Plug.Upload

Bamboo.Attachment.new("/path/to/attachment.png")
Bamboo.Attachment.new("/path/to/attachment.png", filename: "image.png")
Bamboo.Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png")
Bamboo.Attachment.new(params["file"]) # Where params["file"] is a %Plug.Upload
"""
def new(path, opts \\ [])

Expand Down
36 changes: 20 additions & 16 deletions lib/bamboo/email.ex
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,22 @@ defmodule Bamboo.Email do
end

@doc ~S"""
Adds an data attachment to the email
Adds a data attachment to the email

## Example
put_attachment(email, %Bamboo.Attachment{})

put_attachment(email, %Bamboo.Attachment{})

Requires the fields filename and data of the %Bamboo.Attachment{} struct to be set.

## Example
def create(conn, params) do
#...
email
|> put_attachment(%Bamboo.Attachment{filename: "event.ics", data: "BEGIN:VCALENDAR..."})
#...
end

def create(conn, params) do
#...
email
|> put_attachment(%Bamboo.Attachment{filename: "event.ics", data: "BEGIN:VCALENDAR..."})
#...
end
"""
def put_attachment(%__MODULE__{attachments: _}, %Attachment{filename: nil} = attachment) do
raise "You must provide a filename for the attachment, instead got: #{inspect(attachment)}"
Expand All @@ -231,22 +233,24 @@ defmodule Bamboo.Email do
end

@doc ~S"""
Adds an file attachment to the email
Adds a file attachment to the email

## Example
put_attachment(email, path, opts \\ [])

put_attachment(email, path, opts \\ [])

Accepts `filename: <name>` and `content_type: <type>` options.

If you are using Plug, it accepts a Plug.Upload struct

## Example
def create(conn, params) do
#...
email
|> put_attachment(params["file"])
#...
end

def create(conn, params) do
#...
email
|> put_attachment(params["file"])
#...
end
"""
def put_attachment(%__MODULE__{attachments: attachments} = email, path, opts \\ []) do
%{email | attachments: [Bamboo.Attachment.new(path, opts) | attachments]}
Expand Down