ultracart_api 4.1.207 → 4.1.209
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.
- checksums.yaml +4 -4
- data/README.md +28 -2
- data/docs/SfvbApi.md +773 -48
- data/docs/SfvbArchiveRequest.md +18 -0
- data/docs/SfvbCampaign.md +16 -0
- data/docs/SfvbCampaignMembership.md +24 -0
- data/docs/SfvbCampaignWriteRequest.md +32 -0
- data/docs/SfvbCommsEmail.md +6 -0
- data/docs/SfvbCommsList.md +24 -0
- data/docs/SfvbCommsListsResponse.md +18 -0
- data/docs/SfvbCommsSegment.md +26 -0
- data/docs/SfvbCommsSegmentsResponse.md +18 -0
- data/docs/SfvbEmail.md +40 -0
- data/docs/SfvbEmailUpdateRequest.md +20 -0
- data/docs/SfvbFlow.md +22 -0
- data/docs/SfvbFlowStatusRequest.md +18 -0
- data/docs/SfvbFlowWriteRequest.md +38 -0
- data/lib/ultracart_api/api/sfvb_api.rb +5346 -4330
- data/lib/ultracart_api/models/item_third_party_email_marketing.rb +2 -2
- data/lib/ultracart_api/models/sfvb_archive_request.rb +220 -0
- data/lib/ultracart_api/models/sfvb_campaign.rb +85 -1
- data/lib/ultracart_api/models/sfvb_campaign_membership.rb +250 -0
- data/lib/ultracart_api/models/sfvb_campaign_write_request.rb +292 -0
- data/lib/ultracart_api/models/sfvb_comms_email.rb +31 -1
- data/lib/ultracart_api/models/sfvb_comms_list.rb +250 -0
- data/lib/ultracart_api/models/sfvb_comms_lists_response.rb +222 -0
- data/lib/ultracart_api/models/sfvb_comms_segment.rb +260 -0
- data/lib/ultracart_api/models/sfvb_comms_segments_response.rb +222 -0
- data/lib/ultracart_api/models/sfvb_email.rb +330 -0
- data/lib/ultracart_api/models/sfvb_email_update_request.rb +230 -0
- data/lib/ultracart_api/models/sfvb_flow.rb +113 -1
- data/lib/ultracart_api/models/sfvb_flow_status_request.rb +254 -0
- data/lib/ultracart_api/models/sfvb_flow_write_request.rb +354 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +11 -0
- metadata +24 -2
|
@@ -0,0 +1,330 @@
|
|
|
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 SfvbEmail
|
|
18
|
+
# When the email container was last changed (ISO 8601, UTC).
|
|
19
|
+
attr_accessor :container_last_modified_dts
|
|
20
|
+
|
|
21
|
+
# The email uuid. The same uuid the email container (owner type email) and the email render take.
|
|
22
|
+
attr_accessor :email_uuid
|
|
23
|
+
|
|
24
|
+
# Hash of the subject and preview text. Send it as If-Match when updating. A change to the email body does not change it.
|
|
25
|
+
attr_accessor :hash_sha256
|
|
26
|
+
|
|
27
|
+
# True when the email is in a flow or campaign that is sending, so a change reaches customers and needs sfvb_publish. An email in neither is reported live.
|
|
28
|
+
attr_accessor :live
|
|
29
|
+
|
|
30
|
+
# True while a change waits for review. An edit puts it back to needing review.
|
|
31
|
+
attr_accessor :pending_review
|
|
32
|
+
|
|
33
|
+
# The preview text an inbox shows after the subject.
|
|
34
|
+
attr_accessor :preview_text
|
|
35
|
+
|
|
36
|
+
# True when review rejected the email. An edit puts it back to needing review.
|
|
37
|
+
attr_accessor :rejected
|
|
38
|
+
|
|
39
|
+
# True when a change to this email must be reviewed before it sends.
|
|
40
|
+
attr_accessor :requires_review
|
|
41
|
+
|
|
42
|
+
# The subject line. Merge tokens such as firstName are filled in at send.
|
|
43
|
+
attr_accessor :subject
|
|
44
|
+
|
|
45
|
+
# True when UltraCart suspended the email for spam. Edits are refused until the merchant resolves it with UltraCart support.
|
|
46
|
+
attr_accessor :suspended_for_spam
|
|
47
|
+
|
|
48
|
+
# True for a transactional email, which skips the marketing footer rules.
|
|
49
|
+
attr_accessor :transactional
|
|
50
|
+
|
|
51
|
+
# The email version. Every save adds one.
|
|
52
|
+
attr_accessor :version
|
|
53
|
+
|
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
55
|
+
def self.attribute_map
|
|
56
|
+
{
|
|
57
|
+
:'container_last_modified_dts' => :'container_last_modified_dts',
|
|
58
|
+
:'email_uuid' => :'email_uuid',
|
|
59
|
+
:'hash_sha256' => :'hash_sha256',
|
|
60
|
+
:'live' => :'live',
|
|
61
|
+
:'pending_review' => :'pending_review',
|
|
62
|
+
:'preview_text' => :'preview_text',
|
|
63
|
+
:'rejected' => :'rejected',
|
|
64
|
+
:'requires_review' => :'requires_review',
|
|
65
|
+
:'subject' => :'subject',
|
|
66
|
+
:'suspended_for_spam' => :'suspended_for_spam',
|
|
67
|
+
:'transactional' => :'transactional',
|
|
68
|
+
:'version' => :'version'
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Returns all the JSON keys this model knows about
|
|
73
|
+
def self.acceptable_attributes
|
|
74
|
+
attribute_map.values
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Attribute type mapping.
|
|
78
|
+
def self.openapi_types
|
|
79
|
+
{
|
|
80
|
+
:'container_last_modified_dts' => :'String',
|
|
81
|
+
:'email_uuid' => :'String',
|
|
82
|
+
:'hash_sha256' => :'String',
|
|
83
|
+
:'live' => :'Boolean',
|
|
84
|
+
:'pending_review' => :'Boolean',
|
|
85
|
+
:'preview_text' => :'String',
|
|
86
|
+
:'rejected' => :'Boolean',
|
|
87
|
+
:'requires_review' => :'Boolean',
|
|
88
|
+
:'subject' => :'String',
|
|
89
|
+
:'suspended_for_spam' => :'Boolean',
|
|
90
|
+
:'transactional' => :'Boolean',
|
|
91
|
+
:'version' => :'Integer'
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# List of attributes with nullable: true
|
|
96
|
+
def self.openapi_nullable
|
|
97
|
+
Set.new([
|
|
98
|
+
])
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Initializes the object
|
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
103
|
+
def initialize(attributes = {})
|
|
104
|
+
if (!attributes.is_a?(Hash))
|
|
105
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbEmail` initialize method"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
109
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
110
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
111
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbEmail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
112
|
+
end
|
|
113
|
+
h[k.to_sym] = v
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'container_last_modified_dts')
|
|
117
|
+
self.container_last_modified_dts = attributes[:'container_last_modified_dts']
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
if attributes.key?(:'email_uuid')
|
|
121
|
+
self.email_uuid = attributes[:'email_uuid']
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
if attributes.key?(:'hash_sha256')
|
|
125
|
+
self.hash_sha256 = attributes[:'hash_sha256']
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if attributes.key?(:'live')
|
|
129
|
+
self.live = attributes[:'live']
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if attributes.key?(:'pending_review')
|
|
133
|
+
self.pending_review = attributes[:'pending_review']
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if attributes.key?(:'preview_text')
|
|
137
|
+
self.preview_text = attributes[:'preview_text']
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if attributes.key?(:'rejected')
|
|
141
|
+
self.rejected = attributes[:'rejected']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if attributes.key?(:'requires_review')
|
|
145
|
+
self.requires_review = attributes[:'requires_review']
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if attributes.key?(:'subject')
|
|
149
|
+
self.subject = attributes[:'subject']
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if attributes.key?(:'suspended_for_spam')
|
|
153
|
+
self.suspended_for_spam = attributes[:'suspended_for_spam']
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
if attributes.key?(:'transactional')
|
|
157
|
+
self.transactional = attributes[:'transactional']
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
if attributes.key?(:'version')
|
|
161
|
+
self.version = attributes[:'version']
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
166
|
+
# @return Array for valid properties with the reasons
|
|
167
|
+
def list_invalid_properties
|
|
168
|
+
invalid_properties = Array.new
|
|
169
|
+
invalid_properties
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Check to see if the all the properties in the model are valid
|
|
173
|
+
# @return true if the model is valid
|
|
174
|
+
def valid?
|
|
175
|
+
true
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Checks equality by comparing each attribute.
|
|
179
|
+
# @param [Object] Object to be compared
|
|
180
|
+
def ==(o)
|
|
181
|
+
return true if self.equal?(o)
|
|
182
|
+
self.class == o.class &&
|
|
183
|
+
container_last_modified_dts == o.container_last_modified_dts &&
|
|
184
|
+
email_uuid == o.email_uuid &&
|
|
185
|
+
hash_sha256 == o.hash_sha256 &&
|
|
186
|
+
live == o.live &&
|
|
187
|
+
pending_review == o.pending_review &&
|
|
188
|
+
preview_text == o.preview_text &&
|
|
189
|
+
rejected == o.rejected &&
|
|
190
|
+
requires_review == o.requires_review &&
|
|
191
|
+
subject == o.subject &&
|
|
192
|
+
suspended_for_spam == o.suspended_for_spam &&
|
|
193
|
+
transactional == o.transactional &&
|
|
194
|
+
version == o.version
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# @see the `==` method
|
|
198
|
+
# @param [Object] Object to be compared
|
|
199
|
+
def eql?(o)
|
|
200
|
+
self == o
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Calculates hash code according to all attributes.
|
|
204
|
+
# @return [Integer] Hash code
|
|
205
|
+
def hash
|
|
206
|
+
[container_last_modified_dts, email_uuid, hash_sha256, live, pending_review, preview_text, rejected, requires_review, subject, suspended_for_spam, transactional, version].hash
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Builds the object from hash
|
|
210
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
211
|
+
# @return [Object] Returns the model itself
|
|
212
|
+
def self.build_from_hash(attributes)
|
|
213
|
+
new.build_from_hash(attributes)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Builds the object from hash
|
|
217
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
218
|
+
# @return [Object] Returns the model itself
|
|
219
|
+
def build_from_hash(attributes)
|
|
220
|
+
return nil unless attributes.is_a?(Hash)
|
|
221
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
222
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
223
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
224
|
+
self.send("#{key}=", nil)
|
|
225
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
226
|
+
# check to ensure the input is an array given that the attribute
|
|
227
|
+
# is documented as an array but the input is not
|
|
228
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
229
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
230
|
+
end
|
|
231
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
232
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
self
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Deserializes the data based on type
|
|
240
|
+
# @param string type Data type
|
|
241
|
+
# @param string value Value to be deserialized
|
|
242
|
+
# @return [Object] Deserialized data
|
|
243
|
+
def _deserialize(type, value)
|
|
244
|
+
case type.to_sym
|
|
245
|
+
when :Time
|
|
246
|
+
Time.parse(value)
|
|
247
|
+
when :Date
|
|
248
|
+
Date.parse(value)
|
|
249
|
+
when :String
|
|
250
|
+
value.to_s
|
|
251
|
+
when :Integer
|
|
252
|
+
value.to_i
|
|
253
|
+
when :Float
|
|
254
|
+
value.to_f
|
|
255
|
+
when :Boolean
|
|
256
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
257
|
+
true
|
|
258
|
+
else
|
|
259
|
+
false
|
|
260
|
+
end
|
|
261
|
+
when :Object
|
|
262
|
+
# generic object (usually a Hash), return directly
|
|
263
|
+
value
|
|
264
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
265
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
266
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
267
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
268
|
+
k_type = Regexp.last_match[:k_type]
|
|
269
|
+
v_type = Regexp.last_match[:v_type]
|
|
270
|
+
{}.tap do |hash|
|
|
271
|
+
value.each do |k, v|
|
|
272
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
else # model
|
|
276
|
+
# models (e.g. Pet) or oneOf
|
|
277
|
+
klass = UltracartClient.const_get(type)
|
|
278
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Returns the string representation of the object
|
|
283
|
+
# @return [String] String presentation of the object
|
|
284
|
+
def to_s
|
|
285
|
+
to_hash.to_s
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
289
|
+
# @return [Hash] Returns the object in the form of hash
|
|
290
|
+
def to_body
|
|
291
|
+
to_hash
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Returns the object in the form of hash
|
|
295
|
+
# @return [Hash] Returns the object in the form of hash
|
|
296
|
+
def to_hash
|
|
297
|
+
hash = {}
|
|
298
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
299
|
+
value = self.send(attr)
|
|
300
|
+
if value.nil?
|
|
301
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
302
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
hash[param] = _to_hash(value)
|
|
306
|
+
end
|
|
307
|
+
hash
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Outputs non-array value in the form of hash
|
|
311
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
312
|
+
# @param [Object] value Any valid value
|
|
313
|
+
# @return [Hash] Returns the value in the form of hash
|
|
314
|
+
def _to_hash(value)
|
|
315
|
+
if value.is_a?(Array)
|
|
316
|
+
value.compact.map { |v| _to_hash(v) }
|
|
317
|
+
elsif value.is_a?(Hash)
|
|
318
|
+
{}.tap do |hash|
|
|
319
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
320
|
+
end
|
|
321
|
+
elsif value.respond_to? :to_hash
|
|
322
|
+
value.to_hash
|
|
323
|
+
else
|
|
324
|
+
value
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
end
|
|
@@ -0,0 +1,230 @@
|
|
|
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 SfvbEmailUpdateRequest
|
|
18
|
+
# The new preview text, 5 to 150 characters on one line.
|
|
19
|
+
attr_accessor :preview_text
|
|
20
|
+
|
|
21
|
+
# The new subject line, 5 to 150 characters on one line. Merge tokens such as firstName are filled in at send.
|
|
22
|
+
attr_accessor :subject
|
|
23
|
+
|
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
|
+
def self.attribute_map
|
|
26
|
+
{
|
|
27
|
+
:'preview_text' => :'preview_text',
|
|
28
|
+
:'subject' => :'subject'
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns all the JSON keys this model knows about
|
|
33
|
+
def self.acceptable_attributes
|
|
34
|
+
attribute_map.values
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Attribute type mapping.
|
|
38
|
+
def self.openapi_types
|
|
39
|
+
{
|
|
40
|
+
:'preview_text' => :'String',
|
|
41
|
+
:'subject' => :'String'
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# List of attributes with nullable: true
|
|
46
|
+
def self.openapi_nullable
|
|
47
|
+
Set.new([
|
|
48
|
+
])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Initializes the object
|
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
53
|
+
def initialize(attributes = {})
|
|
54
|
+
if (!attributes.is_a?(Hash))
|
|
55
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbEmailUpdateRequest` initialize method"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
59
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
60
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
61
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbEmailUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
62
|
+
end
|
|
63
|
+
h[k.to_sym] = v
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if attributes.key?(:'preview_text')
|
|
67
|
+
self.preview_text = attributes[:'preview_text']
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if attributes.key?(:'subject')
|
|
71
|
+
self.subject = attributes[:'subject']
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
76
|
+
# @return Array for valid properties with the reasons
|
|
77
|
+
def list_invalid_properties
|
|
78
|
+
invalid_properties = Array.new
|
|
79
|
+
invalid_properties
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Check to see if the all the properties in the model are valid
|
|
83
|
+
# @return true if the model is valid
|
|
84
|
+
def valid?
|
|
85
|
+
true
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Checks equality by comparing each attribute.
|
|
89
|
+
# @param [Object] Object to be compared
|
|
90
|
+
def ==(o)
|
|
91
|
+
return true if self.equal?(o)
|
|
92
|
+
self.class == o.class &&
|
|
93
|
+
preview_text == o.preview_text &&
|
|
94
|
+
subject == o.subject
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @see the `==` method
|
|
98
|
+
# @param [Object] Object to be compared
|
|
99
|
+
def eql?(o)
|
|
100
|
+
self == o
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Calculates hash code according to all attributes.
|
|
104
|
+
# @return [Integer] Hash code
|
|
105
|
+
def hash
|
|
106
|
+
[preview_text, subject].hash
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Builds the object from hash
|
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
111
|
+
# @return [Object] Returns the model itself
|
|
112
|
+
def self.build_from_hash(attributes)
|
|
113
|
+
new.build_from_hash(attributes)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Builds the object from hash
|
|
117
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
118
|
+
# @return [Object] Returns the model itself
|
|
119
|
+
def build_from_hash(attributes)
|
|
120
|
+
return nil unless attributes.is_a?(Hash)
|
|
121
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
122
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
123
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
124
|
+
self.send("#{key}=", nil)
|
|
125
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
126
|
+
# check to ensure the input is an array given that the attribute
|
|
127
|
+
# is documented as an array but the input is not
|
|
128
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
129
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
130
|
+
end
|
|
131
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
132
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
self
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Deserializes the data based on type
|
|
140
|
+
# @param string type Data type
|
|
141
|
+
# @param string value Value to be deserialized
|
|
142
|
+
# @return [Object] Deserialized data
|
|
143
|
+
def _deserialize(type, value)
|
|
144
|
+
case type.to_sym
|
|
145
|
+
when :Time
|
|
146
|
+
Time.parse(value)
|
|
147
|
+
when :Date
|
|
148
|
+
Date.parse(value)
|
|
149
|
+
when :String
|
|
150
|
+
value.to_s
|
|
151
|
+
when :Integer
|
|
152
|
+
value.to_i
|
|
153
|
+
when :Float
|
|
154
|
+
value.to_f
|
|
155
|
+
when :Boolean
|
|
156
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
157
|
+
true
|
|
158
|
+
else
|
|
159
|
+
false
|
|
160
|
+
end
|
|
161
|
+
when :Object
|
|
162
|
+
# generic object (usually a Hash), return directly
|
|
163
|
+
value
|
|
164
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
165
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
166
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
167
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
168
|
+
k_type = Regexp.last_match[:k_type]
|
|
169
|
+
v_type = Regexp.last_match[:v_type]
|
|
170
|
+
{}.tap do |hash|
|
|
171
|
+
value.each do |k, v|
|
|
172
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
else # model
|
|
176
|
+
# models (e.g. Pet) or oneOf
|
|
177
|
+
klass = UltracartClient.const_get(type)
|
|
178
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Returns the string representation of the object
|
|
183
|
+
# @return [String] String presentation of the object
|
|
184
|
+
def to_s
|
|
185
|
+
to_hash.to_s
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
|
190
|
+
def to_body
|
|
191
|
+
to_hash
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Returns the object in the form of hash
|
|
195
|
+
# @return [Hash] Returns the object in the form of hash
|
|
196
|
+
def to_hash
|
|
197
|
+
hash = {}
|
|
198
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
199
|
+
value = self.send(attr)
|
|
200
|
+
if value.nil?
|
|
201
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
202
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
hash[param] = _to_hash(value)
|
|
206
|
+
end
|
|
207
|
+
hash
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Outputs non-array value in the form of hash
|
|
211
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
212
|
+
# @param [Object] value Any valid value
|
|
213
|
+
# @return [Hash] Returns the value in the form of hash
|
|
214
|
+
def _to_hash(value)
|
|
215
|
+
if value.is_a?(Array)
|
|
216
|
+
value.compact.map { |v| _to_hash(v) }
|
|
217
|
+
elsif value.is_a?(Hash)
|
|
218
|
+
{}.tap do |hash|
|
|
219
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
220
|
+
end
|
|
221
|
+
elsif value.respond_to? :to_hash
|
|
222
|
+
value.to_hash
|
|
223
|
+
else
|
|
224
|
+
value
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
end
|