File Coverage

lib/Smartcat/Client/Object/ModelWithFilesIReadOnlyListCreateDocumentPropertyModel.pm
Criterion Covered Total %
statement 43 72 59.7
branch 0 10 0.0
condition n/a
subroutine 13 17 76.4
pod 1 4 25.0
total 57 103 55.3


line stmt bran cond sub pod time code
1              
2             =begin comment
3              
4             Smartcat Integration API
5              
6             No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
7              
8             OpenAPI spec version: v1
9              
10             Generated by: https://github.com/swagger-api/swagger-codegen.git
11              
12             =end comment
13              
14             =cut
15              
16             #
17             # NOTE: This class is auto generated by the swagger code generator program.
18             # Do not edit the class manually.
19             # Ref: https://github.com/swagger-api/swagger-codegen
20             #
21             package Smartcat::Client::Object::ModelWithFilesIReadOnlyListCreateDocumentPropertyModel;
22              
23             require 5.6.0;
24 1     1   745 use strict;
  1         2  
  1         31  
25 1     1   5 use warnings;
  1         2  
  1         26  
26 1     1   580 use utf8;
  1         15  
  1         5  
27 1     1   653 use JSON qw(decode_json);
  1         8447  
  1         5  
28 1     1   769 use Data::Dumper;
  1         6478  
  1         65  
29 1     1   521 use Module::Runtime qw(use_module);
  1         1884  
  1         6  
30 1     1   551 use Log::Any qw($log);
  1         8618  
  1         6  
31 1     1   2708 use Date::Parse;
  1         7933  
  1         152  
32 1     1   915 use DateTime;
  1         534899  
  1         60  
33              
34 1     1   537 use Smartcat::Client::Object::CreateDocumentPropertyModel;
  1         3  
  1         12  
35 1     1   459 use Smartcat::Client::Object::UploadedFile;
  1         3  
  1         7  
36              
37 1     1   61 use base ( "Class::Accessor", "Class::Data::Inheritable" );
  1         3  
  1         824  
38              
39             #
40             #
41             #
42             # NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
43             # REF: https://github.com/swagger-api/swagger-codegen
44             #
45              
46             =begin comment
47              
48             Smartcat Integration API
49              
50             No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
51              
52             OpenAPI spec version: v1
53              
54             Generated by: https://github.com/swagger-api/swagger-codegen.git
55              
56             =end comment
57              
58             =cut
59              
60             #
61             # NOTE: This class is auto generated by the swagger code generator program.
62             # Do not edit the class manually.
63             # Ref: https://github.com/swagger-api/swagger-codegen
64             #
65             __PACKAGE__->mk_classdata( 'attribute_map' => {} );
66             __PACKAGE__->mk_classdata( 'swagger_types' => {} );
67             __PACKAGE__->mk_classdata( 'method_documentation' => {} );
68             __PACKAGE__->mk_classdata( 'class_documentation' => {} );
69              
70             # new object
71             sub new {
72 1     1 1 644 my ( $class, %args ) = @_;
73              
74 1         3 my $self = bless {}, $class;
75              
76 1         2 foreach my $attribute ( keys %{ $class->attribute_map } ) {
  1         4  
77 2         32 my $args_key = $class->attribute_map->{$attribute};
78 2         21 $self->$attribute( $args{$args_key} );
79             }
80              
81 1         13 return $self;
82             }
83              
84             # return perl hash
85             sub to_hash {
86 0     0 0   return decode_json( JSON->new->convert_blessed->encode(shift) );
87             }
88              
89             # used by JSON for serialization
90             sub TO_JSON {
91 0     0 0   my $self = shift;
92 0           my $_data = {};
93 0           foreach my $_key ( keys %{ $self->attribute_map } ) {
  0            
94 0 0         if ( defined $self->{$_key} ) {
95 0           $_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
96             }
97             }
98 0           return $_data;
99             }
100              
101             # from Perl hashref
102             sub from_hash {
103 0     0 0   my ( $self, $hash ) = @_;
104              
105             # loop through attributes and use swagger_types to deserialize the data
106 0           while ( my ( $_key, $_type ) = each %{ $self->swagger_types } ) {
  0            
107 0           my $_json_attribute = $self->attribute_map->{$_key};
108 0 0         if ( $_type =~ /^array\[/i ) { # array
    0          
109 0           my $_subclass = substr( $_type, 6, -1 );
110 0           my @_array = ();
111 0           foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
  0            
112 0           push @_array, $self->_deserialize( $_subclass, $_element );
113             }
114 0           $self->{$_key} = \@_array;
115             }
116             elsif ( exists $hash->{$_json_attribute} )
117             { #hash(model), primitive, datetime
118             $self->{$_key} =
119 0           $self->_deserialize( $_type, $hash->{$_json_attribute} );
120             }
121             else {
122 0           $log->debugf( "Warning: %s (%s) does not exist in input hash\n",
123             $_key, $_json_attribute );
124             }
125             }
126              
127 0           return $self;
128             }
129              
130             # deserialize non-array data
131             sub _deserialize {
132 0     0     my ( $self, $type, $data ) = @_;
133 0           $log->debugf( "deserializing %s with %s", Dumper($data), $type );
134              
135 0 0         if ( $type eq 'DateTime' ) {
    0          
136 0           return DateTime->from_epoch( epoch => str2time($data) );
137             }
138             elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
139 0           return $data;
140             }
141             else { # hash(model)
142 0           my $_instance = eval "Smartcat::Client::Object::$type->new()";
143 0           return $_instance->from_hash($data);
144             }
145             }
146              
147             __PACKAGE__->class_documentation(
148             {
149             description => '',
150             class => 'ModelWithFilesIReadOnlyListCreateDocumentPropertyModel',
151             required => [], # TODO
152             }
153             );
154              
155             __PACKAGE__->method_documentation(
156             {
157             'value' => {
158             datatype => 'ARRAY[CreateDocumentPropertyModel]',
159             base_name => 'Value',
160             description => '',
161             format => '',
162             read_only => '',
163             },
164             'files' => {
165             datatype => 'ARRAY[UploadedFile]',
166             base_name => 'Files',
167             description => '',
168             format => '',
169             read_only => '',
170             },
171             }
172             );
173              
174             __PACKAGE__->swagger_types(
175             {
176             'value' => 'ARRAY[CreateDocumentPropertyModel]',
177             'files' => 'ARRAY[UploadedFile]'
178             }
179             );
180              
181             __PACKAGE__->attribute_map(
182             {
183             'value' => 'Value',
184             'files' => 'Files'
185             }
186             );
187              
188             __PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
189              
190             1;