NAME

XAS::Lib::Mixins::JSON::Client - A mixin for a JSON RPC interface

SYNOPSIS

package Client

use XAS::Class
    debug   => 0,
    version => '0.01',
    base    => 'XAS::Lib::Net::Client',
    mixin   => 'XAS::Lib::Mixins::JSON::Client',
;

package main

 my $client = Client->new(
    -port => 9505,
    -host => 'localhost',
);

$client->connect();

my $data = $client->call(
    -method => 'test'
    -id     => $id,
    -params => {}
);

$client->disconnect();

DESCRIPTION

This modules implements a simple JSON RPC v2.0 client as a mixin. It doesn't support "Notification" calls.

METHODS

call

This method is used to format the JSON packet and send it to the server. Any errors returned from the server are parsed and then thrown.

-method

The name of the RPC method to invoke.

-id

The id used to identify this method call.

-params

A hashref of the parameters to be passed to the method.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.