NAME

MikroTik::Client::Response - Parse responses from a buffer

SYNOPSIS

use MikroTik::Client::Response;

my $response = MikroTik::Client::Response->new();

my $list = $response->parse(\$buf);
for my $re (@$list) {
    my ($type, $tag) = delete @{$re}{'.type'. '.tag'};
    say "$_ => $re->{$_}" for keys %$re;
}

DESCRIPTION

Parser for API protocol responses.

ATTRIBUTES

MikroTik::Client::Response implements the following attributes.

data

my $items = $response->data;

Sentences fetched in last operation;

sentence

my $sentence = $response->sentence;
$response->sentence(MikroTik::Client::Sentence->new());

MikroTik::Client::Sentence object used to decode sentences from network buffer.

METHODS

parse

my $list = $response->parse(\$buf);

Parses data from a buffer and returns list of hashrefs with attributes for each sentence. There are some special attributes:

'.tag'
'.tag' => 1

Reply tag.

'.type'
'.type' => '!re'

Reply type.

SEE ALSO

MikroTik::Client