| 1 | =begin comment | ||
| 2 | |||
| 3 | Copyright (c) 2026 Aspose.Cells Cloud | ||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 5 | of this software and associated documentation files (the "Software"), to deal | ||
| 6 | in the Software without restriction, including without limitation the rights | ||
| 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 8 | copies of the Software, and to permit persons to whom the Software is | ||
| 9 | furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in all | ||
| 12 | copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 20 | SOFTWARE. | ||
| 21 | |||
| 22 | =end comment | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | package AsposeCellsCloud::Object::AddTextOptions; | ||
| 27 | |||
| 28 | require 5.6.0; | ||
| 29 | use strict; | ||
| 30 | use warnings; | ||
| 31 | use utf8; | ||
| 32 | use JSON qw(decode_json); | ||
| 33 | use Data::Dumper; | ||
| 34 | use Module::Runtime qw(use_module); | ||
| 35 | use Log::Any qw($log); | ||
| 36 | use Date::Parse; | ||
| 37 | use DateTime; | ||
| 38 | use AsposeCellsCloud::Object::BaseOperateOptions; | ||
| 39 | use AsposeCellsCloud::Object::DataSource; | ||
| 40 | use AsposeCellsCloud::Object::FileInfo; | ||
| 41 | use AsposeCellsCloud::Object::ScopeOptions; | ||
| 42 | |||
| 43 | |||
| 44 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 49 | __PACKAGE__->mk_classdata('swagger_types' => {}); | ||
| 50 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 51 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 52 | |||
| 53 | # new object | ||
| 54 | sub new { | ||
| 55 | my ($class, %args) = @_; | ||
| 56 | |||
| 57 | my $self = bless {}, $class; | ||
| 58 | |||
| 59 | foreach my $attribute (keys %{$class->attribute_map}) { | ||
| 60 | my $args_key = $class->attribute_map->{$attribute}; | ||
| 61 | $self->$attribute( $args{ $args_key } ); | ||
| 62 | } | ||
| 63 | |||
| 64 | return $self; | ||
| 65 | } | ||
| 66 | |||
| 67 | # return perl hash | ||
| 68 | sub to_hash { | ||
| 69 | return decode_json(JSON->new->convert_blessed->encode( shift )); | ||
| 70 | } | ||
| 71 | |||
| 72 | # used by JSON for serialization | ||
| 73 | sub TO_JSON { | ||
| 74 | my $self = shift; | ||
| 75 | my $_data = {}; | ||
| 76 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 77 | if (defined $self->{$_key}) { | ||
| 78 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | return $_data; | ||
| 82 | } | ||
| 83 | |||
| 84 | # from Perl hashref | ||
| 85 | sub from_hash { | ||
| 86 | my ($self, $hash) = @_; | ||
| 87 | |||
| 88 | # loop through attributes and use swagger_types to deserialize the data | ||
| 89 | while ( my ($_key, $_type) = each %{$self->swagger_types} ) { | ||
| 90 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 91 | if ($_type =~ /^array\[/i) { # array | ||
| 92 | my $_subclass = substr($_type, 6, -1); | ||
| 93 | my @_array = (); | ||
| 94 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 95 | push @_array, $self->_deserialize($_subclass, $_element); | ||
| 96 | } | ||
| 97 | $self->{$_key} = \@_array; | ||
| 98 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 99 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); | ||
| 100 | } else { | ||
| 101 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | return $self; | ||
| 106 | } | ||
| 107 | |||
| 108 | # deserialize non-array data | ||
| 109 | sub _deserialize { | ||
| 110 | my ($self, $type, $data) = @_; | ||
| 111 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 112 | |||
| 113 | if ($type eq 'DateTime') { | ||
| 114 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 115 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 116 | return $data; | ||
| 117 | } else { # hash(model) | ||
| 118 | my $_instance = eval "AsposeCellsCloud::Object::$type->new()"; | ||
| 119 | return $_instance->from_hash($data); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | |||
| 124 | __PACKAGE__->class_documentation({description => 'Class summary: The features of this class include hands-on learning activities, group projects, interactive discussions, guest speakers, and field trips to real-world applications.', | ||
| 125 | class => 'AddTextOptions', | ||
| 126 | required => [], # TODO | ||
| 127 | } ); | ||
| 128 | |||
| 129 | |||
| 130 | __PACKAGE__->method_documentation({ | ||
| 131 | 'name' => { | ||
| 132 | datatype => 'string', | ||
| 133 | base_name => 'Name', | ||
| 134 | description => 'The class has a public property named "Name" with a getter and setter method.', | ||
| 135 | format => '', | ||
| 136 | read_only => '', | ||
| 137 | }, | ||
| 138 | 'data_source' => { | ||
| 139 | datatype => 'DataSource', | ||
| 140 | base_name => 'DataSource', | ||
| 141 | description => 'Represents data source. There are three types of data, they are CloudFileSystem, RequestFiles, HttpUri.', | ||
| 142 | format => '', | ||
| 143 | read_only => '', | ||
| 144 | }, | ||
| 145 | 'file_info' => { | ||
| 146 | datatype => 'FileInfo', | ||
| 147 | base_name => 'FileInfo', | ||
| 148 | description => 'Represents file information. Include of filename, filesize, and file content(base64String).', | ||
| 149 | format => '', | ||
| 150 | read_only => '', | ||
| 151 | }, | ||
| 152 | 'scope_options' => { | ||
| 153 | datatype => 'ScopeOptions', | ||
| 154 | base_name => 'ScopeOptions', | ||
| 155 | description => 'Specifies the range of cells within the worksheet where the spreadsheet operations will be performed. This parameter allows users to define the exact area to be processed, ensuring that operations are applied only to the designated cells.', | ||
| 156 | format => '', | ||
| 157 | read_only => '', | ||
| 158 | }, | ||
| 159 | 'text' => { | ||
| 160 | datatype => 'string', | ||
| 161 | base_name => 'Text', | ||
| 162 | description => 'Add text content.', | ||
| 163 | format => '', | ||
| 164 | read_only => '', | ||
| 165 | }, | ||
| 166 | 'select_poistion' => { | ||
| 167 | datatype => 'string', | ||
| 168 | base_name => 'SelectPoistion', | ||
| 169 | description => 'Represents where text should be inserted or selected in the spreadsheet.', | ||
| 170 | format => '', | ||
| 171 | read_only => '', | ||
| 172 | }, | ||
| 173 | 'select_text' => { | ||
| 174 | datatype => 'string', | ||
| 175 | base_name => 'SelectText', | ||
| 176 | description => 'Selected text of cell where text should be inserted or selected in the spreadsheet.', | ||
| 177 | format => '', | ||
| 178 | read_only => '', | ||
| 179 | }, | ||
| 180 | 'skip_empty_cells' => { | ||
| 181 | datatype => 'boolean', | ||
| 182 | base_name => 'SkipEmptyCells', | ||
| 183 | description => 'Indicates whether empty cells should be skipped during processing.', | ||
| 184 | format => '', | ||
| 185 | read_only => '', | ||
| 186 | }, | ||
| 187 | }); | ||
| 188 | |||
| 189 | __PACKAGE__->swagger_types( { | ||
| 190 | 'name' => 'string', | ||
| 191 | 'data_source' => 'DataSource', | ||
| 192 | 'file_info' => 'FileInfo', | ||
| 193 | 'scope_options' => 'ScopeOptions', | ||
| 194 | 'text' => 'string', | ||
| 195 | 'select_poistion' => 'string', | ||
| 196 | 'select_text' => 'string', | ||
| 197 | 'skip_empty_cells' => 'boolean' | ||
| 198 | } ); | ||
| 199 | |||
| 200 | __PACKAGE__->attribute_map( { | ||
| 201 | 'name' => 'Name', | ||
| 202 | 'data_source' => 'DataSource', | ||
| 203 | 'file_info' => 'FileInfo', | ||
| 204 | 'scope_options' => 'ScopeOptions', | ||
| 205 | 'text' => 'Text', | ||
| 206 | 'select_poistion' => 'SelectPoistion', | ||
| 207 | 'select_text' => 'SelectText', | ||
| 208 | 'skip_empty_cells' => 'SkipEmptyCells' | ||
| 209 | } ); | ||
| 210 | |||
| 211 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 212 | |||
| 213 | |||
| 214 | 1; |