ultracart_api 4.1.231 → 4.1.233

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +72 -2
  3. data/docs/ItemContentMultimedia.md +2 -0
  4. data/docs/SfvbApi.md +1660 -162
  5. data/docs/SfvbApprovalCreateRequest.md +8 -0
  6. data/docs/SfvbCampaign.md +4 -0
  7. data/docs/SfvbCampaignWriteRequest.md +2 -0
  8. data/docs/SfvbCommsBranchStat.md +20 -0
  9. data/docs/SfvbCommsChange.md +22 -0
  10. data/docs/SfvbCommsClick.md +20 -0
  11. data/docs/SfvbCommsClicksResponse.md +26 -0
  12. data/docs/SfvbCommsDailyStat.md +30 -0
  13. data/docs/SfvbCommsDashboardResponse.md +24 -0
  14. data/docs/SfvbCommsDashboardRow.md +28 -0
  15. data/docs/SfvbCommsLookupOwner.md +26 -0
  16. data/docs/SfvbCommsLookupResponse.md +34 -0
  17. data/docs/SfvbCommsPlan.md +66 -0
  18. data/docs/SfvbCommsPlanResponse.md +20 -0
  19. data/docs/SfvbCommsProvider.md +28 -0
  20. data/docs/SfvbCommsProviderImportRequest.md +22 -0
  21. data/docs/SfvbCommsProviderImportResponse.md +26 -0
  22. data/docs/SfvbCommsProviderList.md +20 -0
  23. data/docs/SfvbCommsProvidersResponse.md +22 -0
  24. data/docs/SfvbCommsRulerValidateRequest.md +18 -0
  25. data/docs/SfvbCommsRulerValidateResponse.md +22 -0
  26. data/docs/SfvbCommsSender.md +24 -0
  27. data/docs/SfvbCommsSenderUpdate.md +22 -0
  28. data/docs/SfvbCommsSequenceFolder.md +28 -0
  29. data/docs/SfvbCommsSequenceFolderResponse.md +22 -0
  30. data/docs/SfvbCommsSequenceFoldersResponse.md +18 -0
  31. data/docs/SfvbCommsSequenceStatsResponse.md +26 -0
  32. data/docs/SfvbCommsSettings.md +34 -0
  33. data/docs/SfvbCommsSettingsResponse.md +24 -0
  34. data/docs/SfvbCommsSettingsUpdateRequest.md +26 -0
  35. data/docs/SfvbCommsStat.md +54 -0
  36. data/docs/SfvbCommsStepStat.md +34 -0
  37. data/docs/SfvbCommsTemplate.md +30 -0
  38. data/docs/SfvbCommsTemplateResponse.md +30 -0
  39. data/docs/SfvbCommsTemplatesResponse.md +20 -0
  40. data/docs/SfvbCommsTestEmailRequest.md +24 -0
  41. data/docs/SfvbCommsTestPostcardRequest.md +36 -0
  42. data/docs/SfvbCommsTestSendResponse.md +32 -0
  43. data/docs/SfvbCommsTestSmsRequest.md +18 -0
  44. data/docs/SfvbCommsUnreferencedEmail.md +30 -0
  45. data/docs/SfvbCommsUnreferencedPostcard.md +24 -0
  46. data/docs/SfvbCommsUnreferencedResponse.md +32 -0
  47. data/docs/SfvbEmail.md +8 -0
  48. data/docs/SfvbFlow.md +4 -0
  49. data/docs/SfvbFlowBackfillRequest.md +24 -0
  50. data/docs/SfvbFlowBackfillResponse.md +38 -0
  51. data/docs/SfvbFlowWriteRequest.md +2 -0
  52. data/docs/SfvbStepCounts.md +1 -1
  53. data/lib/ultracart_api/api/sfvb_api.rb +2356 -348
  54. data/lib/ultracart_api/models/item_content_multimedia.rb +11 -1
  55. data/lib/ultracart_api/models/sfvb_approval_create_request.rb +39 -3
  56. data/lib/ultracart_api/models/sfvb_campaign.rb +21 -1
  57. data/lib/ultracart_api/models/sfvb_campaign_write_request.rb +11 -1
  58. data/lib/ultracart_api/models/sfvb_comms_branch_stat.rb +229 -0
  59. data/lib/ultracart_api/models/sfvb_comms_change.rb +240 -0
  60. data/lib/ultracart_api/models/sfvb_comms_click.rb +230 -0
  61. data/lib/ultracart_api/models/sfvb_comms_clicks_response.rb +264 -0
  62. data/lib/ultracart_api/models/sfvb_comms_daily_stat.rb +280 -0
  63. data/lib/ultracart_api/models/sfvb_comms_dashboard_response.rb +256 -0
  64. data/lib/ultracart_api/models/sfvb_comms_dashboard_row.rb +269 -0
  65. data/lib/ultracart_api/models/sfvb_comms_lookup_owner.rb +260 -0
  66. data/lib/ultracart_api/models/sfvb_comms_lookup_response.rb +301 -0
  67. data/lib/ultracart_api/models/sfvb_comms_plan.rb +460 -0
  68. data/lib/ultracart_api/models/sfvb_comms_plan_response.rb +231 -0
  69. data/lib/ultracart_api/models/sfvb_comms_provider.rb +272 -0
  70. data/lib/ultracart_api/models/sfvb_comms_provider_import_request.rb +242 -0
  71. data/lib/ultracart_api/models/sfvb_comms_provider_import_response.rb +264 -0
  72. data/lib/ultracart_api/models/sfvb_comms_provider_list.rb +230 -0
  73. data/lib/ultracart_api/models/sfvb_comms_providers_response.rb +244 -0
  74. data/lib/ultracart_api/models/sfvb_comms_ruler_validate_request.rb +220 -0
  75. data/lib/ultracart_api/models/sfvb_comms_ruler_validate_response.rb +242 -0
  76. data/lib/ultracart_api/models/sfvb_comms_sender.rb +250 -0
  77. data/lib/ultracart_api/models/sfvb_comms_sender_update.rb +240 -0
  78. data/lib/ultracart_api/models/sfvb_comms_sequence_folder.rb +270 -0
  79. data/lib/ultracart_api/models/sfvb_comms_sequence_folder_response.rb +243 -0
  80. data/lib/ultracart_api/models/sfvb_comms_sequence_folders_response.rb +222 -0
  81. data/lib/ultracart_api/models/sfvb_comms_sequence_stats_response.rb +263 -0
  82. data/lib/ultracart_api/models/sfvb_comms_settings.rb +297 -0
  83. data/lib/ultracart_api/models/sfvb_comms_settings_response.rb +253 -0
  84. data/lib/ultracart_api/models/sfvb_comms_settings_update_request.rb +257 -0
  85. data/lib/ultracart_api/models/sfvb_comms_stat.rb +402 -0
  86. data/lib/ultracart_api/models/sfvb_comms_step_stat.rb +301 -0
  87. data/lib/ultracart_api/models/sfvb_comms_template.rb +280 -0
  88. data/lib/ultracart_api/models/sfvb_comms_template_response.rb +281 -0
  89. data/lib/ultracart_api/models/sfvb_comms_templates_response.rb +234 -0
  90. data/lib/ultracart_api/models/sfvb_comms_test_email_request.rb +252 -0
  91. data/lib/ultracart_api/models/sfvb_comms_test_postcard_request.rb +312 -0
  92. data/lib/ultracart_api/models/sfvb_comms_test_send_response.rb +292 -0
  93. data/lib/ultracart_api/models/sfvb_comms_test_sms_request.rb +220 -0
  94. data/lib/ultracart_api/models/sfvb_comms_unreferenced_email.rb +280 -0
  95. data/lib/ultracart_api/models/sfvb_comms_unreferenced_postcard.rb +250 -0
  96. data/lib/ultracart_api/models/sfvb_comms_unreferenced_response.rb +296 -0
  97. data/lib/ultracart_api/models/sfvb_email.rb +41 -1
  98. data/lib/ultracart_api/models/sfvb_flow.rb +21 -1
  99. data/lib/ultracart_api/models/sfvb_flow_backfill_request.rb +250 -0
  100. data/lib/ultracart_api/models/sfvb_flow_backfill_response.rb +322 -0
  101. data/lib/ultracart_api/models/sfvb_flow_write_request.rb +11 -1
  102. data/lib/ultracart_api/models/sfvb_step_counts.rb +1 -1
  103. data/lib/ultracart_api/version.rb +1 -1
  104. data/lib/ultracart_api.rb +41 -0
  105. metadata +84 -2
