aspose_pdf_cloud 24.7.0 → 24.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -573,6 +573,95 @@ module AsposePdfCloud
573
573
  return data, status_code, headers
574
574
  end
575
575
 
576
+ # Remove document layer.
577
+ #
578
+ # @param name The document name.
579
+ # @param page_number Layer page.
580
+ # @param layer_id Layer Id.
581
+ # @param [Hash] opts the optional parameters
582
+ # @option opts [String] :folder The document folder.
583
+ # @option opts [String] :storage The document storage.
584
+ # @option opts [String] :pass_base64 The password (Base64).
585
+ # @return [AsposeResponse]
586
+ def delete_document_layer(name, page_number, layer_id, opts = {})
587
+ @api_client.request_token_if_needed
588
+ data, _status_code, _headers = delete_document_layer_with_http_info(name, page_number, layer_id, opts)
589
+ rescue ApiError => error
590
+ if error.code == 401
591
+ @api_client.request_token_if_needed
592
+ data, _status_code, _headers = delete_document_layer_with_http_info(name, page_number, layer_id, opts)
593
+ else
594
+ raise
595
+ end
596
+ return data
597
+ end
598
+
599
+ # Remove document layer.
600
+ #
601
+ # @param name The document name.
602
+ # @param page_number Layer page.
603
+ # @param layer_id Layer Id.
604
+ # @param [Hash] opts the optional parameters
605
+ # @option opts [String] :folder The document folder.
606
+ # @option opts [String] :storage The document storage.
607
+ # @option opts [String] :pass_base64 The password (Base64).
608
+ # @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
609
+ def delete_document_layer_with_http_info(name, page_number, layer_id, opts = {})
610
+ if @api_client.config.debugging
611
+ @api_client.config.logger.debug "Calling API: PdfApi.delete_document_layer ..."
612
+ end
613
+ # verify the required parameter 'name' is set
614
+ if @api_client.config.client_side_validation && name.nil?
615
+ fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.delete_document_layer"
616
+ end
617
+ # verify the required parameter 'page_number' is set
618
+ if @api_client.config.client_side_validation && page_number.nil?
619
+ fail ArgumentError, "Missing the required parameter 'page_number' when calling PdfApi.delete_document_layer"
620
+ end
621
+ # verify the required parameter 'layer_id' is set
622
+ if @api_client.config.client_side_validation && layer_id.nil?
623
+ fail ArgumentError, "Missing the required parameter 'layer_id' when calling PdfApi.delete_document_layer"
624
+ end
625
+ # resource path
626
+ local_var_path = "/pdf/{name}/layers".sub('{' + 'name' + '}', name.to_s)
627
+
628
+ # query parameters
629
+ query_params = {}
630
+ query_params[:'pageNumber'] = page_number
631
+ query_params[:'layerId'] = layer_id
632
+ query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
633
+ query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
634
+ query_params[:'passBase64'] = opts[:'pass_base64'] if !opts[:'pass_base64'].nil?
635
+
636
+ # header parameters
637
+ header_params = {}
638
+ # HTTP header 'Accept' (if needed)
639
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
640
+ # HTTP header 'Content-Type'
641
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
642
+
643
+ # form parameters
644
+ form_params = {}
645
+ # Fix header in file
646
+ post_body = nil
647
+
648
+ # http body (model)
649
+ # Fix header in file
650
+ # post_body = nil
651
+ auth_names = ['JWT']
652
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
653
+ :header_params => header_params,
654
+ :query_params => query_params,
655
+ :form_params => form_params,
656
+ :body => post_body,
657
+ :auth_names => auth_names,
658
+ :return_type => 'AsposeResponse')
659
+ if @api_client.config.debugging
660
+ @api_client.config.logger.debug "API called: PdfApi#delete_document_layer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
661
+ end
662
+ return data, status_code, headers
663
+ end
664
+
576
665
  # Delete all link annotations from the document
577
666
  #
578
667
  # @param name The document name.
@@ -3505,6 +3594,81 @@ module AsposePdfCloud
3505
3594
  return data, status_code, headers
3506
3595
  end
3507
3596
 
