| 1 | # ABSTRACT: request class | ||||||||||||||||||||||||||||
| 2 | package PONAPI::Client::Request; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use JSON::XS qw< encode_json >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use PONAPI::Utils::URI qw< to_uri >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 7 | requires 'method'; | |||||||||||||||||||||||||||
| 11 | 7 | requires 'path'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub request_params { | ||||||||||||||||||||||||||||
| 14 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
request_params: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 7 | my $method = $self->method; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | return ( | ||||||||||||||||||||||||||||
| 19 | 7 | ▶ | method => $method, | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 20 | path => $self->path, | ||||||||||||||||||||||||||||
| 21 | ( $method eq 'GET' | ||||||||||||||||||||||||||||
| 22 | ? ( query_string => $self->_build_query_string ) | ||||||||||||||||||||||||||||
| 23 | : ( $self->can('data') | ||||||||||||||||||||||||||||
| 24 | ? ( body => encode_json( { data => $self->data } ) ) | ||||||||||||||||||||||||||||
| 25 | : () | ||||||||||||||||||||||||||||
| 26 | ) | ||||||||||||||||||||||||||||
| 27 | ) | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub _build_query_string { | ||||||||||||||||||||||||||||
| 32 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_query_string: called CC=11 SCAR=24.1
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 4 | my %u; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | ▶ | $u{filter} = $self->filter | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasFilter") and $self->has_filter
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasFilter") and $self->has_filter
$self->does("PONAPI::Client::Request::Role::HasFilter")
$self->has_filter
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasFilter")B= $self->has_filter
| |||||||||||||||||||||||||||||
| 37 | if $self->does('PONAPI::Client::Request::Role::HasFilter') and $self->has_filter; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 4 | ▶ | $u{fields} = $self->fields | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->does("PONAPI::Client::Request::Role::HasFields") and $self->has_fields
MC/DC100%2/2
$self->does("PONAPI::Client::Request::Role::HasFields") and $self->has_fields
$self->does("PONAPI::Client::Request::Role::HasFields")
$self->has_fields
Truth table100%3/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasFields")B= $self->has_fields
| |||||||||||||||||||||||||||||
| 40 | if $self->does('PONAPI::Client::Request::Role::HasFields') and $self->has_fields; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | $u{page} = $self->page | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasPage") and $self->has_page
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasPage") and $self->has_page
$self->does("PONAPI::Client::Request::Role::HasPage")
$self->has_page
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasPage")B= $self->has_page
| |||||||||||||||||||||||||||||
| 43 | if $self->does('PONAPI::Client::Request::Role::HasPage') and $self->has_page; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | ▶ | $u{include} = $self->include | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->does("PONAPI::Client::Request::Role::HasInclude") and $self->has_include
MC/DC100%2/2
$self->does("PONAPI::Client::Request::Role::HasInclude") and $self->has_include
$self->does("PONAPI::Client::Request::Role::HasInclude")
$self->has_include
Truth table100%3/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasInclude")B= $self->has_include
| |||||||||||||||||||||||||||||
| 46 | if $self->does('PONAPI::Client::Request::Role::HasInclude') and $self->has_include; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 4 | ▶ | $u{sort} = $self->sort | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasSort") and $self->has_sort
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasSort") and $self->has_sort
$self->does("PONAPI::Client::Request::Role::HasSort")
$self->has_sort
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasSort")B= $self->has_sort
| |||||||||||||||||||||||||||||
| 49 | if $self->does('PONAPI::Client::Request::Role::HasSort') and $self->has_sort; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | return to_uri( \%u ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 7 | ▶ | no Moose::Role; 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =pod | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | PONAPI::Client::Request - request class | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 VERSION | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | version 0.002003 | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =over 4 | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =item * | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Mickey Nasriachi <mickey@cpan.org> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item * | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | Stevan Little <stevan@cpan.org> | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =item * | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Brian Fraser <hugmeir@cpan.org> | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =back | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 93 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||||||||||