ArangoDB2/User.pm

filter: Statementstmt 39.1% 18 / 46 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 35.7% 5 / 14 Podpod 100% 9 / 9 totaltotal 41.5% 32 / 77 CC 5 SCAR 12.5
CC
5
Cov
33%
create
6.0
get
6.0
update
6.0
CRAP 3.5
« ArangoDB2/Graph.pm ↑ Summary ArangoDB2/Traversal.pm »
1 package ArangoDB2::User;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 22 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 ArangoDB2::Base
8 22 );
9  
10 22 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 22 my $JSON = JSON::XS->new->utf8;
14  
15 22 my @PARAMS = qw(
16 active changePassword extra name passwd
17 );
18  
19  
20  
21 ###############
22 # API METHODS #
23 ###############
24  
25 # create
26 #
27 # POST /_api/user
28 sub create
29 0 ▶{
Subroutine create: not called CC=2 SCAR=17.9
Pod documented
30 0 my($self, $args) = @_;
31 # process request args
32 0 $args = $self->_build_args($args, \@PARAMS);
33 # use name for user param
34 0 $args->{user} = delete $args->{name};
35 # make request
36 0 ▶ my $res = $self->arango->http->post(
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->post($self->api_path("user"), undef, $JSON->encode($args)) or return 0 0 0
37 $self->api_path('user'),
38 undef,
39 $JSON->encode($args),
40 ) or return;
41 # if request was success copy args to self
42 0 $self->_build_self($res, \@PARAMS);
43  
44 0 return $self;
45 }
46  
47 # delete
48 #
49 # DELETE /_api/user/{user}
50 sub delete
51 0 ▶{
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
52 0 my($self, $args) = @_;
53 # process request args
54 0 $args = $self->_build_args($args, ['name']);
55 # make request
56 return $self->arango->http->delete(
57 0 $self->api_path('user', delete $args->{name}),
58 ) or return;
59 }
60  
61 # get
62 #
63 # GET /_api/user/{user}
64 sub get
65 0 ▶{
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
66 0 my($self, $args) = @_;
67 # process request args
68 0 $args = $self->_build_args($args, ['name']);
69 # make request
70 my $res = $self->arango->http->get(
71 0 ▶ $self->api_path('user', delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->get($self->api_path("user", delete $args->{"name"})) or return 0 0 0
72 ) or return;
73 # copy param data from res to self
74 0 $self->_build_self($res, \@PARAMS);
75  
76 0 return $self;
77 }
78  
79 # update
80 #
81 # PATCH /_api/user/{user}
82 sub update
83 0 ▶{
Subroutine update: not called CC=2 SCAR=17.9
Pod documented
84 0 my($self, $args) = @_;
85 # process request args
86 0 $args = $self->_build_args($args, \@PARAMS);
87 # make request
88 my $res = $self->arango->http->patch(
89 0 ▶ $self->api_path('user', delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->patch($self->api_path("user", delete $args->{"name"}), undef, $JSON->encode($args)) or return 0 0 0
90 undef,
91 $JSON->encode($args),
92 ) or return;
93 # if request was success copy args to self
94 0 $self->_build_self($res, \@PARAMS);
95  
96 0 return $self;
97 }
98  
99 # replace
100 #
101 # PUT /_api/user/{user}
102 sub replace
103 0 ▶{
Subroutine replace: not called CC=2 SCAR=17.9
Pod documented
104 0 my($self, $args) = @_;
105 # process request args
106 0 $args = $self->_build_args($args, \@PARAMS);
107 # make request
108 my $res = $self->arango->http->put(
109 0 ▶ $self->api_path('user', delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->put($self->api_path("user", delete $args->{"name"}), undef, $JSON->encode($args)) or return 0 0 0
110 undef,
111 $JSON->encode($args),
112 ) or return;
113 # if request was success copy args to self
114 0 $self->_build_self($res, \@PARAMS);
115  
116 0 return $self;
117 }
118  
119 ####################
120 # PROPERTY METHODS #
121 ####################
122  
123 0 ▶sub active { shift->_get_set_bool('active', @_) }
Subroutine active: not called CC=1 SCAR=6.9
Pod documented
124  
125 0 ▶sub changePassword { shift->_get_set_bool('changePassword', @_) }
Subroutine changePassword: not called CC=1 SCAR=6.9
Pod documented
126  
127 0 ▶sub extra { shift->_get_set('extra', @_) }
Subroutine extra: not called CC=1 SCAR=6.9
Pod documented
128  
129 0 ▶sub passwd { shift->_get_set('passwd', @_) }
Subroutine passwd: not called CC=1 SCAR=6.9
Pod documented
130  
131 22 1;
132  
133 __END__
« ArangoDB2/Graph.pm ↑ Summary ArangoDB2/Traversal.pm »