ApiFactory.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 71 CC 3 SCAR 11.7
CC
3
Cov
0%
new
6.0
get_api
6.0
api_client
2.0
CRAP 3.2
1 =begin comment
2
3 Aspose.Diagram Cloud API Reference
4
5 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
7 OpenAPI spec version: 3.0
8
9 Generated by: https://github.com/swagger-api/swagger-codegen.git
10
11 =end comment
12
13 =cut
14
15 #
16 # NOTE: This class is auto generated by the swagger code generator program.
17 # Do not edit the class manually.
18 # Ref: https://github.com/swagger-api/swagger-codegen
19 #
20 package AsposeDiagramCloud::ApiFactory;
21
22 use strict;
23 use warnings;
24 use utf8;
25
26 use Carp;
27 use Module::Find;
28
29 usesub AsposeDiagramCloud::Object;
30
31 use AsposeDiagramCloud::ApiClient;
32
33 =head1 Name
34
35 AsposeDiagramCloud::ApiFactory - constructs APIs to retrieve AsposeDiagramCloud objects
36
37 =head1 Synopsis
38
39 package My::Petstore::App;
40
41 use AsposeDiagramCloud::ApiFactory;
42
43 my $api_factory = AsposeDiagramCloud::ApiFactory->new( ... ); # any args for ApiClient constructor
44
45 # later...
46 my $pet_api = $api_factory->get_api('Pet');
47
48 # $pet_api isa AsposeDiagramCloud::PetApi
49
50 my $pet = $pet_api->get_pet_by_id(pet_id => $pet_id);
51
52 # object attributes have proper accessors:
53 printf "Pet's name is %s", $pet->name;
54
55 # change the value stored on the object:
56 $pet->name('Dave');
57
58 =cut
59
60 # Load all the API classes and construct a lookup table at startup time
61 my %_apis = map { $_ =~ /^AsposeDiagramCloud::(.*)$/; $1 => $_ }
62 grep {$_ =~ /Api$/}
63 usesub 'AsposeDiagramCloud';
64
65 =head1 new($api_client)
66
67 create a new AsposeDiagramCloud::ApiFactory instance with the given AsposeDiagramCloud::ApiClient instance.
68
69 =head1 new(%parameters)
70
71 Any parameters are optional, and are passed to and stored on the api_client object.
72
73 See L<AsposeDiagramCloud::ApiClient> and L<AsposeDiagramCloud::Configuration> for valid parameters
74
75 =cut
76
77 sub new {
78 my ($class) = shift;
79
80 my $api_client;
81 if ($_[0] && ref $_[0] && ref $_[0] eq 'AsposeDiagramCloud::ApiClient' ) {
82 $api_client = $_[0];
83 } else {
84 $api_client = AsposeDiagramCloud::ApiClient->new(@_);
85 }
86 bless { api_client => $api_client }, $class;
87 }
88
89 =head1 get_api($which)
90
91 Returns an API object of the requested type.
92
93 $which is a nickname for the class:
94
95 FooBarClient::BazApi has nickname 'Baz'
96
97 =cut
98
99 sub get_api {
100 my ($self, $which) = @_;
101 croak "API not specified" unless $which;
102 my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
103 return $api_class->new($self->api_client);
104 }
105
106 =head1 api_client()
107
108 Returns the api_client object, should you ever need it.
109
110 =cut
111
112 sub api_client { $_[0]->{api_client} }
113
114 =head1 apis_available()
115 =cut
116
117 sub apis_available { return map { $_ =~ s/Api$//; $_ } sort keys %_apis }
118
119 =head1 classname_for()
120 =cut
121
122 sub classname_for {
123 my ($self, $api_name) = @_;
124 return $_apis{"${api_name}Api"};
125 }
126
127
128 1;