| 1 | package Net::OpenSocial::Client::Request; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | has 'id' => ( | |||||||||
| 6 | is => 'rw', | ||||||||||
| 7 | isa => 'Str', | ||||||||||
| 8 | ); | ||||||||||
| 9 | |||||||||||
| 10 | 1 | has 'service' => ( | |||||||||
| 11 | is => 'rw', | ||||||||||
| 12 | isa => 'Str', | ||||||||||
| 13 | required => 1, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 1 | has 'operation' => ( | |||||||||
| 17 | is => 'rw', | ||||||||||
| 18 | isa => 'Str', | ||||||||||
| 19 | required => 1, | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 1 | has 'user_id' => ( | |||||||||
| 23 | is => 'rw', | ||||||||||
| 24 | isa => 'Str', | ||||||||||
| 25 | default => '@me', | ||||||||||
| 26 | required => 1, | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | 1 | has 'group_id' => ( | |||||||||
| 30 | is => 'rw', | ||||||||||
| 31 | isa => 'Str', | ||||||||||
| 32 | default => '@self', | ||||||||||
| 33 | required => 1, | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | has 'params' => ( | ||||||||||
| 37 | is => 'rw', | ||||||||||
| 38 | isa => 'HashRef', | ||||||||||
| 39 | 0 | ▶ | default => sub { +{} }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 40 | 1 | ); | |||||||||
| 41 | |||||||||||
| 42 | 1 | has 'resource' => ( | |||||||||
| 43 | is => 'rw', | ||||||||||
| 44 | isa => 'Net::OpenSocial::Client::Resource', | ||||||||||
| 45 | predicate => 'has_resource', | ||||||||||
| 46 | ); | ||||||||||
| 47 | |||||||||||
| 48 | 1 | my %OP_METHOD_MAP = ( | |||||||||
| 49 | get => 'GET', | ||||||||||
| 50 | create => 'POST', | ||||||||||
| 51 | update => 'PUT', | ||||||||||
| 52 | delete => 'DELETE', | ||||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub rpc_service { | ||||||||
|
Subroutine
rpc_service: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | 0 | my $service = $self->service; | |||||||||
| 58 | 0 | ▶ | $service = 'activity' if $service eq 'activities'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | return $service; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub http_method_for_operation { | ||||||||
|
Subroutine
http_method_for_operation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | 0 | my $self = shift; | |||||||||
| 64 | 0 | return $OP_METHOD_MAP{ $self->operation }; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 1 | ▶ | no Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 69 | 1 | 1; | |||||||||
| 70 | |||||||||||
| 71 | =head1 NAME | ||||||||||
| 72 | |||||||||||
| 73 | Net::OpenSocial::Client::Request - Request class. | ||||||||||
| 74 | |||||||||||
| 75 | =head1 SYNOPSIS | ||||||||||
| 76 | |||||||||||
| 77 | use Net::OpenSocial::Client::Type::Service qw(PEOPLE, ACTIVITY); | ||||||||||
| 78 | use Net::OpenSocial::Client::Type::Operation qw(GET CREATE UPDATE DELETE); | ||||||||||
| 79 | |||||||||||
| 80 | my $req = Net::OpenSocial::Client::Request->new( | ||||||||||
| 81 | service => PEOPL, | ||||||||||
| 82 | operation => GET, | ||||||||||
| 83 | user_id => '@me', | ||||||||||
| 84 | group_id => '@friends', | ||||||||||
| 85 | params => { | ||||||||||
| 86 | itemsPerPage => 10, | ||||||||||
| 87 | startIndex => 11, | ||||||||||
| 88 | }, | ||||||||||
| 89 | ); | ||||||||||
| 90 | |||||||||||
| 91 | =head1 DESCRIPTION | ||||||||||
| 92 | |||||||||||
| 93 | This module represents a OpenSocial REST/RPC request. | ||||||||||
| 94 | For short circuit, there are many request subclasses like | ||||||||||
| 95 | L<Net::OpenSocial::Client::Request::FetchPerson>, | ||||||||||
| 96 | L<Net::OpenSocial::Client::Request::FetchFriends> and so on. | ||||||||||
| 97 | |||||||||||
| 98 | =head1 METHODS | ||||||||||
| 99 | |||||||||||
| 100 | =head2 id | ||||||||||
| 101 | |||||||||||
| 102 | Request id | ||||||||||
| 103 | |||||||||||
| 104 | =head2 service | ||||||||||
| 105 | |||||||||||
| 106 | Service type. | ||||||||||
| 107 | See L<Net::OpenSocial::Client::Type::Service> | ||||||||||
| 108 | |||||||||||
| 109 | =head2 operation | ||||||||||
| 110 | |||||||||||
| 111 | Operation type. | ||||||||||
| 112 | See L<Net::OpenSocial::Client::Type::Operation> | ||||||||||
| 113 | |||||||||||
| 114 | =head2 user_id | ||||||||||
| 115 | |||||||||||
| 116 | Service(container) specific user-id or selector like '@me' | ||||||||||
| 117 | |||||||||||
| 118 | =head2 group_id | ||||||||||
| 119 | |||||||||||
| 120 | Service(container) specific group-id or selector like '@self' or '@friends' | ||||||||||
| 121 | |||||||||||
| 122 | =head2 params | ||||||||||
| 123 | |||||||||||
| 124 | Other parameters | ||||||||||
| 125 | |||||||||||
| 126 | =head2 resource | ||||||||||
| 127 | |||||||||||
| 128 | L<Net::OpenSocial::Client::Resource> object, | ||||||||||
| 129 | This parameter is required when the operation is 'CREATE' or 'UPDATE' | ||||||||||
| 130 | |||||||||||
| 131 | =head2 rpc_service | ||||||||||
| 132 | |||||||||||
| 133 | RPC service name | ||||||||||
| 134 | |||||||||||
| 135 | =head2 http_method_for_operation | ||||||||||
| 136 | |||||||||||
| 137 | HTTP method name for current operation. | ||||||||||
| 138 | |||||||||||
| 139 | =head1 AUTHOR | ||||||||||
| 140 | |||||||||||
| 141 | Lyo Kato, E<lt>lyo.kato@gmail.comE<gt> | ||||||||||
| 142 | |||||||||||
| 143 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 144 | |||||||||||
| 145 | Copyright (C) 2009 by Lyo Kato | ||||||||||
| 146 | |||||||||||
| 147 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 148 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||||||||
| 149 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 150 | |||||||||||
| 151 | =cut | ||||||||||
| 152 | |||||||||||