3597
+ # Gets document layers.
3598
+ #
3599
+ # @param name The document name.
3600
+ # @param [Hash] opts the optional parameters
3601
+ # @option opts [String] :folder The document folder.
3602
+ # @option opts [String] :storage The document storage.
3603
+ # @option opts [String] :pass_base64 The password (Base64).
3604
+ # @return [DocumentLayers]
3605
+ def get_document_layers(name, opts = {})
3606
+ @api_client.request_token_if_needed
3607
+ data, _status_code, _headers = get_document_layers_with_http_info(name, opts)
3608
+ rescue ApiError => error
3609
+ if error.code == 401
3610
+ @api_client.request_token_if_needed
3611
+ data, _status_code, _headers = get_document_layers_with_http_info(name, opts)
3612
+ else
3613
+ raise
3614
+ end
3615
+ return data
3616
+ end
3617
+
3618
+ # Gets document layers.
3619
+ #
3620
+ # @param name The document name.
3621
+ # @param [Hash] opts the optional parameters
3622
+ # @option opts [String] :folder The document folder.
3623
+ # @option opts [String] :storage The document storage.
3624
+ # @option opts [String] :pass_base64 The password (Base64).
3625
+ # @return [Array<(DocumentLayers, Fixnum, Hash)>] DocumentLayers data, response status code and response headers
3626
+ def get_document_layers_with_http_info(name, opts = {})
3627
+ if @api_client.config.debugging
3628
+ @api_client.config.logger.debug "Calling API: PdfApi.get_document_layers ..."
3629
+ end
3630
+ # verify the required parameter 'name' is set
3631
+ if @api_client.config.client_side_validation && name.nil?
3632
+ fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.get_document_layers"
3633
+ end
3634
+ # resource path
3635
+ local_var_path = "/pdf/{name}/layers".sub('{' + 'name' + '}', name.to_s)
3636
+
3637
+ # query parameters
3638
+ query_params = {}
3639
+ query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
3640
+ query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
3641
+ query_params[:'passBase64'] = opts[:'pass_base64'] if !opts[:'pass_base64'].nil?
3642
+
3643
+ # header parameters
3644
+ header_params = {}
3645
+ # HTTP header 'Accept' (if needed)
3646
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
3647
+ # HTTP header 'Content-Type'
3648
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
3649
+
3650
+ # form parameters
3651
+ form_params = {}
3652
+ # Fix header in file
3653
+ post_body = nil
3654
+
3655
+ # http body (model)
3656
+ # Fix header in file
3657
+ # post_body = nil
3658
+ auth_names = ['JWT']
3659
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
3660
+ :header_params => header_params,
3661
+ :query_params => query_params,
3662
+ :form_params => form_params,
3663
+ :body => post_body,
3664
+ :auth_names => auth_names,
3665
+ :return_type => 'DocumentLayers')
3666
+ if @api_client.config.debugging
3667
+ @api_client.config.logger.debug "API called: PdfApi#get_document_layers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
3668
+ end
3669
+ return data, status_code, headers
3670
+ end
3671
+
3508
3672
  # Read document line annotations.
3509
3673
  #
3510
3674
  # @param name The document name.
@@ -15608,6 +15772,86 @@ module AsposePdfCloud
15608
15772
  return data, status_code, headers
15609
15773
  end
15610
15774
 
