ultracart_api 4.1.156 → 4.1.158
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 +10 -2
- data/docs/SfvbApi.md +115 -4
- data/docs/SfvbContainerResponse.md +2 -0
- data/docs/SfvbSiteAttribute.md +30 -0
- data/docs/SfvbSiteAttributeUpdate.md +22 -0
- data/docs/SfvbSiteAttributeUpdateRequest.md +18 -0
- data/docs/SfvbSiteAttributesResponse.md +20 -0
- data/lib/ultracart_api/api/sfvb_api.rb +149 -8
- data/lib/ultracart_api/models/sfvb_container_response.rb +11 -1
- data/lib/ultracart_api/models/sfvb_site_attribute.rb +314 -0
- data/lib/ultracart_api/models/sfvb_site_attribute_update.rb +274 -0
- data/lib/ultracart_api/models/sfvb_site_attribute_update_request.rb +222 -0
- data/lib/ultracart_api/models/sfvb_site_attributes_response.rb +232 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +4 -0
- metadata +10 -2
|
@@ -27,6 +27,9 @@ module UltracartClient
|
|
|
27
27
|
# When the container was last modified, in the store's own record of it. Every owner type reports this. It is absent only when the container has never been written since the store began recording it, so treat an absent value as unknown rather than as never modified. Two behaviours worth knowing. A postcard keeps one timestamp for both of its sides, so writing the front moves the value the back reports. An upsell container that is rewritten with byte identical content keeps its original date rather than moving to now, because the timestamp tracks changes to the container and not writes to the offer.
|
|
28
28
|
attr_accessor :last_modified
|
|
29
29
|
|
|
30
|
+
# The merchant item id of the owning item, for item containers only and absent for every other owner type. owner_object_id is the item oid, which appears nowhere on a rendered storefront, so this is how a caller confirms which item an oid actually reached. It is read fresh on every call and so reflects a renamed item. A container's own id embeds this value, which is what a preview session keys an item container on.
|
|
31
|
+
attr_accessor :merchant_item_id
|
|
32
|
+
|
|
30
33
|
# Identifier of the owning object within its store.
|
|
31
34
|
attr_accessor :owner_object_id
|
|
32
35
|
|
|
@@ -62,6 +65,7 @@ module UltracartClient
|
|
|
62
65
|
:'container_name' => :'container_name',
|
|
63
66
|
:'hash_sha256' => :'hash_sha256',
|
|
64
67
|
:'last_modified' => :'last_modified',
|
|
68
|
+
:'merchant_item_id' => :'merchant_item_id',
|
|
65
69
|
:'owner_object_id' => :'owner_object_id',
|
|
66
70
|
:'owner_type' => :'owner_type'
|
|
67
71
|
}
|
|
@@ -79,6 +83,7 @@ module UltracartClient
|
|
|
79
83
|
:'container_name' => :'String',
|
|
80
84
|
:'hash_sha256' => :'String',
|
|
81
85
|
:'last_modified' => :'String',
|
|
86
|
+
:'merchant_item_id' => :'String',
|
|
82
87
|
:'owner_object_id' => :'String',
|
|
83
88
|
:'owner_type' => :'String'
|
|
84
89
|
}
|
|
@@ -121,6 +126,10 @@ module UltracartClient
|
|
|
121
126
|
self.last_modified = attributes[:'last_modified']
|
|
122
127
|
end
|
|
123
128
|
|
|
129
|
+
if attributes.key?(:'merchant_item_id')
|
|
130
|
+
self.merchant_item_id = attributes[:'merchant_item_id']
|
|
131
|
+
end
|
|
132
|
+
|
|
124
133
|
if attributes.key?(:'owner_object_id')
|
|
125
134
|
self.owner_object_id = attributes[:'owner_object_id']
|
|
126
135
|
end
|
|
@@ -164,6 +173,7 @@ module UltracartClient
|
|
|
164
173
|
container_name == o.container_name &&
|
|
165
174
|
hash_sha256 == o.hash_sha256 &&
|
|
166
175
|
last_modified == o.last_modified &&
|
|
176
|
+
merchant_item_id == o.merchant_item_id &&
|
|
167
177
|
owner_object_id == o.owner_object_id &&
|
|
168
178
|
owner_type == o.owner_type
|
|
169
179
|
end
|
|
@@ -177,7 +187,7 @@ module UltracartClient
|
|
|
177
187
|
# Calculates hash code according to all attributes.
|
|
178
188
|
# @return [Integer] Hash code
|
|
179
189
|
def hash
|
|
180
|
-
[cjson, container_name, hash_sha256, last_modified, owner_object_id, owner_type].hash
|
|
190
|
+
[cjson, container_name, hash_sha256, last_modified, merchant_item_id, owner_object_id, owner_type].hash
|
|
181
191
|
end
|
|
182
192
|
|
|
183
193
|
# Builds the object from hash
|
|
@@ -0,0 +1,314 @@
|
|
|
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 SfvbSiteAttribute
|
|
18
|
+
# Attribute name, as a template's site attribute declaration spells it. Compare case insensitively. This is the value siteAttributeName refers to and the name $site.attr takes.
|
|
19
|
+
attr_accessor :name
|
|
20
|
+
|
|
21
|
+
# What kind of attribute this is, taken from the template that declares it rather than from the stored row. orphan means no template declares it. reserved covers the settings the StoreFronts General screen owns.
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# True when no template declares this name and it is not a reserved setting. A template can still read it with $site.attr, so this is not proof it is unused, but a name you did not mean to create is most likely a misspelling.
|
|
25
|
+
attr_accessor :undeclared
|
|
26
|
+
|
|
27
|
+
# The other themes that declare this attribute, when the active theme does not.
|
|
28
|
+
attr_accessor :used_by
|
|
29
|
+
|
|
30
|
+
# True when a template in the active theme declares this attribute.
|
|
31
|
+
attr_accessor :used_by_current_theme
|
|
32
|
+
|
|
33
|
+
# The stored value, or the template default when nothing has set it.
|
|
34
|
+
attr_accessor :value
|
|
35
|
+
|
|
36
|
+
# True when this API will change the value. List, video list, mailing list and item set values are structured documents and must be edited in the store admin. Of the reserved settings only the title, the SEO description and keywords and the social account names are writable here.
|
|
37
|
+
attr_accessor :writable
|
|
38
|
+
|
|
39
|
+
class EnumAttributeValidator
|
|
40
|
+
attr_reader :datatype
|
|
41
|
+
attr_reader :allowable_values
|
|
42
|
+
|
|
43
|
+
def initialize(datatype, allowable_values)
|
|
44
|
+
@allowable_values = allowable_values.map do |value|
|
|
45
|
+
case datatype.to_s
|
|
46
|
+
when /Integer/i
|
|
47
|
+
value.to_i
|
|
48
|
+
when /Float/i
|
|
49
|
+
value.to_f
|
|
50
|
+
else
|
|
51
|
+
value
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def valid?(value)
|
|
57
|
+
!value || allowable_values.include?(value)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
62
|
+
def self.attribute_map
|
|
63
|
+
{
|
|
64
|
+
:'name' => :'name',
|
|
65
|
+
:'type' => :'type',
|
|
66
|
+
:'undeclared' => :'undeclared',
|
|
67
|
+
:'used_by' => :'used_by',
|
|
68
|
+
:'used_by_current_theme' => :'used_by_current_theme',
|
|
69
|
+
:'value' => :'value',
|
|
70
|
+
:'writable' => :'writable'
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns all the JSON keys this model knows about
|
|
75
|
+
def self.acceptable_attributes
|
|
76
|
+
attribute_map.values
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Attribute type mapping.
|
|
80
|
+
def self.openapi_types
|
|
81
|
+
{
|
|
82
|
+
:'name' => :'String',
|
|
83
|
+
:'type' => :'String',
|
|
84
|
+
:'undeclared' => :'Boolean',
|
|
85
|
+
:'used_by' => :'String',
|
|
86
|
+
:'used_by_current_theme' => :'Boolean',
|
|
87
|
+
:'value' => :'String',
|
|
88
|
+
:'writable' => :'Boolean'
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# List of attributes with nullable: true
|
|
93
|
+
def self.openapi_nullable
|
|
94
|
+
Set.new([
|
|
95
|
+
])
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Initializes the object
|
|
99
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
100
|
+
def initialize(attributes = {})
|
|
101
|
+
if (!attributes.is_a?(Hash))
|
|
102
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbSiteAttribute` initialize method"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
106
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
107
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
108
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbSiteAttribute`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
109
|
+
end
|
|
110
|
+
h[k.to_sym] = v
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'name')
|
|
114
|
+
self.name = attributes[:'name']
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.key?(:'type')
|
|
118
|
+
self.type = attributes[:'type']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'undeclared')
|
|
122
|
+
self.undeclared = attributes[:'undeclared']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.key?(:'used_by')
|
|
126
|
+
self.used_by = attributes[:'used_by']
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
if attributes.key?(:'used_by_current_theme')
|
|
130
|
+
self.used_by_current_theme = attributes[:'used_by_current_theme']
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
if attributes.key?(:'value')
|
|
134
|
+
self.value = attributes[:'value']
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if attributes.key?(:'writable')
|
|
138
|
+
self.writable = attributes[:'writable']
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
143
|
+
# @return Array for valid properties with the reasons
|
|
144
|
+
def list_invalid_properties
|
|
145
|
+
invalid_properties = Array.new
|
|
146
|
+
invalid_properties
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Check to see if the all the properties in the model are valid
|
|
150
|
+
# @return true if the model is valid
|
|
151
|
+
def valid?
|
|
152
|
+
type_validator = EnumAttributeValidator.new('String', ["string", "multiline", "html", "color", "rgba", "boolean", "integer", "orphan", "reserved", "simplelist", "definitionlist", "videolist", "mailinglist", "itemset"])
|
|
153
|
+
return false unless type_validator.valid?(@type)
|
|
154
|
+
true
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
158
|
+
# @param [Object] type Object to be assigned
|
|
159
|
+
def type=(type)
|
|
160
|
+
validator = EnumAttributeValidator.new('String', ["string", "multiline", "html", "color", "rgba", "boolean", "integer", "orphan", "reserved", "simplelist", "definitionlist", "videolist", "mailinglist", "itemset"])
|
|
161
|
+
unless validator.valid?(type)
|
|
162
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
163
|
+
end
|
|
164
|
+
@type = type
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Checks equality by comparing each attribute.
|
|
168
|
+
# @param [Object] Object to be compared
|
|
169
|
+
def ==(o)
|
|
170
|
+
return true if self.equal?(o)
|
|
171
|
+
self.class == o.class &&
|
|
172
|
+
name == o.name &&
|
|
173
|
+
type == o.type &&
|
|
174
|
+
undeclared == o.undeclared &&
|
|
175
|
+
used_by == o.used_by &&
|
|
176
|
+
used_by_current_theme == o.used_by_current_theme &&
|
|
177
|
+
value == o.value &&
|
|
178
|
+
writable == o.writable
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# @see the `==` method
|
|
182
|
+
# @param [Object] Object to be compared
|
|
183
|
+
def eql?(o)
|
|
184
|
+
self == o
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Calculates hash code according to all attributes.
|
|
188
|
+
# @return [Integer] Hash code
|
|
189
|
+
def hash
|
|
190
|
+
[name, type, undeclared, used_by, used_by_current_theme, value, writable].hash
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Builds the object from hash
|
|
194
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
195
|
+
# @return [Object] Returns the model itself
|
|
196
|
+
def self.build_from_hash(attributes)
|
|
197
|
+
new.build_from_hash(attributes)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Builds the object from hash
|
|
201
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
202
|
+
# @return [Object] Returns the model itself
|
|
203
|
+
def build_from_hash(attributes)
|
|
204
|
+
return nil unless attributes.is_a?(Hash)
|
|
205
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
206
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
207
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
208
|
+
self.send("#{key}=", nil)
|
|
209
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
210
|
+
# check to ensure the input is an array given that the attribute
|
|
211
|
+
# is documented as an array but the input is not
|
|
212
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
213
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
214
|
+
end
|
|
215
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
216
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
self
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Deserializes the data based on type
|
|
224
|
+
# @param string type Data type
|
|
225
|
+
# @param string value Value to be deserialized
|
|
226
|
+
# @return [Object] Deserialized data
|
|
227
|
+
def _deserialize(type, value)
|
|
228
|
+
case type.to_sym
|
|
229
|
+
when :Time
|
|
230
|
+
Time.parse(value)
|
|
231
|
+
when :Date
|
|
232
|
+
Date.parse(value)
|
|
233
|
+
when :String
|
|
234
|
+
value.to_s
|
|
235
|
+
when :Integer
|
|
236
|
+
value.to_i
|
|
237
|
+
when :Float
|
|
238
|
+
value.to_f
|
|
239
|
+
when :Boolean
|
|
240
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
241
|
+
true
|
|
242
|
+
else
|
|
243
|
+
false
|
|
244
|
+
end
|
|
245
|
+
when :Object
|
|
246
|
+
# generic object (usually a Hash), return directly
|
|
247
|
+
value
|
|
248
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
249
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
250
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
251
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
252
|
+
k_type = Regexp.last_match[:k_type]
|
|
253
|
+
v_type = Regexp.last_match[:v_type]
|
|
254
|
+
{}.tap do |hash|
|
|
255
|
+
value.each do |k, v|
|
|
256
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
else # model
|
|
260
|
+
# models (e.g. Pet) or oneOf
|
|
261
|
+
klass = UltracartClient.const_get(type)
|
|
262
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Returns the string representation of the object
|
|
267
|
+
# @return [String] String presentation of the object
|
|
268
|
+
def to_s
|
|
269
|
+
to_hash.to_s
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
|
274
|
+
def to_body
|
|
275
|
+
to_hash
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# Returns the object in the form of hash
|
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
|
280
|
+
def to_hash
|
|
281
|
+
hash = {}
|
|
282
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
283
|
+
value = self.send(attr)
|
|
284
|
+
if value.nil?
|
|
285
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
286
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
hash[param] = _to_hash(value)
|
|
290
|
+
end
|
|
291
|
+
hash
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Outputs non-array value in the form of hash
|
|
295
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
296
|
+
# @param [Object] value Any valid value
|
|
297
|
+
# @return [Hash] Returns the value in the form of hash
|
|
298
|
+
def _to_hash(value)
|
|
299
|
+
if value.is_a?(Array)
|
|
300
|
+
value.compact.map { |v| _to_hash(v) }
|
|
301
|
+
elsif value.is_a?(Hash)
|
|
302
|
+
{}.tap do |hash|
|
|
303
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
304
|
+
end
|
|
305
|
+
elsif value.respond_to? :to_hash
|
|
306
|
+
value.to_hash
|
|
307
|
+
else
|
|
308
|
+
value
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
end
|
|
@@ -0,0 +1,274 @@
|
|
|
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 SfvbSiteAttributeUpdate
|
|
18
|
+
# Attribute name. Matched without regard to case against what the storefront already has, so you do not have to reproduce the exact casing. A name nothing matches creates a new attribute.
|
|
19
|
+
attr_accessor :name
|
|
20
|
+
|
|
21
|
+
# Only consulted when creating an attribute no template declares. For a declared attribute the template's type always wins, because the templates decide it and not the caller.
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# The value to store. An empty string clears it. For html the markup is stored as given and rendered as given. For boolean send the text true or false.
|
|
25
|
+
attr_accessor :value
|
|
26
|
+
|
|
27
|
+
class EnumAttributeValidator
|
|
28
|
+
attr_reader :datatype
|
|
29
|
+
attr_reader :allowable_values
|
|
30
|
+
|
|
31
|
+
def initialize(datatype, allowable_values)
|
|
32
|
+
@allowable_values = allowable_values.map do |value|
|
|
33
|
+
case datatype.to_s
|
|
34
|
+
when /Integer/i
|
|
35
|
+
value.to_i
|
|
36
|
+
when /Float/i
|
|
37
|
+
value.to_f
|
|
38
|
+
else
|
|
39
|
+
value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid?(value)
|
|
45
|
+
!value || allowable_values.include?(value)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
50
|
+
def self.attribute_map
|
|
51
|
+
{
|
|
52
|
+
:'name' => :'name',
|
|
53
|
+
:'type' => :'type',
|
|
54
|
+
:'value' => :'value'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns all the JSON keys this model knows about
|
|
59
|
+
def self.acceptable_attributes
|
|
60
|
+
attribute_map.values
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Attribute type mapping.
|
|
64
|
+
def self.openapi_types
|
|
65
|
+
{
|
|
66
|
+
:'name' => :'String',
|
|
67
|
+
:'type' => :'String',
|
|
68
|
+
:'value' => :'String'
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# List of attributes with nullable: true
|
|
73
|
+
def self.openapi_nullable
|
|
74
|
+
Set.new([
|
|
75
|
+
])
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Initializes the object
|
|
79
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
80
|
+
def initialize(attributes = {})
|
|
81
|
+
if (!attributes.is_a?(Hash))
|
|
82
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbSiteAttributeUpdate` initialize method"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
86
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
87
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
88
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbSiteAttributeUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
89
|
+
end
|
|
90
|
+
h[k.to_sym] = v
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if attributes.key?(:'name')
|
|
94
|
+
self.name = attributes[:'name']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'type')
|
|
98
|
+
self.type = attributes[:'type']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'value')
|
|
102
|
+
self.value = attributes[:'value']
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
107
|
+
# @return Array for valid properties with the reasons
|
|
108
|
+
def list_invalid_properties
|
|
109
|
+
invalid_properties = Array.new
|
|
110
|
+
invalid_properties
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Check to see if the all the properties in the model are valid
|
|
114
|
+
# @return true if the model is valid
|
|
115
|
+
def valid?
|
|
116
|
+
type_validator = EnumAttributeValidator.new('String', ["string", "multiline", "html", "boolean", "integer", "color", "rgba"])
|
|
117
|
+
return false unless type_validator.valid?(@type)
|
|
118
|
+
true
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
122
|
+
# @param [Object] type Object to be assigned
|
|
123
|
+
def type=(type)
|
|
124
|
+
validator = EnumAttributeValidator.new('String', ["string", "multiline", "html", "boolean", "integer", "color", "rgba"])
|
|
125
|
+
unless validator.valid?(type)
|
|
126
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
127
|
+
end
|
|
128
|
+
@type = type
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Checks equality by comparing each attribute.
|
|
132
|
+
# @param [Object] Object to be compared
|
|
133
|
+
def ==(o)
|
|
134
|
+
return true if self.equal?(o)
|
|
135
|
+
self.class == o.class &&
|
|
136
|
+
name == o.name &&
|
|
137
|
+
type == o.type &&
|
|
138
|
+
value == o.value
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# @see the `==` method
|
|
142
|
+
# @param [Object] Object to be compared
|
|
143
|
+
def eql?(o)
|
|
144
|
+
self == o
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Calculates hash code according to all attributes.
|
|
148
|
+
# @return [Integer] Hash code
|
|
149
|
+
def hash
|
|
150
|
+
[name, type, value].hash
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Builds the object from hash
|
|
154
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
155
|
+
# @return [Object] Returns the model itself
|
|
156
|
+
def self.build_from_hash(attributes)
|
|
157
|
+
new.build_from_hash(attributes)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Builds the object from hash
|
|
161
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
162
|
+
# @return [Object] Returns the model itself
|
|
163
|
+
def build_from_hash(attributes)
|
|
164
|
+
return nil unless attributes.is_a?(Hash)
|
|
165
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
166
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
167
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
168
|
+
self.send("#{key}=", nil)
|
|
169
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
170
|
+
# check to ensure the input is an array given that the attribute
|
|
171
|
+
# is documented as an array but the input is not
|
|
172
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
173
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
174
|
+
end
|
|
175
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
176
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
self
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Deserializes the data based on type
|
|
184
|
+
# @param string type Data type
|
|
185
|
+
# @param string value Value to be deserialized
|
|
186
|
+
# @return [Object] Deserialized data
|
|
187
|
+
def _deserialize(type, value)
|
|
188
|
+
case type.to_sym
|
|
189
|
+
when :Time
|
|
190
|
+
Time.parse(value)
|
|
191
|
+
when :Date
|
|
192
|
+
Date.parse(value)
|
|
193
|
+
when :String
|
|
194
|
+
value.to_s
|
|
195
|
+
when :Integer
|
|
196
|
+
value.to_i
|
|
197
|
+
when :Float
|
|
198
|
+
value.to_f
|
|
199
|
+
when :Boolean
|
|
200
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
201
|
+
true
|
|
202
|
+
else
|
|
203
|
+
false
|
|
204
|
+
end
|
|
205
|
+
when :Object
|
|
206
|
+
# generic object (usually a Hash), return directly
|
|
207
|
+
value
|
|
208
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
209
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
210
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
211
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
212
|
+
k_type = Regexp.last_match[:k_type]
|
|
213
|
+
v_type = Regexp.last_match[:v_type]
|
|
214
|
+
{}.tap do |hash|
|
|
215
|
+
value.each do |k, v|
|
|
216
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
else # model
|
|
220
|
+
# models (e.g. Pet) or oneOf
|
|
221
|
+
klass = UltracartClient.const_get(type)
|
|
222
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Returns the string representation of the object
|
|
227
|
+
# @return [String] String presentation of the object
|
|
228
|
+
def to_s
|
|
229
|
+
to_hash.to_s
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
233
|
+
# @return [Hash] Returns the object in the form of hash
|
|
234
|
+
def to_body
|
|
235
|
+
to_hash
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Returns the object in the form of hash
|
|
239
|
+
# @return [Hash] Returns the object in the form of hash
|
|
240
|
+
def to_hash
|
|
241
|
+
hash = {}
|
|
242
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
243
|
+
value = self.send(attr)
|
|
244
|
+
if value.nil?
|
|
245
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
246
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
hash[param] = _to_hash(value)
|
|
250
|
+
end
|
|
251
|
+
hash
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Outputs non-array value in the form of hash
|
|
255
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
256
|
+
# @param [Object] value Any valid value
|
|
257
|
+
# @return [Hash] Returns the value in the form of hash
|
|
258
|
+
def _to_hash(value)
|
|
259
|
+
if value.is_a?(Array)
|
|
260
|
+
value.compact.map { |v| _to_hash(v) }
|
|
261
|
+
elsif value.is_a?(Hash)
|
|
262
|
+
{}.tap do |hash|
|
|
263
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
264
|
+
end
|
|
265
|
+
elsif value.respond_to? :to_hash
|
|
266
|
+
value.to_hash
|
|
267
|
+
else
|
|
268
|
+
value
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
end
|