OAuthApi.pm untested

filter: Statementstmt 0.0% 0 / 69 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 109 CC 10 SCAR 37.4
CC
10
Cov
0%
o_auth_post2
90.0
new
6.0
BEGIN
2.0
CRAP 42.0
1 =begin comment
2
3 Web API Swagger specification
4
5 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
7 OpenAPI spec version: 1.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::OAuthApi;
21
22 require 5.6.0;
23 use strict;
24 use warnings;
25 use utf8;
26 use Exporter;
27 use Carp qw( croak );
28 use Log::Any qw($log);
29
30 use AsposeDiagramCloud::ApiClient;
31
32 use base "Class::Data::Inheritable";
33
34 __PACKAGE__->mk_classdata('method_documentation' => {});
35
36 sub new {
37 my $class = shift;
38 my $api_client;
39
40 if ($_[0] && ref $_[0] && ref $_[0] eq 'AsposeDiagramCloud::ApiClient' ) {
41 $api_client = $_[0];
42 } else {
43 $api_client = AsposeDiagramCloud::ApiClient->new(@_);
44 }
45
46 bless { api_client => $api_client }, $class;
47
48 }
49
50
51 #
52 # o_auth_post
53 #
54 # Get Access token
55 #
56 # @param string $grant_type Grant Type (required)
57 # @param string $client_id App SID (required)
58 # @param string $client_secret App Key (required)
59 {
60 my $params = {
61 'grant_type' => {
62 data_type => 'string',
63 description => 'Grant Type',
64 required => '1',
65 },
66 'client_id' => {
67 data_type => 'string',
68 description => 'App SID',
69 required => '1',
70 },
71 'client_secret' => {
72 data_type => 'string',
73 description => 'App Key',
74 required => '1',
75 },
76 };
77 __PACKAGE__->method_documentation->{ 'o_auth_post' } = {
78 summary => 'Get Access token',
79 params => $params,
80 returns => 'AccessTokenResponse',
81 };
82 }
83 # @return AccessTokenResponse
84 #
85 sub o_auth_post2 {
86 my ($self, %args) = @_;
87
88 # verify the required parameter 'grant_type' is set
89 unless (exists $args{'grant_type'}) {
90 croak("Missing the required parameter 'grant_type' when calling o_auth_post");
91 }
92
93 # verify the required parameter 'client_id' is set
94 unless (exists $args{'client_id'}) {
95 croak("Missing the required parameter 'client_id' when calling o_auth_post");
96 }
97
98 # verify the required parameter 'client_secret' is set
99 unless (exists $args{'client_secret'}) {
100 croak("Missing the required parameter 'client_secret' when calling o_auth_post");
101 }
102
103 # parse inputs
104 my $_resource_path = '/connect/token';
105
106 my $_method = 'POST';
107 my $query_params = {};
108 my $header_params = {};
109 my $form_params = {};
110
111 # 'Accept' and 'Content-Type' header
112 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
113 if ($_header_accept) {
114 $header_params->{'Accept'} = $_header_accept;
115 }
116 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
117
118 # form params
119 if ( exists $args{'grant_type'} ) {
120 $form_params->{'grant_type'} = $self->{api_client}->to_form_value($args{'grant_type'});
121 }
122
123 # form params
124 if ( exists $args{'client_id'} ) {
125 $form_params->{'client_id'} = $self->{api_client}->to_form_value($args{'client_id'});
126 }
127
128 # form params
129 if ( exists $args{'client_secret'} ) {
130 $form_params->{'client_secret'} = $self->{api_client}->to_form_value($args{'client_secret'});
131 }
132
133 $self->{api_client}->check_access_token();
134 my $_body_data;
135 # authentication setting, if any
136 my $auth_settings = [qw()];
137
138 # make the API Call
139 my $response = $self->{api_client}->call_api($_resource_path, $_method,
140 $query_params, $form_params,
141 $header_params, $_body_data, $auth_settings);
142 if (!$response) {
143 return;
144 }
145 my $_response_object = $self->{api_client}->deserialize('AccessTokenResponse', $response);
146 return $_response_object;
147 }
148
149 1;