NAME

API::MikroTik::Response - Parse responses from a buffer.

SYNOPSIS

use API::MikroTik::Response;

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

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

DESCRIPTION

Parser for API protocol responses.

ATTRIBUTES

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

data

my $items = $response->data;

Sentences fetched in last operation;

sentence

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

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

METHODS

parse

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

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

API::MikroTik