File Coverage

blib/lib/WebService/Pixela/User.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition 4 4 100.0
subroutine 9 9 100.0
pod 3 5 60.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             package WebService::Pixela::User;
2 6     6   215261 use 5.010001;
  6         24  
3 6     6   31 use strict;
  6         12  
  6         116  
4 6     6   26 use warnings;
  6         12  
  6         234  
5 6     6   30 use Carp qw/croak/;
  6         12  
  6         1969  
6              
7             our $VERSION = "0.021";
8              
9             sub new {
10 44     44 0 8386 my ($class,$pixela_client) = @_;
11 44         170 return bless +{
12             client => $pixela_client,
13             }, $class;
14             }
15              
16             sub client {
17 10     10 0 6419 my $self = shift;
18 10         38 return $self->{client};
19             }
20              
21             sub create {
22 2     2 1 1898 my ($self,%args) = @_;
23 2         6 my $client = $self->client;
24              
25             my $params = {
26             username => $client->username,
27             token => $client->token,
28             agreeTermsOfService => $args{agree_terms_of_service} || "yes",
29 2   100     9 notMinor => $args{not_minor} || "yes",
      100        
30             };
31 2         37 my $res = $client->request('POST','users/',$params);
32 2         23 return $res;
33             }
34              
35             sub update {
36 1     1 1 379 my ($self,$newtoken) = @_;
37 1         5 my $client = $self->client;
38              
39 1         3 my $params = {
40             newToken => $newtoken,
41             };
42 1         5 my $res = $client->request_with_xuser_in_header('PUT',('users/'.$client->username),$params);
43 1         11 $self->client->token($newtoken);
44 1         11 return $res;
45             }
46              
47             sub delete {
48 1     1 1 11 my $self = shift;
49 1         4 my $client = $self->client;
50              
51 1         5 my $res = $client->request_with_xuser_in_header('DELETE',('users/'.$client->username),{});
52 1         14 return $res;
53             }
54              
55              
56             1;
57             __END__