15775
+ # Add document pages image stamps.
15776
+ #
15777
+ # @param name The document name.
15778
+ # @param stamps The array of stamp.
15779
+ # @param [Hash] opts the optional parameters
15780
+ # @option opts [String] :storage The document storage.
15781
+ # @option opts [String] :folder The document folder.
15782
+ # @option opts [String] :password Base64 encoded password.
15783
+ # @return [AsposeResponse]
15784
+ def post_document_image_stamps(name, stamps, opts = {})
15785
+ @api_client.request_token_if_needed
15786
+ data, _status_code, _headers = post_document_image_stamps_with_http_info(name, stamps, opts)
15787
+ rescue ApiError => error
15788
+ if error.code == 401
15789
+ @api_client.request_token_if_needed
15790
+ data, _status_code, _headers = post_document_image_stamps_with_http_info(name, stamps, opts)
15791
+ else
15792
+ raise
15793
+ end
15794
+ return data
15795
+ end
15796
+
15797
+ # Add document pages image stamps.
15798
+ #
15799
+ # @param name The document name.
15800
+ # @param stamps The array of stamp.
15801
+ # @param [Hash] opts the optional parameters
15802
+ # @option opts [String] :storage The document storage.
15803
+ # @option opts [String] :folder The document folder.
15804
+ # @option opts [String] :password Base64 encoded password.
15805
+ # @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
15806
+ def post_document_image_stamps_with_http_info(name, stamps, opts = {})
15807
+ if @api_client.config.debugging
15808
+ @api_client.config.logger.debug "Calling API: PdfApi.post_document_image_stamps ..."
15809
+ end
15810
+ # verify the required parameter 'name' is set
15811
+ if @api_client.config.client_side_validation && name.nil?
15812
+ fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.post_document_image_stamps"
15813
+ end
15814
+ # verify the required parameter 'stamps' is set
15815
+ if @api_client.config.client_side_validation && stamps.nil?
15816
+ fail ArgumentError, "Missing the required parameter 'stamps' when calling PdfApi.post_document_image_stamps"
15817
+ end
15818
+ # resource path
15819
+ local_var_path = "/pdf/{name}/stamps/image".sub('{' + 'name' + '}', name.to_s)
15820
+
15821
+ # query parameters
15822
+ query_params = {}
15823
+ query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
15824
+ query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
15825
+ query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?
15826
+
15827
+ # header parameters
15828
+ header_params = {}
15829
+ # HTTP header 'Accept' (if needed)
15830
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
15831
+ # HTTP header 'Content-Type'
15832
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
15833
+
15834
+ # form parameters
15835
+ form_params = {}
15836
+ # Fix header in file
15837
+ post_body = nil
15838
+
15839
+ # http body (model)
15840
+ post_body = @api_client.object_to_http_body(stamps)
15841
+ auth_names = ['JWT']
15842
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
15843
+ :header_params => header_params,
15844
+ :query_params => query_params,
15845
+ :form_params => form_params,
15846
+ :body => post_body,
15847
+ :auth_names => auth_names,
15848
+ :return_type => 'AsposeResponse')
15849
+ if @api_client.config.debugging
15850
+ @api_client.config.logger.debug "API called: PdfApi#post_document_image_stamps\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
15851
+ end
15852
+ return data, status_code, headers
15853
+ end
15854
+
15611
15855
  # Add document page number stamps.
15612
15856
  #
15613
15857
  # @param name The document name.
@@ -15937,6 +16181,86 @@ module AsposePdfCloud
15937
16181
  return data, status_code, headers
15938
16182
  end
15939
16183
 
16184
+ # Add document pages text stamps.
16185
+ #
16186
+ # @param name The document name.
16187
+ # @param stamps The array of stamp.
16188
+ # @param [Hash] opts the optional parameters
16189
+ # @option opts [String] :storage The document storage.
16190
+ # @option opts [String] :folder The document folder.
16191
+ # @option opts [String] :password Base64 encoded password.
16192
+ # @return [AsposeResponse]
16193
+ def post_document_text_stamps(name, stamps, opts = {})
16194
+ @api_client.request_token_if_needed
16195
+ data, _status_code, _headers = post_document_text_stamps_with_http_info(name, stamps, opts)
16196
+ rescue ApiError => error
16197
+ if error.code == 401
16198
+ @api_client.request_token_if_needed
16199
+ data, _status_code, _headers = post_document_text_stamps_with_http_info(name, stamps, opts)
16200
+ else
16201
+ raise
16202
+ end
16203
+ return data
16204
+ end
16205
+
16206
+ # Add document pages text stamps.
16207
+ #
16208
+ # @param name The document name.
16209
+ # @param stamps The array of stamp.
16210
+ # @param [Hash] opts the optional parameters
16211
+ # @option opts [String] :storage The document storage.
16212
+ # @option opts [String] :folder The document folder.
16213
+ # @option opts [String] :password Base64 encoded password.
16214
+ # @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
16215
+ def post_document_text_stamps_with_http_info(name, stamps, opts = {})
16216
+ if @api_client.config.debugging
16217
+ @api_client.config.logger.debug "Calling API: PdfApi.post_document_text_stamps ..."
16218
+ end
16219
+ # verify the required parameter 'name' is set
16220
+ if @api_client.config.client_side_validation && name.nil?
16221
+ fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.post_document_text_stamps"
16222
+ end
16223
+ # verify the required parameter 'stamps' is set
16224
+ if @api_client.config.client_side_validation && stamps.nil?
16225
+ fail ArgumentError, "Missing the required parameter 'stamps' when calling PdfApi.post_document_text_stamps"
16226
+ end
16227
+ # resource path
16228
+ local_var_path = "/pdf/{name}/stamps/text".sub('{' + 'name' + '}', name.to_s)
16229
+
16230
+ # query parameters
16231
+ query_params = {}
16232
+ query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
16233
+ query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
16234
+ query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?
16235
+
16236
+ # header parameters
16237
+ header_params = {}
16238
+ # HTTP header 'Accept' (if needed)
16239
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
16240
+ # HTTP header 'Content-Type'
16241
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
16242
+
16243
+ # form parameters
16244
+ form_params = {}
16245
+ # Fix header in file
16246
+ post_body = nil
16247
+
16248
+ # http body (model)
16249
+ post_body = @api_client.object_to_http_body(stamps)
16250
+ auth_names = ['JWT']
16251
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
16252
+ :header_params => header_params,
16253
+ :query_params => query_params,
16254
+ :form_params => form_params,
16255
+ :body => post_body,
16256
+ :auth_names => auth_names,
16257
+ :return_type => 'AsposeResponse')
16258
+ if @api_client.config.debugging
16259
+ @api_client.config.logger.debug "API called: PdfApi#post_document_text_stamps\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
16260
+ end
16261
+ return data, status_code, headers
16262
+ end
16263
+
15940
16264
  # Encrypt document in storage.
