Skip to content
Open
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
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Used by "mix format"
[
inputs: ["lib/**/*.ex", "test/**/*.{ex,exs}"]
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
36 changes: 29 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
.idea/
sendgridelixir.iml
/_build
/cover
/deps
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez
/doc
.DS_Store

# Ignore package tarball (built via "mix hex.build").
sendgrid_elixir-*.tar

# Temporary files for e.g. tests.
/tmp

# Misc.
.idea/
sendgridelixir.iml
.DS_Store
30 changes: 15 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 2.0.0 (2019-3-15)
## 2.0.0 (2019-03-15)

### Enhancements
* Switch from using `HTTPoison` to using `Tesla`
Expand All @@ -9,7 +9,7 @@
* An API key can be set manually for any API call as a keyword option, bypassing
the need for a global API key
* An API key can be set with the `{:system, "ENV_VAR"}` to use values at runtime
* Add dialyzer for validing typespecs
* Add Dialyzer for validating typespecs
* Add support for dynamic template data
* Add struct for handling Contact Recipient encoding
* Working config added for testing
Expand All @@ -25,36 +25,36 @@
`SendGrid.Contacts.Recipient.build/2`
* `SendGrid.Contacts.Lists.add` returns `{:ok, map()}` instead of `{:ok, integer()}`.

## 1.8.0 (2018-1-18)
## 1.8.0 (2018-01-18)

### Enhancements
* Raise runtime error whenever API isn't configured whenever making an API call

### Bug Fixes
* custom headers are properly sent when V3 of the SendGrid API

## 1.7.0 (2017-9-11)
## 1.7.0 (2017-09-11)

### Enhancements
* Add `add/1`, `all_recipients/3`, and `delete_recipient/2` to `SendGrid.Contacts.Lists`
* Remove compile warnings for `Phoenix.View`

## 1.6.0 (2017-7-14)
## 1.6.0 (2017-07-14)

### Enhancements
* Relax dependency versions
* add `put_phoenix_layout/2` in `SendGrid.Email` to render views in
### Breaking Changes
* `put_phoenix_template/3` now expects an atom for implicit template rendering

## 1.5.0 (2017-7-3)
## 1.5.0 (2017-07-3)

### Enhancements
* update docs
* upgrade to Elixir 1.4
* add support for Phoenix Views

## 1.4.0 (2017-2-15)
## 1.4.0 (2017-02-15)

### Enhancements
* update `httpoison` to 0.11.0 and `poison` to 3.0
Expand All @@ -66,23 +66,23 @@
* add `add_custom_arg` for custom arguments
* remove `raise` when no API key is provided at compile-time

## 1.2.0 (2016-9-28)
## 1.2.0 (2016-09-28)

### Enhancements
* add `add_attachment` for attachments
* bump `:poison` version to 2

## 1.1.0 (2016-8-30)
## 1.1.0 (2016-08-30)

### Enhancements
* add `add_header` to be sent with an email

## 1.0.3 (2016-8-3)
## 1.0.3 (2016-08-03)

### Bug Fixes
* replace documentation using to `put_to` with `add_to`

## 1.0.2 (2016-7-20)
## 1.0.2 (2016-07-20)

### Enhancements
* [Mailer] sandbox mode is fetched during runtime instead of compile time
Expand All @@ -95,7 +95,7 @@
### Bug Fixes
* [Email] Make an exposed method private

## 1.0.0 (2016-7-15)
## 1.0.0 (2016-07-15)

### Enhancements
* [Email] multiple TO recipients can be added with `add_to/2` and `add_to/3`
Expand All @@ -111,12 +111,12 @@
* `put_from_name/2` no longer exists; use `put_from/3` and set the **from_name** as the third param
* `delete_cc/2` no longer exists

## 0.1.1 (2016-7-5)
## 0.1.1 (2016-07-05)

### Enhancements
* Updated HTTPoison version for less compiler warnings when using Elixir 1.3

## 0.1.0 (2016-5-22)
## 0.1.0 (2016-05-22)

### Enhancements
* Added some API to add email addresses for marketing campaigns
Expand All @@ -131,7 +131,7 @@ def application do
end
```

## 0.2.0 (2016-5-22)
## 0.2.0 (2016-05-22)

### Bug Fixes
* Updated some docs
20 changes: 17 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (c) 2016 Alex Garibay

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# SendGrid

A wrapper for SendGrid's API to create composable emails.
Check the [docs](https://hexdocs.pm/sendgrid/) for complete usage.
[![Module Version](https://img.shields.io/hexpm/v/sendgrid.svg)](https://hex.pm/packages/sendgrid)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/sendgrid/)
[![Total Download](https://img.shields.io/hexpm/dt/sendgrid.svg)](https://hex.pm/packages/sendgrid)
[![License](https://img.shields.io/hexpm/l/sendgrid.svg)](https://github.com/alexgaribay/sendgrid_elixir/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/alexgaribay/sendgrid_elixir.svg)](https://github.com/alexgaribay/sendgrid_elixir/commits/master)

An Elixir wrapper for SendGrid's API to create composable emails.

Check the [API Reference](https://hexdocs.pm/sendgrid/api-reference.html) for
complete usage.

## Example

Expand Down Expand Up @@ -172,3 +180,9 @@ Once configured you can run the full test suite including integration tests as f
```console
mix test --include integration
```

## License

Copyright (c) 2016 Alex Garibay

This library is MIT licensed. See the [LICENSE](https://github.com/alexgaribay/sendgrid_elixir/blob/master/LICENSE) for details.
18 changes: 9 additions & 9 deletions lib/sendgrid.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ defmodule SendGrid do

## Options

* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
"""
@spec get(path :: String.t(), options :: options()) :: {:ok, Response.t()} | {:error, any()}
def get(path, opts \\ []) when is_list(opts) do
Expand All @@ -59,8 +59,8 @@ defmodule SendGrid do

## Options

* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
"""
@spec post(path :: String.t(), body :: map(), options :: options()) ::
{:ok, Response.t()} | {:error, any()}
Expand All @@ -77,8 +77,8 @@ defmodule SendGrid do

## Options

* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
"""
@spec patch(path :: String.t(), body :: map(), options :: options()) ::
{:ok, Response.t()} | {:error, any()}
Expand All @@ -95,8 +95,8 @@ defmodule SendGrid do

## Options

* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
* `:api_key` - API key to use with the request.
* `:query` - Keyword list of query params to use with the request.
"""
@spec delete(path :: String.t(), options :: options()) :: {:ok, Response.t()} | {:error, any()}
def delete(path, opts \\ []) when is_list(opts) do
Expand All @@ -113,7 +113,7 @@ defmodule SendGrid do
unless api_key do
raise RuntimeError, """
No API key is configured for SendGrid. Update your config your pass in a
key with `:api_key` as an addional request option.
key with `:api_key` as an additional request option.

SendGrid.get("/stats", api_key: "API_KEY")

Expand Down
6 changes: 3 additions & 3 deletions lib/sendgrid/email.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule SendGrid.Email do

### Substitutions

You can provided a key-value pair for subsititions to have text replaced.
You can provided a key-value pair for substitutions to have text replaced.

add_substitution(email, "-key-", "value")

Expand Down Expand Up @@ -457,7 +457,7 @@ defmodule SendGrid.Email do
Expects a tuple of the view module and layout to use. If you provide an atom as the second element,
the text and HMTL versions of that template will be used for the respective content types.

Alernatively, you can set a default layout to use by setting the `:phoenix_view` key in your config as
Alternatively, you can set a default layout to use by setting the `:phoenix_view` key in your config as
an atom which will be used for both text and HTML emails.

config :sendgrid,
Expand Down Expand Up @@ -653,7 +653,7 @@ defmodule SendGrid.Email do
@doc """
Sets the email to be sent with sandbox mode enabled or disabled.

The sandbox mode will default to what is explicity configured with
The sandbox mode will default to what is explicitly configured with
SendGrid's configuration.
"""
@spec set_sandbox(t(), boolean()) :: t()
Expand Down
5 changes: 3 additions & 2 deletions lib/sendgrid/mail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ defmodule SendGrid.Mail do

## Sandbox Mode

Sandbox mode allows you to test sending emails without actually delivering emails and using your email quota.
Sandbox mode allows you to test sending emails without actually delivering
emails and using your email quota.

To send emails in sandbox mode, ensure the config key is set:

Expand All @@ -24,7 +25,7 @@ defmodule SendGrid.Mail do

## Options

* `:api_key` - API key to use with the request.
* `:api_key` - API key to use with the request.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion lib/sendgrid/marketing_campaigns/contacts/lists.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule SendGrid.Contacts.Lists do

## Options

* `:api_key` - API key to use with the request.
* `:api_key` - API key to use with the request.
"""
@spec all([SendGrid.api_key()]) :: {:ok, [map()]} | {:error, any()}
def all(opts \\ []) when is_list(opts) do
Expand Down
2 changes: 1 addition & 1 deletion lib/sendgrid/marketing_campaigns/contacts/recipient.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule SendGrid.Contacts.Recipient do
}

@doc """
Builds a Repient to be used in `SendGrid.Contacts.Recipents`.
Builds a Recipient to be used in `SendGrid.Contacts.Recipients`.
"""
@spec build(String.t(), map()) :: t()
def build(email, custom_fields \\ %{}) when is_map(custom_fields) do
Expand Down
3 changes: 2 additions & 1 deletion lib/sendgrid/marketing_campaigns/contacts/recipients.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule SendGrid.Contacts.Recipients do

## Options

* `:api_key` - API key to use with the request.
* `:api_key` - API key to use with the request.

## Examples

Expand All @@ -27,6 +27,7 @@ defmodule SendGrid.Contacts.Recipients do
{:ok, recipient_id} = add(Recipient.build("[email protected]", %{"name" => "John Doe"}))

{:ok, recipient_id} = add(Recipient.build("[email protected]"))

"""
@spec add(Recipient.t(), [SendGrid.api_key()]) ::
{:ok, String.t()} | {:error, [String.t(), ...]}
Expand Down
Loading