| 1 | package Flickr::API::Reflection; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use parent qw( Flickr::API ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | our $VERSION = '1.28'; | |||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub _initialize { | ||||||||
|
Subroutine
_initialize: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | |||||||||||
| 13 | 0 | my $self = shift; | |||||||||
| 14 | 0 | $self->_set_status(1,'API::Reflection initialized'); | |||||||||
| 15 | 0 | return; | |||||||||
| 16 | |||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub methods_list { | ||||||||
|
Subroutine
methods_list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | my $self = shift; | |||||||||
| 23 | 0 | my $rsp = $self->execute_method('flickr.reflection.getMethods'); | |||||||||
| 24 | 0 | $rsp->_propagate_status($self->{flickr}->{status}); | |||||||||
| 25 | 0 | my $listref = (); | |||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | if ($rsp->success() == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 0 | $listref = $rsp->as_hash()->{methods}->{method}; | |||||||||
| 30 | 0 | $self->_set_status(1,"flickr.reflection.getMethods returned " . $#{$listref} . " methods.") | |||||||||
| 31 | |||||||||||
| 32 | } | ||||||||||
| 33 | else { | ||||||||||
| 34 | |||||||||||
| 35 | 0 | $self->_set_status(0,"Flickr::API::Reflection Methods list/hash failed with response error"); | |||||||||
| 36 | 0 | carp "Flickr::API::Reflection Methods list/hash failed with error code: ",$rsp->error_code()," \n ", | |||||||||
| 37 | $rsp->error_message(),"\n"; | ||||||||||
| 38 | |||||||||||
| 39 | 0 | my $listref = (); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | return $listref; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub methods_hash { | ||||||||
|
Subroutine
methods_hash: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | my $self = shift; | |||||||||
| 51 | 0 | my $arrayref = $self->methods_list(); | |||||||||
| 52 | 0 | my $hashref; | |||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | if ($arrayref) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | |||||||||||
| 57 | 0 | %{$hashref} = map {$_ => 1} @{$arrayref}; | |||||||||
| 58 | |||||||||||
| 59 | } | ||||||||||
| 60 | else { | ||||||||||
| 61 | |||||||||||
| 62 | 0 | $hashref = {}; | |||||||||
| 63 | |||||||||||
| 64 | } | ||||||||||
| 65 | 0 | return $hashref; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub get_method { | ||||||||
|
Subroutine
get_method: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 70 | |||||||||||
| 71 | 0 | my $self = shift; | |||||||||
| 72 | 0 | my $method = shift; | |||||||||
| 73 | 0 | my $rsp = $self->execute_method('flickr.reflection.getMethodInfo', | |||||||||
| 74 | {'method_name' => $method}); | ||||||||||
| 75 | 0 | my $hash = $rsp->as_hash(); | |||||||||
| 76 | 0 | my $desc = {}; | |||||||||
| 77 | |||||||||||
| 78 | 0 | $rsp->_propagate_status($self->{flickr}->{status}); | |||||||||
| 79 | |||||||||||
| 80 | 0 | my $err; | |||||||||
| 81 | my $arg; | ||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | if ($rsp->success() == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | |||||||||||
| 85 | 0 | $self->_set_status(1,"flickr.reflection.getMethodInfo returned was successful"); | |||||||||
| 86 | |||||||||||
| 87 | 0 | $desc->{$method} = $hash->{method}; | |||||||||
| 88 | |||||||||||
| 89 | 0 | foreach $err (@{$hash->{errors}->{error}}) { | |||||||||
| 90 | |||||||||||
| 91 | 0 | $desc->{$method}->{error}->{$err->{code}}->{message} = $err->{message}; | |||||||||
| 92 | 0 | $desc->{$method}->{error}->{$err->{code}}->{content} = $err->{content}; | |||||||||
| 93 | |||||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 0 | ▶ | if ( ref($hash->{arguments}->{argument}) eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | |||||||||||
| 98 | 0 | foreach $arg (@{$hash->{arguments}->{argument}}) { | |||||||||
| 99 | |||||||||||
| 100 | 0 | $desc->{$method}->{argument}->{$arg->{name}}->{optional} = $arg->{optional}; | |||||||||
| 101 | 0 | $desc->{$method}->{argument}->{$arg->{name}}->{content} = $arg->{content}; | |||||||||
| 102 | |||||||||||
| 103 | } | ||||||||||
| 104 | } | ||||||||||
| 105 | else { | ||||||||||
| 106 | |||||||||||
| 107 | 0 | $arg = $hash->{arguments}->{argument}; | |||||||||
| 108 | 0 | $desc->{$method}->{argument}->{$arg->{name}}->{optional} = $arg->{optional}; | |||||||||
| 109 | 0 | $desc->{$method}->{argument}->{$arg->{name}}->{content} = $arg->{content}; | |||||||||
| 110 | |||||||||||
| 111 | } | ||||||||||
| 112 | } | ||||||||||
| 113 | else { | ||||||||||
| 114 | |||||||||||
| 115 | 0 | $self->_set_status(0,"Flickr::API::Reflection get_method failed with response error"); | |||||||||
| 116 | 0 | carp "Flickr::API::Reflection get method failed with error code: ",$rsp->error_code()," \n ", | |||||||||
| 117 | $rsp->error_message(),"\n"; | ||||||||||
| 118 | |||||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | 0 | return $desc; | |||||||||
| 122 | } # get_method | ||||||||||
| 123 | |||||||||||
| 124 | |||||||||||
| 125 | |||||||||||
| 126 | 1 | 1; | |||||||||
| 127 | |||||||||||
| 128 | __END__ | ||||||||||