@@ -0,0 +1,301 @@
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 SfvbCommsStepStat
18
+ # Each side's counts, for a condition, split or InboxGeek step.
19
+ attr_accessor :branches
20
+
21
+ # The email it sends, for an email or experiment variant.
22
+ attr_accessor :email_uuid
23
+
24
+ # The step type as the admin shows it.
25
+ attr_accessor :label
26
+
27
+ # The step's name, if it has one.
28
+ attr_accessor :name
29
+
30
+ # The postcard it mails, for a postcard step.
31
+ attr_accessor :postcard_uuid
32
+
33
+ attr_accessor :stats
34
+
35
+ # The step.
36
+ attr_accessor :step_uuid
37
+
38
+ # The step type.
39
+ attr_accessor :type
40
+
41
+ # The experiment variant, for an experiment step.
42
+ attr_accessor :variant_name
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'branches' => :'branches',
48
+ :'email_uuid' => :'email_uuid',
49
+ :'label' => :'label',
50
+ :'name' => :'name',
51
+ :'postcard_uuid' => :'postcard_uuid',
52
+ :'stats' => :'stats',
53
+ :'step_uuid' => :'step_uuid',
54
+ :'type' => :'type',
55
+ :'variant_name' => :'variant_name'
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :'branches' => :'Array<SfvbCommsBranchStat>',
68
+ :'email_uuid' => :'String',
69
+ :'label' => :'String',
70
+ :'name' => :'String',
71
+ :'postcard_uuid' => :'String',
72
+ :'stats' => :'SfvbCommsStat',
73
+ :'step_uuid' => :'String',
74
+ :'type' => :'String',
75
+ :'variant_name' => :'String'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ ])
83
+ end
84
+
85
+ # Initializes the object
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ def initialize(attributes = {})
88
+ if (!attributes.is_a?(Hash))
89
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbCommsStepStat` initialize method"
90
+ end
91
+
92
+ # check to see if the attribute exists and convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}) { |(k, v), h|
94
+ if (!self.class.attribute_map.key?(k.to_sym))
95
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbCommsStepStat`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
96
+ end
97
+ h[k.to_sym] = v
98
+ }
99
+
100
+ if attributes.key?(:'branches')
101
+ if (value = attributes[:'branches']).is_a?(Array)
102
+ self.branches = value
103
+ end
104
+ end
105
+
106
+ if attributes.key?(:'email_uuid')
107
+ self.email_uuid = attributes[:'email_uuid']
108
+ end
109
+
110
+ if attributes.key?(:'label')
111
+ self.label = attributes[:'label']
112
+ end
113
+
114
+ if attributes.key?(:'name')
115
+ self.name = attributes[:'name']
116
+ end
117
+
118
+ if attributes.key?(:'postcard_uuid')
119
+ self.postcard_uuid = attributes[:'postcard_uuid']
120
+ end
121
+
122
+ if attributes.key?(:'stats')
123
+ self.stats = attributes[:'stats']
124
+ end
125
+
126
+ if attributes.key?(:'step_uuid')
127
+ self.step_uuid = attributes[:'step_uuid']
128
+ end
129
+
130
+ if attributes.key?(:'type')
131
+ self.type = attributes[:'type']
132
+ end
133
+
134
+ if attributes.key?(:'variant_name')
135
+ self.variant_name = attributes[:'variant_name']
136
+ end
137
+ end
138
+
139
+ # Show invalid properties with the reasons. Usually used together with valid?
140
+ # @return Array for valid properties with the reasons
141
+ def list_invalid_properties
142
+ invalid_properties = Array.new
143
+ invalid_properties
144
+ end
145
+
146
+ # Check to see if the all the properties in the model are valid
147
+ # @return true if the model is valid
148
+ def valid?
149
+ true
150
+ end
151
+
152
+ # Checks equality by comparing each attribute.
153
+ # @param [Object] Object to be compared
154
+ def ==(o)
155
+ return true if self.equal?(o)
156
+ self.class == o.class &&
157
+ branches == o.branches &&
158
+ email_uuid == o.email_uuid &&
159
+ label == o.label &&
160
+ name == o.name &&
161
+ postcard_uuid == o.postcard_uuid &&
162
+ stats == o.stats &&
163
+ step_uuid == o.step_uuid &&
164
+ type == o.type &&
165
+ variant_name == o.variant_name
166
+ end
167
+
168
+ # @see the `==` method
169
+ # @param [Object] Object to be compared
170
+ def eql?(o)
171
+ self == o
172
+ end
173
+
174
+ # Calculates hash code according to all attributes.
175
+ # @return [Integer] Hash code
176
+ def hash
177
+ [branches, email_uuid, label, name, postcard_uuid, stats, step_uuid, type, variant_name].hash
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def self.build_from_hash(attributes)
184
+ new.build_from_hash(attributes)
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def build_from_hash(attributes)
191
+ return nil unless attributes.is_a?(Hash)
192
+ attributes = attributes.transform_keys(&:to_sym)
193
+ self.class.openapi_types.each_pair do |key, type|
194
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
195
+ self.send("#{key}=", nil)
196
+ elsif type =~ /\AArray<(.*)>/i
197
+ # check to ensure the input is an array given that the attribute
198
+ # is documented as an array but the input is not
199
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
200
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
201
+ end
202
+ elsif !attributes[self.class.attribute_map[key]].nil?
203
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
204
+ end
205
+ end
206
+
207
+ self
208
+ end
209
+
210
+ # Deserializes the data based on type
211
+ # @param string type Data type
212
+ # @param string value Value to be deserialized
213
+ # @return [Object] Deserialized data
214
+ def _deserialize(type, value)
215
+ case type.to_sym
216
+ when :Time
217
+ Time.parse(value)
218
+ when :Date
219
+ Date.parse(value)
220
+ when :String
221
+ value.to_s
222
+ when :Integer
223
+ value.to_i
224
+ when :Float
225
+ value.to_f
226
+ when :Boolean
227
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
228
+ true
229
+ else
230
+ false
231
+ end
232
+ when :Object
233
+ # generic object (usually a Hash), return directly
234
+ value
235
+ when /\AArray<(?<inner_type>.+)>\z/
236
+ inner_type = Regexp.last_match[:inner_type]
237
+ value.map { |v| _deserialize(inner_type, v) }
238
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
239
+ k_type = Regexp.last_match[:k_type]
240
+ v_type = Regexp.last_match[:v_type]
241
+ {}.tap do |hash|
242
+ value.each do |k, v|
243
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
244
+ end
245
+ end
246
+ else # model
247
+ # models (e.g. Pet) or oneOf
248
+ klass = UltracartClient.const_get(type)
249
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
250
+ end
251
+ end
252
+
253
+ # Returns the string representation of the object
254
+ # @return [String] String presentation of the object
255
+ def to_s
256
+ to_hash.to_s
257
+ end
258
+
259
+ # to_body is an alias to to_hash (backward compatibility)
260
+ # @return [Hash] Returns the object in the form of hash
261
+ def to_body
262
+ to_hash
263
+ end
264
+
265
+ # Returns the object in the form of hash
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_hash
268
+ hash = {}
269
+ self.class.attribute_map.each_pair do |attr, param|
270
+ value = self.send(attr)
271
+ if value.nil?
272
+ is_nullable = self.class.openapi_nullable.include?(attr)
273
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
274
+ end
275
+
276
+ hash[param] = _to_hash(value)
277
+ end
278
+ hash
279
+ end
280
+
281
+ # Outputs non-array value in the form of hash
282
+ # For object, use to_hash. Otherwise, just return the value
283
+ # @param [Object] value Any valid value
284
+ # @return [Hash] Returns the value in the form of hash
285
+ def _to_hash(value)
286
+ if value.is_a?(Array)
287
+ value.compact.map { |v| _to_hash(v) }
288
+ elsif value.is_a?(Hash)
289
+ {}.tap do |hash|
290
+ value.each { |k, v| hash[k] = _to_hash(v) }
291
+ end
292
+ elsif value.respond_to? :to_hash
293
+ value.to_hash
294
+ else
295
+ value
296
+ end
297
+ end
298
+
299
+ end
300
+
301
+ end
@@ -0,0 +1,280 @@
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 SfvbCommsTemplate
18
+ # The description.
19
+ attr_accessor :description
20
+
21
+ # The saved template's id, for a storefront or system template.
22
+ attr_accessor :email_template_oid
23
+
24
+ # The name.
25
+ attr_accessor :name
26
+
27
+ # The theme file, for a base template.
28
+ attr_accessor :path
29
+
30
+ # The admin's order.
31
+ attr_accessor :sort_order
32
+
33
+ # storefront (saved on this storefront), system (UltraCart's), or base (a theme file an email renders inside).
34
+ attr_accessor :source
35
+
36
+ # The flow trigger the template is meant for, or none.
37
+ attr_accessor :trigger_type
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'description' => :'description',
43
+ :'email_template_oid' => :'email_template_oid',
44
+ :'name' => :'name',
45
+ :'path' => :'path',
46
+ :'sort_order' => :'sort_order',
47
+ :'source' => :'source',
48
+ :'trigger_type' => :'trigger_type'
49
+ }
50
+ end
51
+
52
+ # Returns all the JSON keys this model knows about
53
+ def self.acceptable_attributes
54
+ attribute_map.values
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'description' => :'String',
61
+ :'email_template_oid' => :'Integer',
62
+ :'name' => :'String',
63
+ :'path' => :'String',
64
+ :'sort_order' => :'Integer',
65
+ :'source' => :'String',
66
+ :'trigger_type' => :'String'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbCommsTemplate` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbCommsTemplate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'description')
92
+ self.description = attributes[:'description']
93
+ end
94
+
95
+ if attributes.key?(:'email_template_oid')
96
+ self.email_template_oid = attributes[:'email_template_oid']
97
+ end
98
+
99
+ if attributes.key?(:'name')
100
+ self.name = attributes[:'name']
101
+ end
102
+
103
+ if attributes.key?(:'path')
104
+ self.path = attributes[:'path']
105
+ end
106
+
107
+ if attributes.key?(:'sort_order')
108
+ self.sort_order = attributes[:'sort_order']
109
+ end
110
+
111
+ if attributes.key?(:'source')
112
+ self.source = attributes[:'source']
113
+ end
114
+
115
+ if attributes.key?(:'trigger_type')
116
+ self.trigger_type = attributes[:'trigger_type']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ invalid_properties
125
+ end
126
+
127
+ # Check to see if the all the properties in the model are valid
128
+ # @return true if the model is valid
129
+ def valid?
130
+ true
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ description == o.description &&
139
+ email_template_oid == o.email_template_oid &&
140
+ name == o.name &&
141
+ path == o.path &&
142
+ sort_order == o.sort_order &&
143
+ source == o.source &&
144
+ trigger_type == o.trigger_type
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [description, email_template_oid, name, path, sort_order, source, trigger_type].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ new.build_from_hash(attributes)
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ attributes = attributes.transform_keys(&:to_sym)
172
+ self.class.openapi_types.each_pair do |key, type|
173
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
174
+ self.send("#{key}=", nil)
175
+ elsif type =~ /\AArray<(.*)>/i
176
+ # check to ensure the input is an array given that the attribute
177
+ # is documented as an array but the input is not
178
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
179
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
180
+ end
181
+ elsif !attributes[self.class.attribute_map[key]].nil?
182
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
183
+ end
184
+ end
185
+
186
+ self
187
+ end
188
+
189
+ # Deserializes the data based on type
190
+ # @param string type Data type
191
+ # @param string value Value to be deserialized
192
+ # @return [Object] Deserialized data
193
+ def _deserialize(type, value)
194
+ case type.to_sym
195
+ when :Time
196
+ Time.parse(value)
197
+ when :Date
198
+ Date.parse(value)
199
+ when :String
200
+ value.to_s
201
+ when :Integer
202
+ value.to_i
203
+ when :Float
204
+ value.to_f
205
+ when :Boolean
206
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
207
+ true
208
+ else
209
+ false
210
+ end
211
+ when :Object
212
+ # generic object (usually a Hash), return directly
213
+ value
214
+ when /\AArray<(?<inner_type>.+)>\z/
215
+ inner_type = Regexp.last_match[:inner_type]
216
+ value.map { |v| _deserialize(inner_type, v) }
217
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
218
+ k_type = Regexp.last_match[:k_type]
219
+ v_type = Regexp.last_match[:v_type]
220
+ {}.tap do |hash|
221
+ value.each do |k, v|
222
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
223
+ end
224
+ end
225
+ else # model
226
+ # models (e.g. Pet) or oneOf
227
+ klass = UltracartClient.const_get(type)
228
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
229
+ end
230
+ end
231
+
232
+ # Returns the string representation of the object
233
+ # @return [String] String presentation of the object
234
+ def to_s
235
+ to_hash.to_s
236
+ end
237
+
238
+ # to_body is an alias to to_hash (backward compatibility)
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_body
241
+ to_hash
242
+ end
243
+
244
+ # Returns the object in the form of hash
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_hash
247
+ hash = {}
248
+ self.class.attribute_map.each_pair do |attr, param|
249
+ value = self.send(attr)
250
+ if value.nil?
251
+ is_nullable = self.class.openapi_nullable.include?(attr)
252
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
253
+ end
254
+
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map { |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end