Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcelbuesing/sendgrid-v3
Haskell Sendgrid v3 API Library
https://github.com/marcelbuesing/sendgrid-v3
Last synced: 19 days ago
JSON representation
Haskell Sendgrid v3 API Library
- Host: GitHub
- URL: https://github.com/marcelbuesing/sendgrid-v3
- Owner: marcelbuesing
- License: mit
- Created: 2018-01-20T07:20:18.000Z (almost 7 years ago)
- Default Branch: dev
- Last Pushed: 2024-05-02T21:01:04.000Z (7 months ago)
- Last Synced: 2024-10-14T13:27:38.327Z (about 1 month ago)
- Language: Haskell
- Size: 77.1 KB
- Stars: 15
- Watchers: 5
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# SendGrid-v3
[![CI](https://github.com/marcelbuesing/sendgrid-v3/actions/workflows/ci.yml/badge.svg)](https://github.com/marcelbuesing/sendgrid-v3/actions/workflows/ci.yml/badge.svg)[![Hackage](https://img.shields.io/hackage/v/sendgrid-v3.svg)](https://hackage.haskell.org/package/sendgrid-v3)A library for accessing the [v3 SendGrid API](https://sendgrid.com/docs/API_Reference/api_v3.html) in Haskell.
```Haskell
{-# LANGUAGE OverloadedStrings #-}import Data.List.NonEmpty (fromList)
import Data.Text (Text)
import Network.SendGridV3.Api
import Control.Lens ((^.))
import Network.Wreq (responseStatus, statusCode)sendGridApiKey :: Text
sendGridApiKey = "SG..."testMail :: Mail () ()
testMail =
let to = personalization $ fromList [MailAddress "[email protected]" "John Doe"]
from = MailAddress "[email protected]" "Jane Smith"
subject = "Email Subject"
content = fromList [mailContentText "Example Content"]
in mail [to] from subject $ Just contentmain :: IO ()
main = do
sendgridSettings <- mkSendGridSettings sendGridApiKey-- Send an email, overriding options as needed
eResponse <- sendMail sendgridSettings (testMail { _mailSendAt = Just 1516468000 })
case eResponse of
Left httpException -> error $ show httpException
Right response -> print (response ^. responseStatus . statusCode)
```# Test Setup
```
echo "export SENDGRID_API_KEY='SG.YOURKEY'" > sendgrid.env
echo "export SENDGRID_TEST_MAIL='[email protected]' >> sendgrid.env
source ./sendgrid.env
```