l websocket client for Mattermost.
use Encode 'encode';
use Mojo::IOLoop;
use Mojo::JSON qw(decode_json encode_json);
use Moo;
use MooX::HandlesVia;
use Types::Standard qw(ArrayRef Bool InstanceOf In
lf->logger->debugf('[Seq: %d] Sending ping', $self->last_seq);
}
return $tx->send(encode_json({
seq => $self->last_seq,
action => 'ping',
}));
}
sub _on_start {
my
y $tx = shift;
my $input = shift;
return unless $input;
my $message = decode_json(encode('utf8', $input));
if ($message->{seq}) {
$self->logger->debugf('[Seq: %d]', $
ILDARGS => sub {
my $orig = shift;
my $self = shift;
my $args = shift;
# Convert JSON::PP::Boolean into regular boolean
$args->{prepackaged} = $args->{prepackaged} ? 1 : 0;
r
ervice::Mattermost::V4::API::Response;
# ABSTRACT: Container for API responses.
use Mojo::JSON 'decode_json';
use Moo;
use Types::Standard qw(Any ArrayRef Bool InstanceOf Int Maybe Object Str);
use
#####
sub BUILD {
my $self = shift;
if ($self->_looks_like_json($self->raw_content)) {
$self->content(decode_json($self->raw_content));
}
return 1;
}
######################
##########################################
sub _looks_like_json {
my $self = shift;
my $inp = shift;
# Rudimentary "is it JSON?" hack
return $inp && $inp =~ /^[\{\[]/ ? 1 : 0;
}
##
type;
if (grep { $_ eq $request->method } ($self->PUT, $self->POST)) {
$form_type = 'json';
} else {
$form_type = 'form';
}
$form_type = $args->{override_data_type} i