The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

LINE::Bot::API::Builder::FlexMessage

SYNOPSIS

    my $message = LINE::Bot::API::Builder::FlexMessage->new( json => $json_text );

    $bot->push_message( $user_id, $message->build );

DESCRIPTION

This module can be used to convert the output of Flex Message Simulator to an object.

Structurally, a flex message is represented as an object in JSON with smaller components. Here's an minimal example:

    {
      "type": "flex",
      "altText": "This is a Flex Message",
      "contents": {
        "type": "bubble",
        "body": {
          "type": "box",
          "layout": "horizontal",
          "contents": [
            {
              "type": "text",
              "text": "Hello,"
            },
            {
              "type": "text",
              "text": "World!"
            }
          ]
        }
      }
    }

This module merely parse the given json text provided by the json attribute and directly use the structure as the message content.

It is created to let developers able to basically paste the JSON text produced by Flex Message Simular into code.

METHODS

new( json => $json_text )

Object constructure. The "json" parameter is required. The value should be a normal scalar variable containing json text.

build()

Returns the message object that can be pass thru push_message method.

SEE ALSO

Flex Message Simulator