File Coverage

lib/Smartcat/Client/Object/ProjectModel.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::ProjectModel;
22              
23             require 5.6.0;
24 1     1   755 use strict;
  1         2  
  1         29  
25 1     1   5 use warnings;
  1         2  
  1         25  
26 1     1   617 use utf8;
  1         15  
  1         5  
27 1     1   632 use JSON qw(decode_json);
  1         8169  
  1         5  
28 1     1   718 use Data::Dumper;
  1         6698  
  1         65  
29 1     1   509 use Module::Runtime qw(use_module);
  1         1755  
  1         7  
30 1     1   529 use Log::Any qw($log);
  1         8256  
  1         6  
31 1     1   2658 use Date::Parse;
  1         7590  
  1         121  
32 1     1   866 use DateTime;
  1         518895  
  1         57  
33              
34 1     1   570 use Smartcat::Client::Object::DocumentModel;
  1         4  
  1         7  
35 1     1   507 use Smartcat::Client::Object::ProjectWorkflowStageModel;
  1         3  
  1         5  
36              
37 1     1   58 use base ( "Class::Accessor", "Class::Data::Inheritable" );
  1         2  
  1         1079  
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 654 my ( $class, %args ) = @_;
73              
74 1         3 my $self = bless {}, $class;
75              
76 1         3 foreach my $attribute ( keys %{ $class->attribute_map } ) {
  1         3  
77 17         231 my $args_key = $class->attribute_map->{$attribute};
78 17         134 $self->$attribute( $args{$args_key} );
79             }
80              
81 1         26 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 => 'ProjectModel',
151             required => [], # TODO
152             }
153             );
154              
155             __PACKAGE__->method_documentation(
156             {
157             'id' => {
158             datatype => 'string',
159             base_name => 'id',
160             description => '',
161             format => '',
162             read_only => '',
163             },
164             'name' => {
165             datatype => 'string',
166             base_name => 'name',
167             description => '',
168             format => '',
169             read_only => '',
170             },
171             'description' => {
172             datatype => 'string',
173             base_name => 'description',
174             description => '',
175             format => '',
176             read_only => '',
177             },
178             'deadline' => {
179             datatype => 'DateTime',
180             base_name => 'deadline',
181             description => '',
182             format => '',
183             read_only => '',
184             },
185             'creation_date' => {
186             datatype => 'DateTime',
187             base_name => 'creationDate',
188             description => '',
189             format => '',
190             read_only => '',
191             },
192             'created_by_user_id' => {
193             datatype => 'string',
194             base_name => 'createdByUserId',
195             description => '',
196             format => '',
197             read_only => '',
198             },
199             'modification_date' => {
200             datatype => 'DateTime',
201             base_name => 'modificationDate',
202             description => '',
203             format => '',
204             read_only => '',
205             },
206             'source_language' => {
207             datatype => 'string',
208             base_name => 'sourceLanguage',
209             description => '',
210             format => '',
211             read_only => '',
212             },
213             'target_languages' => {
214             datatype => 'ARRAY[string]',
215             base_name => 'targetLanguages',
216             description => '',
217             format => '',
218             read_only => '',
219             },
220             'status' => {
221             datatype => 'string',
222             base_name => 'status',
223             description => '',
224             format => '',
225             read_only => '',
226             },
227             'status_modification_date' => {
228             datatype => 'DateTime',
229             base_name => 'statusModificationDate',
230             description => '',
231             format => '',
232             read_only => '',
233             },
234             'domain_id' => {
235             datatype => 'int',
236             base_name => 'domainId',
237             description => '',
238             format => '',
239             read_only => '',
240             },
241             'client_id' => {
242             datatype => 'string',
243             base_name => 'clientId',
244             description => '',
245             format => '',
246             read_only => '',
247             },
248             'vendor_account_id' => {
249             datatype => 'string',
250             base_name => 'vendorAccountId',
251             description => '',
252             format => '',
253             read_only => '',
254             },
255             'workflow_stages' => {
256             datatype => 'ARRAY[ProjectWorkflowStageModel]',
257             base_name => 'workflowStages',
258             description => '',
259             format => '',
260             read_only => '',
261             },
262             'documents' => {
263             datatype => 'ARRAY[DocumentModel]',
264             base_name => 'documents',
265             description => '',
266             format => '',
267             read_only => '',
268             },
269             'external_tag' => {
270             datatype => 'string',
271             base_name => 'externalTag',
272             description => '',
273             format => '',
274             read_only => '',
275             },
276             }
277             );
278              
279             __PACKAGE__->swagger_types(
280             {
281             'id' => 'string',
282             'name' => 'string',
283             'description' => 'string',
284             'deadline' => 'DateTime',
285             'creation_date' => 'DateTime',
286             'created_by_user_id' => 'string',
287             'modification_date' => 'DateTime',
288             'source_language' => 'string',
289             'target_languages' => 'ARRAY[string]',
290             'status' => 'string',
291             'status_modification_date' => 'DateTime',
292             'domain_id' => 'int',
293             'client_id' => 'string',
294             'vendor_account_id' => 'string',
295             'workflow_stages' => 'ARRAY[ProjectWorkflowStageModel]',
296             'documents' => 'ARRAY[DocumentModel]',
297             'external_tag' => 'string'
298             }
299             );
300              
301             __PACKAGE__->attribute_map(
302             {
303             'id' => 'id',
304             'name' => 'name',
305             'description' => 'description',
306             'deadline' => 'deadline',
307             'creation_date' => 'creationDate',
308             'created_by_user_id' => 'createdByUserId',
309             'modification_date' => 'modificationDate',
310             'source_language' => 'sourceLanguage',
311             'target_languages' => 'targetLanguages',
312             'status' => 'status',
313             'status_modification_date' => 'statusModificationDate',
314             'domain_id' => 'domainId',
315             'client_id' => 'clientId',
316             'vendor_account_id' => 'vendorAccountId',
317             'workflow_stages' => 'workflowStages',
318             'documents' => 'documents',
319             'external_tag' => 'externalTag'
320             }
321             );
322              
323             __PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
324              
325             1;