15941
16265
  #
15942
16266
  # @param name Document name.
@@ -20674,6 +20998,102 @@ module AsposePdfCloud
20674
20998
  return data, status_code, headers
20675
20999
  end
20676
21000
 
21001
+ # Create a separate PDF from a PDF Layer and upload resulting file to storage.
21002
+ #
21003
+ # @param name The document name.
21004
+ # @param page_number The page number.
21005
+ # @param out_path The out path of result image.
21006
+ # @param layer_id Layer Id.
21007
+ # @param [Hash] opts the optional parameters
21008
+ # @option opts [String] :folder The document folder.
21009
+ # @option opts [String] :storage The document storage.
21010
+ # @option opts [String] :pass_base64 The password (Base64).
21011
+ # @return [AsposeResponse]
21012
+ def put_create_pdf_from_layer(name, page_number, out_path, layer_id, opts = {})
21013
+ @api_client.request_token_if_needed
21014
+ data, _status_code, _headers = put_create_pdf_from_layer_with_http_info(name, page_number, out_path, layer_id, opts)
21015
+ rescue ApiError => error
21016
+ if error.code == 401
21017
+ @api_client.request_token_if_needed
21018
+ data, _status_code, _headers = put_create_pdf_from_layer_with_http_info(name, page_number, out_path, layer_id, opts)
21019
+ else
21020
+ raise
21021
+ end
21022
+ return data
21023
+ end
21024
+
21025
+ # Create a separate PDF from a PDF Layer and upload resulting file to storage.
21026
+ #
21027
+ # @param name The document name.
21028
+ # @param page_number The page number.
21029
+ # @param out_path The out path of result image.
21030
+ # @param layer_id Layer Id.
21031
+ # @param [Hash] opts the optional parameters
21032
+ # @option opts [String] :folder The document folder.
21033
+ # @option opts [String] :storage The document storage.
21034
+ # @option opts [String] :pass_base64 The password (Base64).
21035
+ # @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
21036
+ def put_create_pdf_from_layer_with_http_info(name, page_number, out_path, layer_id, opts = {})
21037
+ if @api_client.config.debugging
21038
+ @api_client.config.logger.debug "Calling API: PdfApi.put_create_pdf_from_layer ..."
21039
+ end
21040
+ # verify the required parameter 'name' is set
21041
+ if @api_client.config.client_side_validation && name.nil?
21042
+ fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.put_create_pdf_from_layer"
21043
+ end
21044
+ # verify the required parameter 'page_number' is set
21045
+ if @api_client.config.client_side_validation && page_number.nil?
21046
+ fail ArgumentError, "Missing the required parameter 'page_number' when calling PdfApi.put_create_pdf_from_layer"
21047
+ end
21048
+ # verify the required parameter 'out_path' is set
21049
+ if @api_client.config.client_side_validation && out_path.nil?
21050
+ fail ArgumentError, "Missing the required parameter 'out_path' when calling PdfApi.put_create_pdf_from_layer"
21051
+ end
21052
+ # verify the required parameter 'layer_id' is set
21053
+ if @api_client.config.client_side_validation && layer_id.nil?
21054
+ fail ArgumentError, "Missing the required parameter 'layer_id' when calling PdfApi.put_create_pdf_from_layer"
21055
+ end
21056
+ # resource path
21057
+ local_var_path = "/pdf/{name}/layers".sub('{' + 'name' + '}', name.to_s)
21058
+
21059
+ # query parameters
21060
+ query_params = {}
21061
+ query_params[:'pageNumber'] = page_number
21062
+ query_params[:'outPath'] = out_path
21063
+ query_params[:'layerId'] = layer_id
21064
+ query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
21065
+ query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
21066
+ query_params[:'passBase64'] = opts[:'pass_base64'] if !opts[:'pass_base64'].nil?
21067
+
21068
+ # header parameters
21069
+ header_params = {}
21070
+ # HTTP header 'Accept' (if needed)
21071
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
21072
+ # HTTP header 'Content-Type'
21073
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
21074
+
21075
+ # form parameters
21076
+ form_params = {}
21077
+ # Fix header in file
21078
+ post_body = nil
21079
+
21080
+ # http body (model)
21081
+ # Fix header in file
21082
+ # post_body = nil
21083
+ auth_names = ['JWT']
21084
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
21085
+ :header_params => header_params,
21086
+ :query_params => query_params,
21087
+ :form_params => form_params,
21088
+ :body => post_body,
21089
+ :auth_names => auth_names,
21090
+ :return_type => 'AsposeResponse')
21091
+ if @api_client.config.debugging
21092
+ @api_client.config.logger.debug "API called: PdfApi#put_create_pdf_from_layer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
21093
+ end
21094
+ return data, status_code, headers
21095
+ end
21096
+
20677
21097
  # Decrypt document from content.
