File: Version_1_0.pm

package info (click to toggle)
libjson-rpc-common-perl 0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 244 kB
  • sloc: perl: 1,481; makefile: 2
file content (95 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl

package JSON::RPC::Common::Procedure::Call::Version_1_0;
$JSON::RPC::Common::Procedure::Call::Version_1_0::VERSION = '0.11';
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__

=pod

=head1 NAME

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

=head1 VERSION

version 0.11

=head1 SYNOPSIS

	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 ],
	});

=head1 DESCRIPTION

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

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

=head1 AUTHOR

Yuval Kogman <nothingmuch@woobling.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Yuval Kogman and others.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut