Skip to content

Commit

Permalink
missing fields in email request type
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Aug 22, 2024
1 parent 333a0fd commit b03e73b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions azure-email/Azure/Email.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,34 @@ instance ToJSON EmailContent where
, "subject" .= ecSubject
]

data EmailAttachment = EmailAttachment
{ eaContentInBase64 :: !Text
-- ^ Base64 encoded contents of the attachment
, eaContentType :: !Text
-- ^ MIME type of the attachment
, eaName :: !Text
-- ^ Name of the attachment
}
deriving stock (Generic)

instance ToJSON EmailAttachment where
toJSON EmailAttachment{..} =
object
[ "name" .= eaName
, "contentType" .= eaContentType
, "contentInBase64" .= eaContentInBase64
]

{- | Source:
https://learn.microsoft.com/en-us/rest/api/communication/dataplane/email/send?view=rest-communication-dataplane-2023-03-31&tabs=HTTP
-}
data AzureEmailRequest = AzureEmailRequest
{ aerContent :: !EmailContent
, aerRecipients :: !EmailRecipients
, aerSenderAddress :: !Text -- TODO: This should probably be it's own newtype
, aerReplyTo :: ![EmailAddress] -- TODO: Should this be NonEmpty instead?
, aerAttachments :: ![EmailAttachment]
, aerUserEngagementTrackingDisabled :: !Bool
}
deriving stock (Generic)

Expand All @@ -71,4 +92,18 @@ instance ToJSON AzureEmailRequest where
[ "content" .= aerContent
, "recipients" .= aerRecipients
, "senderAddress" .= aerSenderAddress
, "replyTo" .= aerReplyTo
, "attachments" .= aerAttachments
, "userEngagementTrackingDisabled" .= aerUserEngagementTrackingDisabled
]

{- | Possible states once a send email action is triggered.
Source: https://learn.microsoft.com/en-us/rest/api/communication/dataplane/email/send?view=rest-communication-dataplane-2023-03-31&tabs=HTTP#emailsendstatus
-}
data EmailSendStatus
= Canceled
| Failed
| NotStarted
| Running
| Succeeded
deriving stock (Eq, Show, Generic, Enum, Bounded)
1 change: 1 addition & 0 deletions azure-email/azure-email.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ library
import: common-options
exposed-modules: Azure.Email
build-depends: aeson
, bytestring
, http-client
, servant
, servant-client
Expand Down

0 comments on commit b03e73b

Please sign in to comment.