| 1 | package WWW::Gitea::API::Users; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Gitea users API (lookup and search) | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use WWW::Gitea::User; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 4 | has client => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | required => 1, | ||||||||||
| 14 | weak_ref => 1, | ||||||||||
| 15 | ); | ||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | has openapi_operations => ( | ||||||||||
| 19 | is => 'lazy', | ||||||||||
| 20 | builder => sub { | ||||||||||
| 21 | return { | ||||||||||
| 22 | 0 | ▶ | 'users.get' => { method => 'GET', path => '/users/{username}' }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
_build_openapi_operations: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | 'users.search' => { method => 'GET', path => '/users/search' }, | ||||||||||
| 24 | }; | ||||||||||
| 25 | }, | ||||||||||
| 26 | 4 | ); | |||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 4 | with 'WWW::Gitea::Role::OpenAPI'; | |||||||||
| 30 | |||||||||||
| 31 | sub _wrap { | ||||||||||
| 32 | 0 | ▶ | my ($self, $data) = @_; | ||||||||
|
Subroutine
_wrap: not called CC=1 SCAR=6.9
| |||||||||||
| 33 | 0 | return WWW::Gitea::User->new(client => $self->client, data => $data); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub get { | ||||||||||
| 37 | 0 | ▶ | my ($self, $username) = @_; | ||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 38 | 0 | ▶ | croak 'username required' unless defined $username; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | my $data = $self->call_operation('users.get', | |||||||||
| 40 | path => { username => $username }); | ||||||||||
| 41 | 0 | return $self->_wrap($data); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | sub search { | ||||||||||
| 46 | 0 | ▶ | my ($self, %query) = @_; | ||||||||
|
Subroutine
search: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 47 | 0 | my $data = $self->call_operation('users.search', query => \%query); | |||||||||
| 48 | 0 | ▶ | return [ map { $self->_wrap($_) } @{ $data->{data} || [] } ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | 4 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||