]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm
16134a48b490d14dd11a5fd96c89b8a8fd9de141
[Evergreen.git] / OpenSRF / src / perlmods / OpenSRF / DomainObject / oilsMethod.pm
1 package OpenSRF::DomainObject::oilsMethod;
2
3 use JSON;
4 JSON->register_class_hint(hint => 'osrfMethod', class => 'OpenSRF::DomainObject::oilsMethod');
5
6 sub toString {
7         my $self = shift;
8         my $pretty = shift;
9         return JSON->perl2prettyJSON($self) if ($pretty);
10         return JSON->perl2JSON($self);
11 }
12
13
14 =head1 NAME
15
16 OpenSRF::DomainObject::oilsMethod
17
18 =head1 SYNOPSIS
19
20 use OpenSRF::DomainObject::oilsMethod;
21
22 my $method = OpenSRF::DomainObject::oilsMethod->new( method => 'search' );
23
24 $method->return_type( 'mods' );
25
26 $method->params( 'title:harry potter' );
27
28 $client->send( 'REQUEST', $method );
29
30 =head1 METHODS
31
32 =head2 OpenSRF::DomainObject::oilsMethod->method( [$new_method_name] )
33
34 =over 4
35
36 Sets or gets the method name that will be called on the server.  As above,
37 this can be specified as a build attribute as well as added to a prebuilt
38 oilsMethod object.
39
40 =back
41
42 =cut
43
44 sub method {
45         my $self = shift;
46         my $val = shift;
47         $self->{method} = $val if (defined $val);
48         return $self->{method};
49 }
50
51 =head2 OpenSRF::DomainObject::oilsMethod->return_type( [$new_return_type] )
52
53 =over 4
54
55 Sets or gets the return type for this method call.  This can also be supplied as
56 a build attribute.
57
58 This option does not require that the server return the type you request.  It is
59 used as a suggestion when more than one return type or format is possible.
60
61 =back
62
63 =cut
64
65
66 sub return_type {
67         my $self = shift;
68         my $val = shift;
69         $self->{return_type} = $val if (defined $val);
70         return $self->{return_type};
71 }
72
73 =head2 OpenSRF::DomainObject::oilsMethod->params( @new_params )
74
75 =over 4
76
77 Sets or gets the parameters for this method call.  Just pass in either text
78 parameters, or DOM nodes of any type.
79
80 =back
81
82 =cut
83
84
85 sub params {
86         my $self = shift;
87         my @args = @_;
88         $self->{params} = \@args if (@args);
89         return @{ $self->{params} };
90 }
91
92 1;