view release on metacpan or search on metacpan
- Add webhook redelivery field (PR #199)
- Add validate richmenu object (PR #198)
- Add accessor for the imageSet field (PR #192)
- Fixed test case name (PR #190)
1.20 2021-04-09 18:28:50 JST
- Add acceptedTime and completedTime field to narrowcast progress status (PR #179)
- add an accessor to property named 'keywords' to LINE::Bot::API::Event::Message::Sticker (issue #163)
- add an accessor to property named 'mention' to LINE::Bot::API::Event::Message::Text (issue #171)
- add a new API for setting webhook endpoint (issue #159)
- add a new API for getting webhook endpoint information (issue #159)
- add a new API for testing webhook endpoint (issue #159)
1.19 2021-01-22 17:01:55 JST
- requires IO::Socket::SSL at least 2.060 for the support of TLS 1.3 (PR #165)
- See also: https://developers.line.biz/ja/news/2020/10/06/update-webhook-client-and-root-certificate/
- Minor documentation updates and warning fixes.
- Update examples of Flex Messages. See eg/push-flex-message-showcases.pl (PR #155)
- Update test case for creating audience data with uploading user id (PR #157)
1.18 2020-10-12 12:40:31 JST
- Changed accepting parameter "sender" at SendMessage.pm (Issue #113 PR#140)
- Add `API#get_friend_demographics`. (Issue #75)
1.14 2020-02-07 17:17:42 JST
- Requires Type::Tiny at least 1.004000. (PR #97)
- An accessor name stickerResourceType is added to LINE::Bot::API::Event::Message::Sticker package.
See also: https://developers.line.biz/en/reference/messaging-api/#wh-sticker. (PR #98)
1.13 2019-12-20 16:26:47 JST
- Add method for calling download_rich_menu_image API (PR #91)
- Update the hostnames for some API calls. (PR #88)
See also: https://developers.line.biz/en/news/#notice-of-domain-name-change-for-certain-endpoints-2019-11-08
1.12 2019-11-08 17:42:10 JST
- Add the FlexMessage object builder that can take the result of "FlexMessage Simulator". See LINE::Bot::API::Builder::FlexMessage
- Add an method for uploading background image for a RichMenu: `API#upload_rich_menu_image` (PR #84)
1.11 2019-08-14 15:04:38 JST
- Add support for renewing OAuth tokens. (PR #74)
1.10 2019-08-14 14:58:51 JST
- Add an example of using altUri.desktop.
t/22_get_room_member_profile.t
t/41_event.t
t/42_create_events_by_api.t
t/51_issue_link_token.t
t/52_download_rich_menu_image.t
t/52_rich_menu.t
t/52_rich_menu_response.t
t/52_upload_rich_menu_image.t
t/53-retry_key.t
t/54-get_bot_info.t
t/55-get-webhook-endpoint-information.t
t/55-set-webhook-url.t
t/55-test-webhook.t
t/56_get_followers.t
t/57_validate_message_objects.t
t/PR75-get-number-of-followers.t
t/author-critic.t
t/author-pod-syntax.t
t/controller-rich-menu-image-sample.jpg
t/examples/account-link-event.json
t/examples/audio-message-1.json
get_room_member_profile($room_id, $user_id)
Get room user profile information. A room is like a group without a
group name. The response is similar to get_group_member_profile.
See also the LINE Developers API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile
get_number_of_sent_reply_messages($date)
Gets the number of messages sent with the /bot/message/reply endpoint.
The number of messages retrieved by this operation does not include the
number of messages sent from LINE@ Manager.
The $date parameter is "yyyyMMdd" format.
get_number_of_sent_push_messages($date)
Gets the number of messages sent with the /bot/message/push endpoint.
The number of messages retrieved by this operation does not include the
number of messages sent from LINE@ Manager.
date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
Timezone: UTC+9
get_number_of_sent_multicast_messages($date)
Gets the number of messages sent with the /bot/message/multicast
endpoint.
The number of messages retrieved by this operation does not include the
number of messages sent from LINE@ Manager.
date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
Timezone: UTC+9
get_number_of_send_broadcast_messages($date)
Gets the number of messages sent with the /bot/message/broadcast
endpoint.
The number of messages retrieved by this operation does not include the
number of messages sent from LINE Official Account Manager.
date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
Timezone: UTC+9
HTTP status, invoke $res-http_status()>.
get_user_interaction_statistics({ requestId => "..." })
Returns statistics about how users interact with narrowcast messages or
broadcast messages sent from your LINE Official Account.
See also the LINE Developers API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#get-message-event
set_webhook_url({ 'endpoint' => "https://example.com/webhook" })
Sets the webhook endpoint to te given endpoint, which should be an URL
string.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#set-webhook-endpoint-url
get_webhook_endpoint_information()
Return the information about webhook endpoint as an response object
with following accessors:
$res = $api->get_webhook_endpoint_information();
$res->endpoint(); # URL as a string
$res->active(); # true or false
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information
test_webhook_endpoint({ 'endpoint' => "https://example.com/webhook" })
Checks if the configured webhook endpoint can receive a test webhook
event.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information
validate_reply_message_objects([ $message, ... ] )
Validates that an array of message objects is valid as a value for the
messages property of the request body for the Send reply message
endpoint.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-reply-message
validate_push_message_objects([ $message, ... ] )
Validates that an array of message objects is valid as a value for the
messages property of the request body for the Send push message
endpoint.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-push-message
validate_multicast_message_objects([ $message, ... ] )
Validates that an array of message objects is valid as a value for the
messages property of the request body for the Send multicast message
endpoint.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-multicast-message
validate_narrowcast_message_objects([ $message, ... ] )
Validates that an array of message objects is valid as a value for the
messages property of the request body for the Send narrowcast message
endpoint.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-narrowcast-message
validate_broadcast_message_objects([ $message, ... ] )
Validates that an array of message objects is valid as a value for the
messages property of the request body for the Send broadcast message
endpoint.
See also the LINE Developer API reference of this method:
https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-broadcast-message
get_followers({ 'limit' => 100, 'start' => "..." })
Gets the list of User IDs of users who have added LINE Official Account
as a friend.
See also the LINE Developer API reference of this method:
eg/echo.psgi view on Meta::CPAN
use warnings;
use lib 'lib';
use Plack::Request;
use LINE::Bot::API;
use LINE::Bot::API::Builder::SendMessage;
my $channel_secret = $ENV{CHANNEL_SECRET};
my $channel_access_token = $ENV{CHANNEL_ACCESS_TOKEN};
my $messaging_api_endpoint = $ENV{MESSAGING_API_ENDPOINT};
my $callback_url = $ENV{CALLBACK_URL} // '/perl/callback';
my $bot = LINE::Bot::API->new(
channel_secret => $channel_secret,
channel_access_token => $channel_access_token,
messaging_api_endpoint => $messaging_api_endpoint,
);
sub {
my $env = shift;
my $req = Plack::Request->new($env);
unless ($req->method eq 'POST' && $req->path eq $callback_url) {
warn "Unknown endpoint: $callback_url != @{[ $req->path ]}\n";
return [404, [], ['Not Found']];
}
unless ($bot->validate_signature($req->content, $req->header('X-Line-Signature'))) {
warn "Bad LINE Signature\n";
return [400, [], ['bad request']];
}
my $events = $bot->parse_events_from_json($req->content);
for my $event (@{ $events }) {
eg/line-bot-framework/interactive-bot.psgi view on Meta::CPAN
use warnings;
use lib 'lib';
use Plack::Request;
use LINE::Bot::API;
use LINEBotFramework;
my $channel_secret = $ENV{CHANNEL_SECRET};
my $channel_access_token = $ENV{CHANNEL_ACCESS_TOKEN};
my $messaging_api_endpoint = $ENV{MESSAGING_API_ENDPOINT};
my $callback_url = $ENV{CALLBACK_URL} // '/perl/callback';
my $bot = LINE::Bot::API->new(
channel_secret => $channel_secret,
channel_access_token => $channel_access_token,
messaging_api_endpoint => $messaging_api_endpoint,
);
my $framework = LINEBotFramework->new(
base_class => 'ExampleBot',
bot => $bot,
xslate_config => {
path => 'bot-tmpl',
},
);
eg/push-flex-message-showcases.pl view on Meta::CPAN
use FindBin '$Bin';
use File::Glob ':bsd_glob';
use JSON;
use Data::Dumper qw(Dumper);
use LINE::Bot::API;
my $channel_secret = $ENV{CHANNEL_SECRET} or die "requiers env: CHANNEL_SECRET";
my $channel_access_token = $ENV{CHANNEL_ACCESS_TOKEN} or die "requires env: CHANNEL_ACCESS_TOKEN";
my $messaging_api_endpoint = $ENV{MESSAGING_API_ENDPOINT};
my($to_id) = @ARGV;
$to_id or die "requires \$ARGV[0]: a user ID";
my $bot = LINE::Bot::API->new(
channel_secret => $channel_secret,
channel_access_token => $channel_access_token,
$messaging_api_endpoint ? (
messaging_api_endpoint => $messaging_api_endpoint,
):(),
);
my $json = JSON->new->utf8;
for my $file (bsd_glob($Bin . '/flex-message-showcases/*.json')) {
my ($fh, $flex_message);
print "# $file\n";
open($fh, '<', $file);
eg/push_imagemap-template.pl view on Meta::CPAN
use LINE::Bot::API;
use LINE::Bot::API;
use LINE::Bot::API::Builder::SendMessage;
use LINE::Bot::API::Builder::ImagemapMessage;
use LINE::Bot::API::Builder::TemplateMessage;
my $channel_secret = $ENV{CHANNEL_SECRET};
my $channel_access_token = $ENV{CHANNEL_ACCESS_TOKEN};
my $messaging_api_endpoint = $ENV{MESSAGING_API_ENDPOINT};
my $imagemap_image_url = $ENV{IMAGEMAP_IMAGE_URL};
my $template_image_url = $ENV{TEMPLATE_IMAGE_URL};
my($to_id, $text) = @ARGV;
my $bot = LINE::Bot::API->new(
channel_secret => $channel_secret,
channel_access_token => $channel_access_token,
messaging_api_endpoint => $messaging_api_endpoint,
);
my $messages = LINE::Bot::API::Builder::SendMessage->new->add_text( text => $text );
# Imagemap Message
my $imagemap = LINE::Bot::API::Builder::ImagemapMessage->new(
base_url => $imagemap_image_url,
alt_text => 'altText',
base_width => 1040,
base_height => 1040,
lib/LINE/Bot/API.pm view on Meta::CPAN
sub new {
my($class, %args) = @_;
my $client = LINE::Bot::API::Client->new(%args);
bless {
client => $client,
channel_secret => $args{channel_secret},
channel_access_token => $args{channel_access_token},
messaging_api_endpoint => $args{messaging_api_endpoint} // DEFAULT_MESSAGING_API_ENDPOINT,
social_api_endpoint => $args{social_api_endpoint} // DEFAULT_SOCIAL_API_ENDPOINT,
content_api_endpoint => $args{content_api_endpoint} // DEFAULT_CONTENT_API_ENDPOINT,
oauth_api_endpoint => $args{oauth_api_endpoint} // DEFAULT_OAUTH2_API_ENDPOINT,
}, $class;
}
sub request {
my ($self, $method, $path, @payload) = @_;
return $self->{client}->$method(
$self->{messaging_api_endpoint} . $path,
@payload,
);
}
sub request_content {
my ($self, $method, $path, @payload) = @_;
return $self->{client}->$method(
$self->{content_api_endpoint} . $path,
@payload,
);
}
sub reply_message {
my($self, $reply_token, $messages) = @_;
my $res = $self->request(
post => 'message/reply',
+{
lib/LINE/Bot/API.pm view on Meta::CPAN
}
sub upload_rich_menu_image {
my ($self, $rich_menu_id, $content_type, $file_path) = @_;
if (!$content_type) {
croak 'Need content_type';
}
my $res = $self->{client}->post_image(
$self->{content_api_endpoint} . "richmenu/$rich_menu_id/content",
[
'Content-Type' => $content_type,
],
$file_path
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Token->new(%{ $res });
} else {
return LINE::Bot::API::Response::Error->new(%{ $res });
}
}
sub download_rich_menu_image {
my ($self, $rich_menu_id) = @_;
return $self->{client}->get_content(
$self->{content_api_endpoint} . "richmenu/$rich_menu_id/content"
);
}
sub validate_rich_menu_object {
my ($self, $rich_menu) = @_;
my $res = $self->request(post => "richmenu/validate", $rich_menu);
LINE::Bot::API::Response::Common->new(%{ $res });
}
sub issue_channel_access_token {
my ($self, $opts) = @_;
my $res = $self->{client}->post_form(
$self->{social_api_endpoint} . 'accessToken',
[
grant_type => 'client_credentials',
client_id => $opts->{client_id},
client_secret => $opts->{client_secret},
]
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Token->new(%{ $res });
} else {
return LINE::Bot::API::Response::Error->new(%{ $res });
}
}
sub issue_channel_access_token_v2_1 {
my ($self, $opts) = @_;
my $res = $self->{client}->post_form(
$self->{oauth_api_endpoint} . 'token',
undef,
[
grant_type => 'client_credentials',
client_assertion_type => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
client_assertion => $opts->{jwt},
]
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Token->new(%{ $res });
lib/LINE/Bot/API.pm view on Meta::CPAN
}
}
sub get_valid_channel_access_token_v2_1 {
my ($self, $opts) = @_;
my $jwt = uri_escape($opts->{jwt});
my $assertion_type = uri_escape('urn:ietf:params:oauth:client-assertion-type:jwt-bearer');
my $res = $self->{client}->get(
$self->{oauth_api_endpoint} . 'tokens/kid' . "?client_assertion_type=$assertion_type&client_assertion=$jwt",
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Token->new(%{ $res });
} else {
return LINE::Bot::API::Response::Error->new(%{ $res });
}
}
sub revoke_channel_access_token {
my ($self, $opts) = @_;
my $res = $self->{client}->post_form(
$self->{social_api_endpoint} . 'revoke',
[
access_token => $opts->{access_token},
]
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Common->new(%{ $res });
} else {
return LINE::Bot::API::Response::Error->new(%{ $res });
}
lib/LINE/Bot/API.pm view on Meta::CPAN
}
sub get_bot_info {
my ($self) = @_;
my $res = $self->request(get => "info");
LINE::Bot::API::Response::BotInfo->new(%{ $res });
}
sub set_webhook_url {
my ($self, $opts) = @_;
defined($opts->{endpoint}) or croak "set_webhook_url: Missing a mandatory parameter: `endpoint`";
my $res = $self->request(
'put' => "channel/webhook/endpoint",
[],
+{ endpoint => $opts->{endpoint} },
);
if ($res->{http_status} eq '200') {
return LINE::Bot::API::Response::Common->new(%{ $res });
} else {
return LINE::Bot::API::Response::Error->new(%{ $res });
}
}
sub get_webhook_endpoint_information {
my ($self) = @_;
my $res = $self->request(get => "channel/webhook/endpoint");
LINE::Bot::API::Response::WebhookInformation->new(%{ $res });
}
sub test_webhook_endpoint {
my ($self, $opts) = @_;
my $req_body = {};
if ($opts->{'endpoint'}) {
$req_body->{'endpoint'} = $opts->{'endpoint'};
}
my $res = $self->request(
'post' => "channel/webhook/endpoint",
[],
$req_body,
);
LINE::Bot::API::Response::WebhookTest->new(%{ $res });
}
sub validate_reply_message_objects {
my($self, $messages) = @_;
lib/LINE/Bot/API.pm view on Meta::CPAN
=head2 C<< get_room_member_profile($room_id, $user_id) >>
Get room user profile information.
A room is like a group without a group name.
The response is similar to get_group_member_profile.
See also the LINE Developers API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile>
=head2 C<< get_number_of_sent_reply_messages($date) >>
Gets the number of messages sent with the C<< /bot/message/reply >> endpoint.
The number of messages retrieved by this operation does not include
the number of messages sent from LINE@ Manager.
The C<< $date >> parameter is "yyyyMMdd" format.
=head2 C<< get_number_of_sent_push_messages($date) >>
Gets the number of messages sent with the C<< /bot/message/push >> endpoint.
The number of messages retrieved by this operation does not include the number of messages sent from LINE@ Manager.
=over 4
=item date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
Timezone: UTC+9
=back
=head2 C<< get_number_of_sent_multicast_messages($date) >>
Gets the number of messages sent with the C<< /bot/message/multicast >> endpoint.
The number of messages retrieved by this operation does not include the number of messages sent from LINE@ Manager.
=over 4
=item date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
Timezone: UTC+9
=back
=head2 C<< get_number_of_send_broadcast_messages($date) >>
Gets the number of messages sent with the C<< /bot/message/broadcast >> endpoint.
The number of messages retrieved by this operation does not include the number of messages sent from LINE Official Account Manager.
=over 4
=item date
Date the messages were sent
Format: yyyyMMdd (Example: 20191231)
lib/LINE/Bot/API.pm view on Meta::CPAN
Notice that the "status" does not mean HTTP status. To inspect actual
HTTP status, invoke C<$res->http_status()>.
=head2 C<< get_user_interaction_statistics({ requestId => "..." }) >>
Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account.
See also the LINE Developers API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#get-message-event>
=head2 C<< set_webhook_url({ 'endpoint' => "https://example.com/webhook" }) >>
Sets the webhook endpoint to te given C<endpoint>, which should be an URL string.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#set-webhook-endpoint-url>
=head2 C<< get_webhook_endpoint_information() >>
Return the information about webhook endpoint as an response object with following accessors:
$res = $api->get_webhook_endpoint_information();
$res->endpoint(); # URL as a string
$res->active(); # true or false
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information>
=head2 C<< test_webhook_endpoint({ 'endpoint' => "https://example.com/webhook" }) >>
Checks if the configured webhook endpoint can receive a test webhook event.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information>
=head2 C<< validate_reply_message_objects([ $message, ... ] ) >>
Validates that an array of message objects is valid as a value for the messages property of the request body for the Send reply message endpoint.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-reply-message>
=head2 C<< validate_push_message_objects([ $message, ... ] ) >>
Validates that an array of message objects is valid as a value for the messages property of the request body for the Send push message endpoint.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-push-message>
=head2 C<< validate_multicast_message_objects([ $message, ... ] ) >>
Validates that an array of message objects is valid as a value for the messages property of the request body for the Send multicast message endpoint.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-multicast-message>
=head2 C<< validate_narrowcast_message_objects([ $message, ... ] ) >>
Validates that an array of message objects is valid as a value for the messages property of the request body for the Send narrowcast message endpoint.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-narrowcast-message>
=head2 C<< validate_broadcast_message_objects([ $message, ... ] ) >>
Validates that an array of message objects is valid as a value for the messages property of the request body for the Send broadcast message endpoint.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-broadcast-message>
=head2 C<< get_followers({ 'limit' => 100, 'start' => "..." }) >>
Gets the list of User IDs of users who have added LINE Official Account as a friend.
See also the LINE Developer API reference of this method: L<https://developers.line.biz/en/reference/messaging-api/#get-follower-ids>
=head1 How to build a send message object
lib/LINE/Bot/API/Response/WebhookInformation.pm view on Meta::CPAN
package LINE::Bot::API::Response::WebhookInformation;
use strict;
use warnings;
use parent 'LINE::Bot::API::Response::Common';
sub endpoint { $_[0]->{endpoint} }
sub active { $_[0]->{active} }
1;
__END__
=head1 NAME
LINE::Bot::API::Response::WebhookInformation
=head1 DESCRIPTION
This cllass corresponds to the response object of "Get Webhook Endpoint Information" API as described in this page: L<https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information>.
For each top-level properties, there is a corresponding method with the same name which provides access to the value of the property.
=head1 METHODS
=over 4
=item endpoint
=item active
=back
lib/LINE/Bot/API/Response/WebhookTest.pm view on Meta::CPAN
1;
__END__
=head1 NAME
LINE::Bot::API::Response::WebhookTest
=head1 DESCRIPTION
This cllass corresponds to the response object of "Test Webhook Endpoint" API as described in this page: L<https://developers.line.biz/en/reference/messaging-api/#test-webhook-endpoint>
For each top-level properties, there is a corresponding method with the same name which provides access to the value of the property.
=head1 METHODS
=over 4
=item success
=item timestamp
lib/LINE/Bot/Audience.pm view on Meta::CPAN
use URI::QueryParam;
sub new {
my($class, %args) = @_;
my $client = LINE::Bot::API::Client->new(%args);
bless {
client => $client,
channel_secret => $args{channel_secret},
channel_access_token => $args{channel_access_token},
messaging_api_endpoint => $args{messaging_api_endpoint} // DEFAULT_MESSAGING_API_ENDPOINT,
}, $class;
}
sub request {
my ($self, $method, $path, @payload) = @_;
return $self->{client}->$method(
$self->{messaging_api_endpoint} . $path,
@payload,
);
}
sub rename_audience {
my ($self, $opts) = @_;
my $res = $self->request(post => 'audienceGroup/'. $opts->{audience_group_id} . '/updateDescription', +{
'description' => $opts->{description},
});
lib/LINE/Bot/Message/Narrowcast.pm view on Meta::CPAN
};
sub new {
my ($class, %args) = @_;
my $client = LINE::Bot::API::Client->new(%args);
bless {
client => $client,
channel_secret => $args{channel_secret},
channel_access_token => $args{channel_access_token},
messaging_api_endpoint => $args{messaging_api_endpoint} // DEFAULT_MESSAGING_API_ENDPOINT,
}, $class;
}
sub request {
my ($self, $method, $path, @payload) = @_;
return $self->{client}->$method(
$self->{messaging_api_endpoint} . $path,
@payload,
);
}
sub send_message {
my ($self, $messages, $recipient, $demographic, $limit, $options) = @_;
my @headers = ();
if ($options && defined($options->{'retry_key'})) {
push @headers, 'X-Line-Retry-Key' => $options->{'retry_key'};
t/55-get-webhook-endpoint-information.t view on Meta::CPAN
use lib 't/lib';
use t::Util;
use LINE::Bot::API;
my $bot = LINE::Bot::API->new(
channel_secret => 'testsecret',
channel_access_token => 'ACCESS_TOKEN',
);
send_request {
my $res = $bot->get_webhook_endpoint_information();
isa_ok $res, 'LINE::Bot::API::Response::WebhookInformation';
is $res->is_success, T();
is $res->http_status, 200;
is $res->endpoint, 'https://example.com/webhook';
is $res->active, T();
} receive_request {
my %args = @_;
is $args{method}, 'GET';
is $args{url}, 'https://api.line.me/v2/bot/channel/webhook/endpoint';
+{
endpoint => 'https://example.com/webhook',
active => 1,
}
};
done_testing;
t/55-set-webhook-url.t view on Meta::CPAN
use LINE::Bot::API;
my $bot = LINE::Bot::API->new(
channel_secret => 'testsecret',
channel_access_token => 'ACCESS_TOKEN',
);
send_request {
my $webhook_url = "https://example.com/webhook/" . int(rand(100000000));
my $res = $bot->set_webhook_url({ 'endpoint' => $webhook_url });
isa_ok $res, 'LINE::Bot::API::Response::Common';
is $res->is_success, T();
is $res->http_status, 200;
} receive_request {
my %args = @_;
is $args{method}, 'PUT';
is $args{url}, 'https://api.line.me/v2/bot/channel/webhook/endpoint';
+{};
};
done_testing;
t/55-test-webhook.t view on Meta::CPAN
use LINE::Bot::API;
my $bot = LINE::Bot::API->new(
channel_secret => 'testsecret',
channel_access_token => 'ACCESS_TOKEN',
);
send_request {
my $webhook_url = "https://example.com/webhook/" . int(rand(100000000));
my $res = $bot->test_webhook_endpoint({ 'endpoint' => $webhook_url });
isa_ok $res, 'LINE::Bot::API::Response::WebhookTest';
is $res->is_success, T();
is $res->http_status, 200;
is $res->success(), T();
is $res->timestamp(), E();
is $res->statusCode(), E();
is $res->reason(), E();
is $res->detail(), E();
} receive_request {
my %args = @_;
is $args{method}, 'POST';
is $args{url}, 'https://api.line.me/v2/bot/channel/webhook/endpoint';
+{
success => 1,
timestamp => time() * 1000,
statusCode => 200,
reason => 'OK',
detail => '...',
}
};