| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Line.Messaging.API.Types
Contents
Description
This module provides types to be used with Line.Messaging.API.
Synopsis
- module Line.Messaging.Common.Types
- class Messageable a
- data Message = (Show a, Messageable a) => Message a
- newtype Text = Text {}
- data Image = Image {
- getURL :: URL
- getPreviewURL :: URL
- data Video = Video {
- getURL :: URL
- getPreviewURL :: URL
- data Audio = Audio {
- getURL :: URL
- getDuration :: Integer
- data Location = Location {
- getTitle :: Text
- getAddress :: Text
- getLatitude :: Double
- getLongitude :: Double
- data Sticker = Sticker {
- getPackageID :: ID
- getStickerID :: ID
- data ImageMap = ImageMap {
- getBaseImageURL :: URL
- getAltText :: Text
- getBaseImageSize :: (Integer, Integer)
- getActions :: [ImageMapAction]
- data ImageMapAction
- type ImageMapArea = (Integer, Integer, Integer, Integer)
- data Template t = Template {
- getAltText :: Text
- getTemplateContent :: t
- data Buttons = Buttons {
- getThumbnailURL :: Maybe URL
- getTitle :: Maybe Text
- getText :: Text
- getActions :: [TemplateAction]
- data Confirm = Confirm {
- getText :: Text
- getActions :: [TemplateAction]
- data Carousel = Carousel {
- getColumns :: [Column]
- data ImageCarousel = ImageCarousel {
- getColumns :: [ImageColumn]
- data Column = Column {
- getThumbnailURL :: Maybe URL
- getTitle :: Maybe Text
- getText :: Text
- getActions :: [TemplateAction]
- data ImageColumn = ImageColumn {}
- type Label = Text
- data TemplateAction
- data DatetimeMode
- data Profile = Profile {}
- data APIError
- data APIErrorBody = APIErrorBody {}
Common types
Re-exported for convenience.
module Line.Messaging.Common.Types
Message types
class Messageable a #
A type class representing types to be converted into Message.
It has toType and toObject as its minimal complete definition, but it
is not recommended to define any extra instance, as the new type may not work
with the LINE APIs.
About existing messageable types, please refer to the following instances. Each instance is matched with a message object described in the LINE documentation.
Minimal complete definition
toType, toObject
Instances
| Messageable ImageMap # | |
| Messageable Sticker # | |
| Messageable Location # | |
| Messageable Audio # | |
| Messageable Video # | |
| Messageable Image # | |
| Messageable Text # | |
| Messageable (Template ImageCarousel) # | |
Defined in Line.Messaging.API.Types Methods toType :: Template ImageCarousel -> Text toObject :: Template ImageCarousel -> [Pair] toValue :: Template ImageCarousel -> Value | |
| Messageable (Template Carousel) # | |
| Messageable (Template Confirm) # | |
| Messageable (Template Buttons) # | |
A type representing a message to be sent.
The data constructor converts Messageable into Message. It allows
different types of Messageable to be sent through a single API call.
An example usage is like below.
pushTextAndImage :: ID -> APIIO () pushTextAndImage identifier = push identifier [ Message $Text"hello", Message $Image"https://example.com/image.jpg" "https://example.com/preview.jpg" ]
Constructors
| (Show a, Messageable a) => Message a |
Text
Messageable for text data.
It contains Text of Data.Text. Its corresponding JSON spec is described
here.
This type is also used to decode text event message from webhook request. About the webhook usage, please refer to EventMessage in Line.Messaging.Webhook.Types.
Image
Messageable for image data.
It contains URLs of an original image and its preview. Its corresponding JSON spec is described here.
Constructors
| Image | |
Fields
| |
Video
Messageable for video data.
It contains URLs of an original video and its preview. Its corresponding JSON spec is described here.
Constructors
| Video | |
Fields
| |
Audio
Messageable for audio data.
It contains a URL of an audio, and its duration in milliseconds. Its corresponding JSON spec is described here.
Constructors
| Audio | |
Fields
| |
Location
Messageable for location data.
It contains a title, address, and geographic coordination of a location. Its corresponding JSON spec is described here.
This type is also used to decode location event message from webhook request. About the webhook usage, please refer to EventMessage in Line.Messaging.Webhook.Types.
Constructors
| Location | |
Fields
| |
Sticker
Messageable for sticker data.
It contains its package and sticker ID. Its corresponding JSON spec is described here.
This type is also used to decode sticker event message from webhook request. About the webhook usage, please refer to EventMessage in Line.Messaging.Webhook.Types.
Constructors
| Sticker | |
Fields
| |
Image map
Messageable for image map data.
About how to send an image map message and what each field means, please refer to image map message spec.
Constructors
| ImageMap | |
Fields
| |
data ImageMapAction #
A type representing actions when a specific area of an image map is tapped.
It contains action data and area information.
Constructors
| IMURIAction URL ImageMapArea | Open a web page when an area is tapped. |
| IMMessageAction Text ImageMapArea | Send a text message from the user who tapped an area. |
Instances
| Eq ImageMapAction # | |
Defined in Line.Messaging.API.Types Methods (==) :: ImageMapAction -> ImageMapAction -> Bool # (/=) :: ImageMapAction -> ImageMapAction -> Bool # | |
| Show ImageMapAction # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> ImageMapAction -> ShowS # show :: ImageMapAction -> String # showList :: [ImageMapAction] -> ShowS # | |
| ToJSON ImageMapAction # | |
Defined in Line.Messaging.API.Types Methods toJSON :: ImageMapAction -> Value # toEncoding :: ImageMapAction -> Encoding # toJSONList :: [ImageMapAction] -> Value # toEncodingList :: [ImageMapAction] -> Encoding # | |
type ImageMapArea = (Integer, Integer, Integer, Integer) #
A type representing a tappable area in an image map
Each component means (x, y, width, height) correspondingly.
Template
Messageable for template data.
It has a type parameter t which means a template content type. The type is
polymolphic, but Messageable instances are defined only for Buttons,
Confirm, Carousel, and ImageCarousel.
About how to send template message and what each field means, please refer to template message spec.
Constructors
| Template | |
Fields
| |
Instances
| Eq t => Eq (Template t) # | |
| Show t => Show (Template t) # | |
| Messageable (Template ImageCarousel) # | |
Defined in Line.Messaging.API.Types Methods toType :: Template ImageCarousel -> Text toObject :: Template ImageCarousel -> [Pair] toValue :: Template ImageCarousel -> Value | |
| Messageable (Template Carousel) # | |
| Messageable (Template Confirm) # | |
| Messageable (Template Buttons) # | |
The buttons content type for template message.

For more details of each field, please refer to the Buttons section in the LINE documentation.
Constructors
| Buttons | |
Fields
| |
The confirm content type for template message.

For more details of each field, please refer to the Confirm section in the LINE documentation.
Constructors
| Confirm | |
Fields
| |
The carousel content type for template message.

For more details of each field, please refer to the Carousel section in the LINE documentation.
Constructors
| Carousel | |
Fields
| |
data ImageCarousel #
The image carousel content type for template message.

For more details of each field, please refer to the Image carousel section in the LINE documentation.
Constructors
| ImageCarousel | |
Fields
| |
Instances
| Eq ImageCarousel # | |
Defined in Line.Messaging.API.Types Methods (==) :: ImageCarousel -> ImageCarousel -> Bool # (/=) :: ImageCarousel -> ImageCarousel -> Bool # | |
| Show ImageCarousel # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> ImageCarousel -> ShowS # show :: ImageCarousel -> String # showList :: [ImageCarousel] -> ShowS # | |
| ToJSON ImageCarousel # | |
Defined in Line.Messaging.API.Types Methods toJSON :: ImageCarousel -> Value # toEncoding :: ImageCarousel -> Encoding # toJSONList :: [ImageCarousel] -> Value # toEncodingList :: [ImageCarousel] -> Encoding # | |
| Messageable (Template ImageCarousel) # | |
Defined in Line.Messaging.API.Types Methods toType :: Template ImageCarousel -> Text toObject :: Template ImageCarousel -> [Pair] toValue :: Template ImageCarousel -> Value | |
Actual contents of carousel template.
It has the same fields as Buttons, except that the number of actions is
up to 3.
Constructors
| Column | |
Fields
| |
data ImageColumn #
Actual contents of carousel template.
It has the same fields as Buttons, except that the number of actions is
up to 3.
Constructors
| ImageColumn | |
Fields
| |
Instances
| Eq ImageColumn # | |
Defined in Line.Messaging.API.Types | |
| Show ImageColumn # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> ImageColumn -> ShowS # show :: ImageColumn -> String # showList :: [ImageColumn] -> ShowS # | |
| ToJSON ImageColumn # | |
Defined in Line.Messaging.API.Types Methods toJSON :: ImageColumn -> Value # toEncoding :: ImageColumn -> Encoding # toJSONList :: [ImageColumn] -> Value # toEncodingList :: [ImageColumn] -> Encoding # | |
Just a type alias for Text, used with TemplateAction.
data TemplateAction #
A data type for possible template actions.
Each action object represents a button in template message. A button has a label and an actual action fired by click.
Constructors
| TplMessageAction Label Text | Message action. When clicked, a specified text will be sent into the same room by a user who clicked the button. |
| TplPostbackAction Label Text (Maybe Text) | Postback action. When clicked, a specified text will be sent, and postback data will be sent to webhook server as a postback event. |
| TplURIAction Label URL | URI action. When clicked, a web page with a specified URI will open in the in-app browser. |
| TplDatetimePickerAction | Datetime picker action. When clicked, a postback action will be sent with the date and time selected by the user from the date and time selection dialog. For the detailed information of datetime picker, please refer to the official documentation. |
Instances
| Eq TemplateAction # | |
Defined in Line.Messaging.API.Types Methods (==) :: TemplateAction -> TemplateAction -> Bool # (/=) :: TemplateAction -> TemplateAction -> Bool # | |
| Show TemplateAction # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> TemplateAction -> ShowS # show :: TemplateAction -> String # showList :: [TemplateAction] -> ShowS # | |
| ToJSON TemplateAction # | |
Defined in Line.Messaging.API.Types Methods toJSON :: TemplateAction -> Value # toEncoding :: TemplateAction -> Encoding # toJSONList :: [TemplateAction] -> Value # toEncodingList :: [TemplateAction] -> Encoding # | |
data DatetimeMode #
Instances
| Eq DatetimeMode # | |
Defined in Line.Messaging.API.Types | |
| Show DatetimeMode # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> DatetimeMode -> ShowS # show :: DatetimeMode -> String # showList :: [DatetimeMode] -> ShowS # | |
| ToJSON DatetimeMode # | |
Defined in Line.Messaging.API.Types Methods toJSON :: DatetimeMode -> Value # toEncoding :: DatetimeMode -> Encoding # toJSONList :: [DatetimeMode] -> Value # toEncodingList :: [DatetimeMode] -> Encoding # | |
Profile
A type to represent a user's profile.
It is the return type of the getProfile API in the Line.Messaging.API module.
Constructors
| Profile | |
Fields
| |
Error types
An error type possibly returned from the
APIIO type.
State code errors may contain a parsed error body. Other types of errors, which may rarely occur if used properly, does not.
For more details of error types, please refer to Status codes and Error response sections in the LINE documentation.
Constructors
| BadRequest (Maybe APIErrorBody) | 400 Bad Request with a parsed error body, caused by badly formatted request. |
| Unauthorized (Maybe APIErrorBody) | 401 Unauthorized with a parsed error body, caused by invalid access token. |
| Forbidden (Maybe APIErrorBody) | 403 Forbidden with a parsed error body, caused by unauthorized account or plan. |
| TooManyRequests (Maybe APIErrorBody) | 429 Too Many Requests with a parsed error body, caused by exceeding the rate limit. |
| InternalServerError (Maybe APIErrorBody) | 500 Internal Server Error with a parsed error body. |
| UndefinedStatusCode Int ByteString | Caused by status codes other than 200 and listed statuses above, with the status code and request body. |
| JSONDecodeError String | Caused by badly formatted response body from APIs. |
| UndefinedError SomeException | Any other exception caught as |
data APIErrorBody #
An error body type.
It contains error message, and may contain property information and detailed error bodies.
Constructors
| APIErrorBody | |
Fields | |
Instances
| Eq APIErrorBody # | |
Defined in Line.Messaging.API.Types | |
| Show APIErrorBody # | |
Defined in Line.Messaging.API.Types Methods showsPrec :: Int -> APIErrorBody -> ShowS # show :: APIErrorBody -> String # showList :: [APIErrorBody] -> ShowS # | |
| FromJSON APIErrorBody # | |
Defined in Line.Messaging.API.Types | |