20678
21098
  #
20679
21099
  # @param out_path Full resulting filename (ex. /folder1/folder2/result.doc)
@@ -464,8 +464,16 @@ module AsposePdfCloud
464
464
  end
465
465
 
466
466
  response = conn.post tokenUrl, form_params, req_opts[:body]
467
- data = JSON.parse("[#{response.body}]", :symbolize_names => true)[0]
467
+
468
+ begin
469
+ data = JSON.parse("[#{response.body}]", :symbolize_names => true)[0]
470
+ rescue Exception => exception
471
+ raise ApiError.new(response.body)
472
+ end
468
473
 
474
+ if data.nil? || data[:access_token].nil? || data[:access_token] == ""
475
+ raise("empty token (#{response.body})")
476
+ end
469
477
  @config.access_token = data[:access_token]
470
478
  end
471
479
 
@@ -0,0 +1,201 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2024 Aspose.PDF 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
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ require 'date'
23
+ require 'time'
24
+
25
+ module AsposePdfCloud
26
+ # DocumentLayers response class.
27
+ class DocumentLayers
28
+ # List of document Layers.
29
+ attr_accessor :layers
30
+
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'layers' => :'Layers'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'layers' => :'Array<LayerInfo>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'Layers')
55
+ if (value = attributes[:'Layers']).is_a?(Array)
56
+ self.layers = value
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properies with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ return invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ return true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ layers == o.layers
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Fixnum] Hash code
91
+ def hash
92
+ [layers].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ self.class.swagger_types.each_pair do |key, type|
101
+ if type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
105
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
106
+ end
107
+ elsif !attributes[self.class.attribute_map[key]].nil?
108
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
109
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ DateTime.parse(value)
123
+ when :Date
124
+ Date.parse(value)
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :BOOLEAN
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else # model
152
+ temp_model = AsposePdfCloud.const_get(type).new
153
+ temp_model.build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ next if value.nil?
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map{ |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end
198
+
199
+ end
200
+
201
+ end