JSON::RPC::Common::Procedure::Call::Version_1_0 - JSON-RPC 1.0 request


JSON-RPC-Common documentation Contained in the JSON-RPC-Common distribution.

Index


Code Index:

NAME

Top

JSON::RPC::Common::Procedure::Call::Version_1_0 - JSON-RPC 1.0 request

VERSION

Top

version 0.10

SYNOPSIS

Top

	use JSON::RPC::Common::Procedure::Call;

	my $req = JSON::RPC::Common::Procedure::Call->inflate({
		# 1.0 doesn't specify the version
		id     => "oink",
		params => [ 1 .. 3 ],
	});

DESCRIPTION

Top

This class implements requests according to the JSON-RPC 1.0 spec: http://json-rpc.org/wiki/specification.

JSON-RPC 1.0 requests are considered notifications if the id is null.

AUTHOR

Top

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


JSON-RPC-Common documentation Contained in the JSON-RPC-Common distribution.

#!/usr/bin/perl

package JSON::RPC::Common::Procedure::Call::Version_1_0;
BEGIN {
  $JSON::RPC::Common::Procedure::Call::Version_1_0::VERSION = '0.10';
}
use Moose;
# ABSTRACT: JSON-RPC 1.0 request

use JSON::RPC::Common::Procedure::Return::Version_1_0;

use namespace::clean -except => [qw(meta)];

extends qw(JSON::RPC::Common::Procedure::Call);

has '+version' => (
	# default => "1.0", # broken, Moose::Meta::Method::Accessor gens numbers if looks_like_number
	default => sub { "1.0" },
);

has '+params' => (
	isa => "ArrayRef",
	required => 1,
);

has '+id' => (
	required => 1,
);

has '+return_class' => (
	default => "JSON::RPC::Common::Procedure::Return::Version_1_0",
);

has '+error_class' => (
	default => "JSON::RPC::Common::Procedure::Return::Version_1_0::Error",
);

sub is_notification {
	my $self = shift;
	return not defined $self->id;
}

sub deflate_params {
	my $self = shift;
	return ( params => $self->params );
}

sub deflate_id {
	my $self = shift;
	return ( id => $self->id ); # never omitted, can be null instead
}

__PACKAGE__->meta->make_immutable;

__PACKAGE__




__END__