line-1.0.1.0: Haskell SDK for the LINE API

Safe HaskellNone
LanguageHaskell2010

Line.Messaging.API.Types

Contents

Description

This module provides types to be used with Line.Messaging.API.

Synopsis

Common types

Re-exported for convenience.

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.

Minimal complete definition

toType, toObject

data Message Source #

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

newtype Text Source #

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.

Constructors

Text 

Fields

Instances

Eq Text Source # 

Methods

(==) :: Text -> Text -> Bool #

(/=) :: Text -> Text -> Bool #

Ord Text Source # 

Methods

compare :: Text -> Text -> Ordering #

(<) :: Text -> Text -> Bool #

(<=) :: Text -> Text -> Bool #

(>) :: Text -> Text -> Bool #

(>=) :: Text -> Text -> Bool #

max :: Text -> Text -> Text #

min :: Text -> Text -> Text #

Show Text Source # 

Methods

showsPrec :: Int -> Text -> ShowS #

show :: Text -> String #

showList :: [Text] -> ShowS #

FromJSON Text Source # 

Methods

parseJSON :: Value -> Parser Text #

Messageable Text Source # 

Methods

toType :: Text -> Text

toObject :: Text -> [Pair]

toValue :: Text -> Value

Image

data Image Source #

Messageable for image data.

It contains URLs of an original image and its preview. Its corresponding JSON spec is described here.

Constructors

Image 

Instances

Video

data Video Source #

Messageable for video data.

It contains URLs of an original video and its preview. Its corresponding JSON spec is described here.

Constructors

Video 

Instances

Audio

data Audio Source #

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 

Instances

Location

data Location Source #

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.

Sticker

data Sticker Source #

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 

Image map

data ImageMap Source #

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 Source #

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.

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

data Template t Source #

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.

Constructors

Template 

Fields

data Buttons Source #

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

data Confirm Source #

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

data Carousel Source #

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 Column Source #

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

type Label = Text Source #

Just a type alias for Text, used with TemplateAction.

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.

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 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

data Profile Source #

A type to represent a user's profile.

It is the return type of the getProfile API in the Line.Messaging.API module.

Error types

data APIError Source #

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 SomeException.

data APIErrorBody Source #

An error body type.

It contains error message, and may contain property information and detailed error bodies.