ultracart_api 4.1.255 → 4.1.257

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5217,6 +5217,76 @@ module UltracartClient
5217
5217
  return data, status_code, headers
5218
5218
  end
5219
5219
 
5220
+ # One code library email item, with its body and file list
5221
+ # Answers for an item this account owns, one shared with it, or one published for everyone, approved by UltraCart and free, the same items listSfvbCodeLibraryEmails lists; anything else is not found. Returns the title, description, subject, preview text, the body as stored and the image files the item carries, without their contents (#2126).
5222
+ # @param storefront_oid [Integer]
5223
+ # @param library_item_oid [Integer]
5224
+ # @param [Hash] opts the optional parameters
5225
+ # @return [SfvbCodeLibraryEmailResponse]
5226
+ def get_sfvb_code_library_email(storefront_oid, library_item_oid, opts = {})
5227
+ data, _status_code, _headers = get_sfvb_code_library_email_with_http_info(storefront_oid, library_item_oid, opts)
5228
+ data
5229
+ end
5230
+
5231
+ # One code library email item, with its body and file list
5232
+ # Answers for an item this account owns, one shared with it, or one published for everyone, approved by UltraCart and free, the same items listSfvbCodeLibraryEmails lists; anything else is not found. Returns the title, description, subject, preview text, the body as stored and the image files the item carries, without their contents (#2126).
5233
+ # @param storefront_oid [Integer]
5234
+ # @param library_item_oid [Integer]
5235
+ # @param [Hash] opts the optional parameters
5236
+ # @return [Array<(SfvbCodeLibraryEmailResponse, Integer, Hash)>] SfvbCodeLibraryEmailResponse data, response status code and response headers
5237
+ def get_sfvb_code_library_email_with_http_info(storefront_oid, library_item_oid, opts = {})
5238
+ if @api_client.config.debugging
5239
+ @api_client.config.logger.debug 'Calling API: SfvbApi.get_sfvb_code_library_email ...'
5240
+ end
5241
+ # verify the required parameter 'storefront_oid' is set
5242
+ if @api_client.config.client_side_validation && storefront_oid.nil?
5243
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.get_sfvb_code_library_email"
5244
+ end
5245
+ # verify the required parameter 'library_item_oid' is set
5246
+ if @api_client.config.client_side_validation && library_item_oid.nil?
5247
+ fail ArgumentError, "Missing the required parameter 'library_item_oid' when calling SfvbApi.get_sfvb_code_library_email"
5248
+ end
5249
+ # resource path
5250
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/code_library/emails/{library_item_oid}'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s)).sub('{' + 'library_item_oid' + '}', CGI.escape(library_item_oid.to_s))
5251
+
5252
+ # query parameters
5253
+ query_params = opts[:query_params] || {}
5254
+
5255
+ # header parameters
5256
+ header_params = opts[:header_params] || {}
5257
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
5258
+ # HTTP header 'Accept' (if needed)
5259
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
5260
+
5261
+ # form parameters
5262
+ form_params = opts[:form_params] || {}
5263
+
5264
+ # http body (model)
5265
+ post_body = opts[:debug_body]
5266
+
5267
+ # return_type
5268
+ return_type = opts[:debug_return_type] || 'SfvbCodeLibraryEmailResponse'
5269
+
5270
+ # auth_names
5271
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
5272
+
5273
+ new_options = opts.merge(
5274
+ :operation => :"SfvbApi.get_sfvb_code_library_email",
5275
+ :header_params => header_params,
5276
+ :query_params => query_params,
5277
+ :form_params => form_params,
5278
+ :body => post_body,
5279
+ :auth_names => auth_names,
5280
+ :return_type => return_type
5281
+ )
5282
+
5283
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
5284
+ if @api_client.config.debugging
5285
+ @api_client.config.logger.debug "API called: SfvbApi#get_sfvb_code_library_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5286
+ end
5287
+ return data, status_code, headers
5288
+ end
5289
+
5220
5290
  # Read one campaign folder
5221
5291
  # The folder, with the name and uuid of each campaign filed in it.
5222
5292
  # @param storefront_oid [Integer]
@@ -10475,6 +10545,64 @@ module UltracartClient
10475
10545
  return data, status_code, headers
10476
10546
  end
10477
10547
 
