License | BSD3 |
---|---|
Maintainer | Marcello Seri <marcello.seri@gmail.com> |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module contains types and helpers to build requests to the
Messenger Platform API
to use with SendAPI
.
- data Button = Button {}
- data BubbleElement = BubbleElement {
- elm_title :: Text
- elm_item_url :: Maybe Text
- elm_image_url :: Maybe Text
- elm_subtitle :: Maybe Text
- elm_buttons :: Maybe [Button]
- data FileUpload = FileUpload {}
- data FileUploadContent
- data NotificationType
- = Regular
- | SilentPush
- | NoPush
- data PaymentSummary = PaymentSummary {}
- data PaymentAdjustment = PaymentAdjustment {}
- data Recipient = Recipient {}
- data ReceiptItem = ReceiptItem {
- re_title :: Text
- re_subtitle :: Maybe Text
- re_quantity :: Maybe Int
- re_price :: Maybe Int
- re_currency :: Maybe Text
- re_image_url :: Maybe Text
- data ShippingAddress = ShippingAddress {
- sa_street_1 :: Text
- sa_street_2 :: Maybe Text
- sa_city :: Text
- sa_postal_code :: Text
- sa_state :: Text
- sa_country :: Text
- data SendTextMessageRequest = SendTextMessageRequest {}
- data SendStructuredMessageRequest = SendStructuredMessageRequest {
- smRecipient :: Recipient
- smAttachment :: AttachmentWrapper
- smNotificationType :: Maybe NotificationType
- data UploadImageMessageRequest payload = UploadImageMessageRequest {
- uiRecipient :: Recipient
- uiFileData :: payload
- data WelcomeMessageRequest
- = WelcomeTextMessage {
- wtmMessage :: Text
- | WelcomeStructuredMessage {
- wsmMessage :: AttachmentWrapper
- | WelcomeEmptyMessage
- = WelcomeTextMessage {
- bubbleElement :: Text -> BubbleElement
- localFileUpload :: FilePath -> FileUpload
- paymentSummary :: Double -> PaymentSummary
- postbackButton :: Text -> Text -> Button
- receiptItem :: Text -> ReceiptItem
- recipient :: Maybe Text -> Maybe Text -> Maybe Recipient
- shippingAddress :: Text -> Text -> Text -> Text -> Text -> ShippingAddress
- sendButtonTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> [Button] -> SendStructuredMessageRequest
- sendGenericTemplateMessageRequest :: Maybe NotificationType -> Recipient -> [BubbleElement] -> SendStructuredMessageRequest
- sendImageMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendStructuredMessageRequest
- sendReceiptTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> Text -> Text -> Text -> Maybe Text -> Maybe Text -> [ReceiptItem] -> Maybe ShippingAddress -> PaymentSummary -> Maybe [PaymentAdjustment] -> SendStructuredMessageRequest
- sendTextMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendTextMessageRequest
- setWelcomeButtonTemplateMessageRequest :: Text -> [Button] -> WelcomeMessageRequest
- setWelcomeGenericTemplateMessageRequest :: [BubbleElement] -> WelcomeMessageRequest
- setWelcomeImageMessageRequest :: Text -> WelcomeMessageRequest
- setWelcomeTextMessageRequest :: Text -> WelcomeMessageRequest
- uploadImageMessageRequest :: Recipient -> FileUpload -> UploadImageMessageRequest FileUpload
- webUrlButton :: Text -> Text -> Button
Types
Button
object for structured messages payloads
Button | |
|
data BubbleElement Source
Bubble element object for structured messages payloads
BubbleElement | |
|
data FileUpload Source
This object represents data (image, video, ...) with mime type to upload.
FileUpload | |
|
data FileUploadContent Source
This object represents data (image, video, ...) to upload.
data NotificationType Source
Push notification type for the message
Regular | will emit a sound/vibration and a phone notification (default) |
SilentPush | will emit a phone notification |
NoPush | will not emit either |
data PaymentSummary Source
Payment summary object for Receipt Template messages
PaymentSummary | |
|
data PaymentAdjustment Source
Informations about the recipient of the message
Recipient | |
|
data ReceiptItem Source
ReceiptItem | |
|
data ShippingAddress Source
Shipping address object for Receipt Template messages
ShippingAddress | |
|
data SendTextMessageRequest Source
This object represents a text message request The message text must be UTF-8, with 320 character limit
data SendStructuredMessageRequest Source
This object represents a structured message request
SendStructuredMessageRequest | |
|
data UploadImageMessageRequest payload Source
This object represents request for sendImage
UploadImageMessageRequest | |
|
Eq payload => Eq (UploadImageMessageRequest payload) Source | |
Show payload => Show (UploadImageMessageRequest payload) Source | |
ToJSON (UploadImageMessageRequest Text) Source | |
FromJSON (UploadImageMessageRequest Text) Source |
data WelcomeMessageRequest Source
This object represents a Welcome Message (FromJSON is disabled for it)
WelcomeTextMessage | |
| |
WelcomeStructuredMessage | |
| |
WelcomeEmptyMessage |
Functions
bubbleElement :: Text -> BubbleElement Source
Take the bubble element title. The buttons will appear as call-to-action in Messenger. Return a bubble Element
localFileUpload :: FilePath -> FileUpload Source
Return a FileUpload
from a given FilePath
.
At the moment, only png and jpg images are supported by the API.
postbackButton :: Text -> Text -> Button Source
Take the button title and the button payload (this data will be sent back to you via webhook) and return a "postback" button
receiptItem :: Text -> ReceiptItem Source
recipient :: Maybe Text -> Maybe Text -> Maybe Recipient Source
Take reciptient id (optional) or phone_number (optional) and return a 'Maybe Recipient' object. Return Nothing when values are either both (Just _) or both Nothing.
shippingAddress :: Text -> Text -> Text -> Text -> Text -> ShippingAddress Source
sendButtonTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> [Button] -> SendStructuredMessageRequest Source
Take a notification type (optional), a recipient, the text of the message and a list of
buttons (they will appear as call-to-actions).
Return a SendStructuredMessageRequest
for a structured message with button template
sendGenericTemplateMessageRequest :: Maybe NotificationType -> Recipient -> [BubbleElement] -> SendStructuredMessageRequest Source
Take a notification type (optional), a recipient, a list of ButtonElement
.
Return a SendStructuredMessageRequest
for a structured message with generic template
sendImageMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendStructuredMessageRequest Source
Take a notification type (optional), a recipient, an image url.
Return a SendStructuredMessageRequest
for a structured message with image attachment
sendReceiptTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> Text -> Text -> Text -> Maybe Text -> Maybe Text -> [ReceiptItem] -> Maybe ShippingAddress -> PaymentSummary -> Maybe [PaymentAdjustment] -> SendStructuredMessageRequest Source
Take a notification type (optional), a recipient and all the informations needed to construct a ReceiptTemplate
object.
Namely: the recipient name, the order number (must be unique), the currency, the payment method, the timestamp (optional),
the order url (optional), a list with the receipt items, the shipping address (optional), the payment summary and,
finally, a list of payment adjustments (optional).
Return a SendStructuredMessageRequest
for a structured message with receipt template
sendTextMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendTextMessageRequest Source
Take a notification type (optional), a recipient and a text.
Return a SendTextMessageRequest
.
Raise an error if the text is longer than 320 characters.
setWelcomeButtonTemplateMessageRequest :: Text -> [Button] -> WelcomeMessageRequest Source
Take the text of the message and a list of buttons (they will appear as call-to-actions).
Return a WelcomeMessageRequest
for a structured message with button template
setWelcomeGenericTemplateMessageRequest :: [BubbleElement] -> WelcomeMessageRequest Source
Take a list of ButtonElement.
Return a WelcomeMessageRequest
for a structured message with generic template
setWelcomeImageMessageRequest :: Text -> WelcomeMessageRequest Source
Take an image url.
Return a WelcomeMessageRequest
for a structured message with image attachment
setWelcomeTextMessageRequest :: Text -> WelcomeMessageRequest Source
Take a text. Return a WelcomeMessageRequest
uploadImageMessageRequest :: Recipient -> FileUpload -> UploadImageMessageRequest FileUpload Source
Take a Recipient
and FileUpload
(relative to a jpg or png). Return a ('UploadImageMessageRequest FileUpload')
for a structured message contatining and image uploaded using multipart form data.
webUrlButton :: Text -> Text -> Button Source
Take the button title and the button url (this URL is opened in a mobile browser when the button is tapped) and return a "web_url" button