Fastly/ContactApi.pm untested

filter: Statementstmt 0.0% 0 / 136 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 204 CC 22 SCAR 40.9
CC
22
Cov
0%
create_contacts
132.0
delete_contact
56.0
list_contacts
30.0
CRAP 59.5
1 =begin comment
2  
3 Fastly API
4  
5 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
6  
7 The version of the API Spec document: 1.0.0
8 Contact: oss@fastly.com
9  
10 =end comment
11  
12 =cut
13  
14 #
15 # NOTE: This class is auto generated.
16 # Do not edit the class manually.
17 #
18 package WebService::Fastly::ContactApi;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use Exporter;
25 use Carp qw( croak );
26 use Log::Any qw($log);
27  
28 use WebService::Fastly::ApiClient;
29  
30 use base "Class::Data::Inheritable";
31  
32 __PACKAGE__->mk_classdata('method_documentation' => {});
33  
34 sub new {
35 my $class = shift;
36 my $api_client;
37  
38 if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) {
39 $api_client = $_[0];
40 } else {
41 $api_client = WebService::Fastly::ApiClient->new(@_);
42 }
43  
44 bless { api_client => $api_client }, $class;
45  
46 }
47  
48  
49 #
50 # create_contacts
51 #
52 # Add a new customer contact
53 #
54 # @param string $customer_id Alphanumeric string identifying the customer. (required)
55 # @param string $user_id The alphanumeric string representing the user for this customer contact. (optional)
56 # @param string $contact_type The type of contact. (optional)
57 # @param string $name The name of this contact, when user_id is not provided. (optional)
58 # @param string $email The email of this contact, when a user_id is not provided. (optional)
59 # @param string $phone The phone number for this contact. Required for primary, technical, and security contact types. (optional)
60 # @param string $customer_id The alphanumeric string representing the customer for this customer contact. (optional)
61 {
62 my $params = {
63 'customer_id' => {
64 data_type => 'string',
65 description => 'Alphanumeric string identifying the customer.',
66 required => '1',
67 },
68 'user_id' => {
69 data_type => 'string',
70 description => 'The alphanumeric string representing the user for this customer contact.',
71 required => '0',
72 },
73 'contact_type' => {
74 data_type => 'string',
75 description => 'The type of contact.',
76 required => '0',
77 },
78 'name' => {
79 data_type => 'string',
80 description => 'The name of this contact, when user_id is not provided.',
81 required => '0',
82 },
83 'email' => {
84 data_type => 'string',
85 description => 'The email of this contact, when a user_id is not provided.',
86 required => '0',
87 },
88 'phone' => {
89 data_type => 'string',
90 description => 'The phone number for this contact. Required for primary, technical, and security contact types.',
91 required => '0',
92 },
93 'customer_id' => {
94 data_type => 'string',
95 description => 'The alphanumeric string representing the customer for this customer contact.',
96 required => '0',
97 },
98 };
99 __PACKAGE__->method_documentation->{ 'create_contacts' } = {
100 summary => 'Add a new customer contact',
101 params => $params,
102 returns => 'ContactResponse',
103 };
104 }
105 # @return ContactResponse
106 #
107 sub create_contacts {
108 my ($self, %args) = @_;
109  
110 # verify the required parameter 'customer_id' is set
111 unless (exists $args{'customer_id'}) {
112 croak("Missing the required parameter 'customer_id' when calling create_contacts");
113 }
114  
115 # parse inputs
116 my $_resource_path = '/customer/{customer_id}/contacts';
117  
118 my $_method = 'POST';
119 my $query_params = {};
120 my $header_params = {};
121 my $form_params = {};
122  
123 # 'Accept' and 'Content-Type' header
124 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
125 if ($_header_accept) {
126 $header_params->{'Accept'} = $_header_accept;
127 }
128 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
129  
130 # path params
131 if ( exists $args{'customer_id'}) {
132 my $_base_variable = "{" . "customer_id" . "}";
133 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
134 $_resource_path =~ s/$_base_variable/$_base_value/g;
135 }
136  
137 # form params
138 if ( exists $args{'user_id'} ) {
139 $form_params->{'user_id'} = $self->{api_client}->to_form_value($args{'user_id'});
140 }
141  
142 # form params
143 if ( exists $args{'contact_type'} ) {
144 $form_params->{'contact_type'} = $self->{api_client}->to_form_value($args{'contact_type'});
145 }
146  
147 # form params
148 if ( exists $args{'name'} ) {
149 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
150 }
151  
152 # form params
153 if ( exists $args{'email'} ) {
154 $form_params->{'email'} = $self->{api_client}->to_form_value($args{'email'});
155 }
156  
157 # form params
158 if ( exists $args{'phone'} ) {
159 $form_params->{'phone'} = $self->{api_client}->to_form_value($args{'phone'});
160 }
161  
162 # form params
163 if ( exists $args{'customer_id'} ) {
164 $form_params->{'customer_id'} = $self->{api_client}->to_form_value($args{'customer_id'});
165 }
166  
167 my $_body_data;
168 # authentication setting, if any
169 my $auth_settings = [qw(token )];
170  
171 # make the API Call
172 my $response = $self->{api_client}->call_api($_resource_path, $_method,
173 $query_params, $form_params,
174 $header_params, $_body_data, $auth_settings);
175 if (!$response) {
176 return;
177 }
178 my $_response_object = $self->{api_client}->deserialize('ContactResponse', $response);
179 return $_response_object;
180 }
181  
182 #
183 # delete_contact
184 #
185 # Delete a contact
186 #
187 # @param string $customer_id Alphanumeric string identifying the customer. (required)
188 # @param string $contact_id An alphanumeric string identifying the customer contact. (required)
189 {
190 my $params = {
191 'customer_id' => {
192 data_type => 'string',
193 description => 'Alphanumeric string identifying the customer.',
194 required => '1',
195 },
196 'contact_id' => {
197 data_type => 'string',
198 description => 'An alphanumeric string identifying the customer contact.',
199 required => '1',
200 },
201 };
202 __PACKAGE__->method_documentation->{ 'delete_contact' } = {
203 summary => 'Delete a contact',
204 params => $params,
205 returns => 'InlineResponse200',
206 };
207 }
208 # @return InlineResponse200
209 #
210 sub delete_contact {
211 my ($self, %args) = @_;
212  
213 # verify the required parameter 'customer_id' is set
214 unless (exists $args{'customer_id'}) {
215 croak("Missing the required parameter 'customer_id' when calling delete_contact");
216 }
217  
218 # verify the required parameter 'contact_id' is set
219 unless (exists $args{'contact_id'}) {
220 croak("Missing the required parameter 'contact_id' when calling delete_contact");
221 }
222  
223 # parse inputs
224 my $_resource_path = '/customer/{customer_id}/contacts/{contact_id}';
225  
226 my $_method = 'DELETE';
227 my $query_params = {};
228 my $header_params = {};
229 my $form_params = {};
230  
231 # 'Accept' and 'Content-Type' header
232 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
233 if ($_header_accept) {
234 $header_params->{'Accept'} = $_header_accept;
235 }
236 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
237  
238 # path params
239 if ( exists $args{'customer_id'}) {
240 my $_base_variable = "{" . "customer_id" . "}";
241 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
242 $_resource_path =~ s/$_base_variable/$_base_value/g;
243 }
244  
245 # path params
246 if ( exists $args{'contact_id'}) {
247 my $_base_variable = "{" . "contact_id" . "}";
248 my $_base_value = $self->{api_client}->to_path_value($args{'contact_id'});
249 $_resource_path =~ s/$_base_variable/$_base_value/g;
250 }
251  
252 my $_body_data;
253 # authentication setting, if any
254 my $auth_settings = [qw(token )];
255  
256 # make the API Call
257 my $response = $self->{api_client}->call_api($_resource_path, $_method,
258 $query_params, $form_params,
259 $header_params, $_body_data, $auth_settings);
260 if (!$response) {
261 return;
262 }
263 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
264 return $_response_object;
265 }
266  
267 #
268 # list_contacts
269 #
270 # List contacts
271 #
272 # @param string $customer_id Alphanumeric string identifying the customer. (required)
273 {
274 my $params = {
275 'customer_id' => {
276 data_type => 'string',
277 description => 'Alphanumeric string identifying the customer.',
278 required => '1',
279 },
280 };
281 __PACKAGE__->method_documentation->{ 'list_contacts' } = {
282 summary => 'List contacts',
283 params => $params,
284 returns => 'ARRAY[SchemasContactResponse]',
285 };
286 }
287 # @return ARRAY[SchemasContactResponse]
288 #
289 sub list_contacts {
290 my ($self, %args) = @_;
291  
292 # verify the required parameter 'customer_id' is set
293 unless (exists $args{'customer_id'}) {
294 croak("Missing the required parameter 'customer_id' when calling list_contacts");
295 }
296  
297 # parse inputs
298 my $_resource_path = '/customer/{customer_id}/contacts';
299  
300 my $_method = 'GET';
301 my $query_params = {};
302 my $header_params = {};
303 my $form_params = {};
304  
305 # 'Accept' and 'Content-Type' header
306 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
307 if ($_header_accept) {
308 $header_params->{'Accept'} = $_header_accept;
309 }
310 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
311  
312 # path params
313 if ( exists $args{'customer_id'}) {
314 my $_base_variable = "{" . "customer_id" . "}";
315 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
316 $_resource_path =~ s/$_base_variable/$_base_value/g;
317 }
318  
319 my $_body_data;
320 # authentication setting, if any
321 my $auth_settings = [qw(token )];
322  
323 # make the API Call
324 my $response = $self->{api_client}->call_api($_resource_path, $_method,
325 $query_params, $form_params,
326 $header_params, $_body_data, $auth_settings);
327 if (!$response) {
328 return;
329 }
330 my $_response_object = $self->{api_client}->deserialize('ARRAY[SchemasContactResponse]', $response);
331 return $_response_object;
332 }
333  
334 1;