10548
+ # Who this token is
10549
+ # Returns the merchant, user, granted scopes and reachable storefronts for the calling token. Declared for any scope so an application can always discover which account it is connected to.
10550
+ # @param [Hash] opts the optional parameters
10551
+ # @return [SfvbWhoamiResponse]
10552
+ def get_sfvb_session(opts = {})
10553
+ data, _status_code, _headers = get_sfvb_session_with_http_info(opts)
10554
+ data
10555
+ end
10556
+
10557
+ # Who this token is
10558
+ # Returns the merchant, user, granted scopes and reachable storefronts for the calling token. Declared for any scope so an application can always discover which account it is connected to.
10559
+ # @param [Hash] opts the optional parameters
10560
+ # @return [Array<(SfvbWhoamiResponse, Integer, Hash)>] SfvbWhoamiResponse data, response status code and response headers
10561
+ def get_sfvb_session_with_http_info(opts = {})
10562
+ if @api_client.config.debugging
10563
+ @api_client.config.logger.debug 'Calling API: SfvbApi.get_sfvb_session ...'
10564
+ end
10565
+ # resource path
10566
+ local_var_path = '/sfvb/session'
10567
+
10568
+ # query parameters
10569
+ query_params = opts[:query_params] || {}
10570
+
10571
+ # header parameters
10572
+ header_params = opts[:header_params] || {}
10573
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
10574
+ # HTTP header 'Accept' (if needed)
10575
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
10576
+
10577
+ # form parameters
10578
+ form_params = opts[:form_params] || {}
10579
+
10580
+ # http body (model)
10581
+ post_body = opts[:debug_body]
10582
+
10583
+ # return_type
10584
+ return_type = opts[:debug_return_type] || 'SfvbWhoamiResponse'
10585
+
10586
+ # auth_names
10587
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
10588
+
10589
+ new_options = opts.merge(
10590
+ :operation => :"SfvbApi.get_sfvb_session",
10591
+ :header_params => header_params,
10592
+ :query_params => query_params,
10593
+ :form_params => form_params,
10594
+ :body => post_body,
10595
+ :auth_names => auth_names,
10596
+ :return_type => return_type
10597
+ )
10598
+
10599
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
10600
+ if @api_client.config.debugging
10601
+ @api_client.config.logger.debug "API called: SfvbApi#get_sfvb_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
10602
+ end
10603
+ return data, status_code, headers
10604
+ end
10605
+
10478
10606
  # Read a storefront's site attributes
10479
10607
  # The values the siteattribute element and $site.attr render. These are not in any file or theme. Attributes a template declares but nothing has set are included with the template's default, so the response describes what the templates can render rather than only what has been saved. Credentials stored as site attributes are never included.
10480
10608
  # @param storefront_oid [Integer]
@@ -11996,64 +12124,6 @@ module UltracartClient
11996
12124
  return data, status_code, headers
11997
12125
  end
11998
12126
 
11999
- # Who this token is
12000
- # Returns the merchant, user, granted scopes and reachable storefronts for the calling token. Declared for any scope so an application can always discover which account it is connected to.
12001
- # @param [Hash] opts the optional parameters
12002
- # @return [SfvbWhoamiResponse]
12003
- def get_sfvb_whoami(opts = {})
12004
- data, _status_code, _headers = get_sfvb_whoami_with_http_info(opts)
12005
- data
12006
- end
12007
-
12008
- # Who this token is
12009
- # Returns the merchant, user, granted scopes and reachable storefronts for the calling token. Declared for any scope so an application can always discover which account it is connected to.
12010
- # @param [Hash] opts the optional parameters
12011
- # @return [Array<(SfvbWhoamiResponse, Integer, Hash)>] SfvbWhoamiResponse data, response status code and response headers
12012
- def get_sfvb_whoami_with_http_info(opts = {})
12013
- if @api_client.config.debugging
12014
- @api_client.config.logger.debug 'Calling API: SfvbApi.get_sfvb_whoami ...'
12015
- end
12016
- # resource path
12017
- local_var_path = '/sfvb/whoami'
12018
-
12019
- # query parameters
12020
- query_params = opts[:query_params] || {}
12021
-
12022
- # header parameters
12023
- header_params = opts[:header_params] || {}
12024
- header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
12025
- # HTTP header 'Accept' (if needed)
12026
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
12027
-
12028
- # form parameters
12029
- form_params = opts[:form_params] || {}
12030
-
12031
- # http body (model)
12032
- post_body = opts[:debug_body]
12033
-
12034
- # return_type
12035
- return_type = opts[:debug_return_type] || 'SfvbWhoamiResponse'
12036
-
12037
- # auth_names
12038
- auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
12039
-
12040
- new_options = opts.merge(
12041
- :operation => :"SfvbApi.get_sfvb_whoami",
12042
- :header_params => header_params,
12043
- :query_params => query_params,
12044
- :form_params => form_params,
12045
- :body => post_body,
12046
- :auth_names => auth_names,
12047
- :return_type => return_type
12048
- )
12049
-
12050
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
12051
- if @api_client.config.debugging
12052
- @api_client.config.logger.debug "API called: SfvbApi#get_sfvb_whoami\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
12053
- end
12054
- return data, status_code, headers
12055
- end
12056
-
12057
12127
  # Ignore a 404 path
12058
12128
  # Hides one path from the list and stops counting its hits, for example scanner noise. Reversible.
