Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides types to be used with Line.Messaging.API.
- module Line.Messaging.Common.Types
- class Messageable a
- data Message = (Show a, Messageable a) => Message a
- newtype Text = Text {}
- data Image = Image {}
- data Video = Video {}
- data Audio = Audio {}
- data Location = Location {}
- data Sticker = Sticker {
- getPackageID :: ID
- getStickerID :: ID
- data ImageMap = ImageMap {}
- data ImageMapAction
- type ImageMapArea = (Integer, Integer, Integer, Integer)
- data Template t = Template {
- getTemplateAltText :: Text
- getTemplate :: t
- data Buttons = Buttons {}
- data Confirm = Confirm {}
- data Carousel = Carousel {
- getColumns :: [Column]
- data Column = Column {}
- type Label = Text
- data TemplateAction
- data Profile = Profile {}
- data APIError
- data APIErrorBody = APIErrorBody {}
Common types
Re-exported for convenience.
module Line.Messaging.Common.Types
Message types
class Messageable a Source #
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.
toType, toObject
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" ]
(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.
Image | |
|
Video
Messageable
for video data.
It contains URLs of an original video and its preview. Its corresponding JSON spec is described here.
Video | |
|
Audio
Messageable
for audio data.
It contains a URL of an audio, and its duration in milliseconds. Its corresponding JSON spec is described here.
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.
Location | |
|
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.
Sticker | |
|
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.
ImageMap | |
|
data ImageMapAction Source #
A type representing actions when a specific area of an image map is tapped.
It contains action data and area information.
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. |
type ImageMapArea = (Integer, Integer, Integer, Integer) Source #
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
, and Carousel
.
About how to send template message and what each field means, please refer to template message spec.
Template | |
|
The buttons content type for template message.
For more details of each field, please refer to the Buttons section in the LINE documentation.
Buttons | |
|
The confirm content type for template message.
For more details of each field, please refer to the Confirm section in the LINE documentation.
Confirm | |
|
The carousel content type for template message.
For more details of each field, please refer to the Carousel section in the LINE documentation.
Carousel | |
|
Actual contents of carousel template.
It has the same fields as Buttons
, except that the number of actions is
up to 3.
Column | |
|
data TemplateAction Source #
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.
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 Postback 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. |
Profile
A type to represent a user's profile.
It is the return type of the getProfile API in the Line.Messaging.API module.
Profile | |
|
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.
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 Source #
An error body type.
It contains error message, and may contain property information and detailed error bodies.