12059
12129
  # @param storefront_oid [Integer]
@@ -12502,6 +12572,81 @@ module UltracartClient
12502
12572
  return data, status_code, headers
12503
12573
  end
12504
12574
 
12575
+ # Save a reusable email to this account's code library
12576
+ # Saves a whole email (body, subject and preview text) as a code library email item that the admin's \"start from library\" picker and the step insert's library_item_oid can start a new email from (#2126). No flow, campaign, sequence or step is made, and nothing sends. The item is private to this account, never published or shared. The body must pass the library content scanner and the email container rules. Image files the body names by a path starting with / are carried with the item when they are PNG, JPEG or GIF and their contents are that image, up to 25 files, 5 MB each and 20 MB in all; any other file is listed in files_skipped with the reason. Make a new uuid for each save. Sending the same uuid again returns the item it saved, unchanged, with created false, so a retry after an uncertain response is safe. Titles may repeat.
12577
+ # @param storefront_oid [Integer]
12578
+ # @param code_library_email_create_request [SfvbCodeLibraryEmailCreateRequest] The email to save, with the uuid that makes a retry safe
12579
+ # @param [Hash] opts the optional parameters
12580
+ # @return [SfvbCodeLibraryEmailResponse]
12581
+ def insert_sfvb_code_library_email(storefront_oid, code_library_email_create_request, opts = {})
12582
+ data, _status_code, _headers = insert_sfvb_code_library_email_with_http_info(storefront_oid, code_library_email_create_request, opts)
12583
+ data
12584
+ end
12585
+
12586
+ # Save a reusable email to this account&#39;s code library
12587
+ # Saves a whole email (body, subject and preview text) as a code library email item that the admin&#39;s \&quot;start from library\&quot; picker and the step insert&#39;s library_item_oid can start a new email from (#2126). No flow, campaign, sequence or step is made, and nothing sends. The item is private to this account, never published or shared. The body must pass the library content scanner and the email container rules. Image files the body names by a path starting with / are carried with the item when they are PNG, JPEG or GIF and their contents are that image, up to 25 files, 5 MB each and 20 MB in all; any other file is listed in files_skipped with the reason. Make a new uuid for each save. Sending the same uuid again returns the item it saved, unchanged, with created false, so a retry after an uncertain response is safe. Titles may repeat.
12588
+ # @param storefront_oid [Integer]
12589
+ # @param code_library_email_create_request [SfvbCodeLibraryEmailCreateRequest] The email to save, with the uuid that makes a retry safe
12590
+ # @param [Hash] opts the optional parameters
12591
+ # @return [Array<(SfvbCodeLibraryEmailResponse, Integer, Hash)>] SfvbCodeLibraryEmailResponse data, response status code and response headers
12592
+ def insert_sfvb_code_library_email_with_http_info(storefront_oid, code_library_email_create_request, opts = {})
12593
+ if @api_client.config.debugging
12594
+ @api_client.config.logger.debug 'Calling API: SfvbApi.insert_sfvb_code_library_email ...'
12595
+ end
12596
+ # verify the required parameter 'storefront_oid' is set
12597
+ if @api_client.config.client_side_validation && storefront_oid.nil?
12598
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.insert_sfvb_code_library_email"
12599
+ end
12600
+ # verify the required parameter 'code_library_email_create_request' is set
12601
+ if @api_client.config.client_side_validation && code_library_email_create_request.nil?
12602
+ fail ArgumentError, "Missing the required parameter 'code_library_email_create_request' when calling SfvbApi.insert_sfvb_code_library_email"
12603
+ end
12604
+ # resource path
12605
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/code_library/emails'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s))
12606
+
12607
+ # query parameters
12608
+ query_params = opts[:query_params] || {}
12609
+
12610
+ # header parameters
12611
+ header_params = opts[:header_params] || {}
12612
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
12613
+ # HTTP header 'Accept' (if needed)
12614
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
12615
+ # HTTP header 'Content-Type'
12616
+ content_type = @api_client.select_header_content_type(['application/json'])
12617
+ if !content_type.nil?
12618
+ header_params['Content-Type'] = content_type
12619
+ end
12620
+
12621
+ # form parameters
12622
+ form_params = opts[:form_params] || {}
12623
+
12624
+ # http body (model)
12625
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(code_library_email_create_request)
12626
+
12627
+ # return_type
12628
+ return_type = opts[:debug_return_type] || 'SfvbCodeLibraryEmailResponse'
12629
+
12630
+ # auth_names
12631
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
12632
+
12633
+ new_options = opts.merge(
12634
+ :operation => :"SfvbApi.insert_sfvb_code_library_email",
12635
+ :header_params => header_params,
12636
+ :query_params => query_params,
12637
+ :form_params => form_params,
12638
+ :body => post_body,
12639
+ :auth_names => auth_names,
12640
+ :return_type => return_type
12641
+ )
12642
+
12643
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
12644
+ if @api_client.config.debugging
12645
+ @api_client.config.logger.debug "API called: SfvbApi#insert_sfvb_code_library_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
12646
+ end
12647
+ return data, status_code, headers
12648
+ end
12649
+
12505
12650
  # Create a campaign folder
12506
12651
  # A new, empty folder. File a campaign in it by setting its folder_uuid.
12507
12652
  # @param storefront_oid [Integer]
@@ -0,0 +1,270 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class SfvbCodeLibraryEmailCreateRequest
18
+ # The email body, a container that passes the email container rules.
19
+ attr_accessor :container_cjson
20
+
21
+ # Up to 1000 characters on one line, or empty.
22
+ attr_accessor :description
23
+
24
+ # The preview text a new email started from the item takes, 5 to 150 characters on one line.
25
+ attr_accessor :preview_text
26
+
27
+ # The subject a new email started from the item takes, 5 to 150 characters on one line.
28
+ attr_accessor :subject
29
+
30
+ # The title the new-email picker shows, 4 to 100 characters on one line.
31
+ attr_accessor :title
32
+
33
+ # A UUID the caller makes for this save. Sending the same uuid again returns the item it saved, unchanged, so a retry after an uncertain response never makes a second item.
34
+ attr_accessor :uuid
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'container_cjson' => :'container_cjson',
40
+ :'description' => :'description',
41
+ :'preview_text' => :'preview_text',
42
+ :'subject' => :'subject',
43
+ :'title' => :'title',
44
+ :'uuid' => :'uuid'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'container_cjson' => :'String',
57
+ :'description' => :'String',
58
+ :'preview_text' => :'String',
59
+ :'subject' => :'String',
60
+ :'title' => :'String',
61
+ :'uuid' => :'String'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbCodeLibraryEmailCreateRequest` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbCodeLibraryEmailCreateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'container_cjson')
87
+ self.container_cjson = attributes[:'container_cjson']
88
+ end
89
+
90
+ if attributes.key?(:'description')
91
+ self.description = attributes[:'description']
92
+ end
93
+
94
+ if attributes.key?(:'preview_text')
95
+ self.preview_text = attributes[:'preview_text']
96
+ end
97
+
98
+ if attributes.key?(:'subject')
99
+ self.subject = attributes[:'subject']
100
+ end
101
+
102
+ if attributes.key?(:'title')
103
+ self.title = attributes[:'title']
104
+ end
105
+
106
+ if attributes.key?(:'uuid')
107
+ self.uuid = attributes[:'uuid']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ container_cjson == o.container_cjson &&
130
+ description == o.description &&
131
+ preview_text == o.preview_text &&
132
+ subject == o.subject &&
133
+ title == o.title &&
134
+ uuid == o.uuid
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [container_cjson, description, preview_text, subject, title, uuid].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ self.class.openapi_types.each_pair do |key, type|
163
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
164
+ self.send("#{key}=", nil)
165
+ elsif type =~ /\AArray<(.*)>/i
166
+ # check to ensure the input is an array given that the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
169
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
170
+ end
171
+ elsif !attributes[self.class.attribute_map[key]].nil?
172
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
173
+ end
174
+ end
175
+
176
+ self
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def _deserialize(type, value)
184
+ case type.to_sym
185
+ when :Time
186
+ Time.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ # models (e.g. Pet) or oneOf
217
+ klass = UltracartClient.const_get(type)
218
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
+ end
220
+ end
221
+
222
+ # Returns the string representation of the object
223
+ # @return [String] String presentation of the object
224
+ def to_s
225
+ to_hash.to_s
226
+ end
227
+
228
+ # to_body is an alias to to_hash (backward compatibility)
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_body
231
+ to_hash
232
+ end
233
+
234
+ # Returns the object in the form of hash
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_hash
237
+ hash = {}
238
+ self.class.attribute_map.each_pair do |attr, param|
239
+ value = self.send(attr)
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
245
+ hash[param] = _to_hash(value)
246
+ end
247
+ hash
248
+ end
249
+
250
+ # Outputs non-array value in the form of hash
251
+ # For object, use to_hash. Otherwise, just return the value
252
+ # @param [Object] value Any valid value
253
+ # @return [Hash] Returns the value in the form of hash
254
+ def _to_hash(value)
255
+ if value.is_a?(Array)
256
+ value.compact.map { |v| _to_hash(v) }
257
+ elsif value.is_a?(Hash)
258
+ {}.tap do |hash|
259
+ value.each { |k, v| hash[k] = _to_hash(v) }
260
+ end
261
+ elsif value.respond_to? :to_hash
262
+ value.to_hash
263
+ else
264
+ value
265
+ end
266
+ end
267
+
268
+ end
269
+
270
+ end