ultracart_api 4.1.182 → 4.1.184
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 +37 -2
- data/docs/AutoOrderApi.md +28 -1
- data/docs/OrderApi.md +107 -3
- data/docs/SfvbApi.md +941 -50
- data/docs/SfvbLibraryAiReview.md +28 -0
- data/docs/SfvbLibraryContentManifest.md +26 -0
- data/docs/SfvbLibraryDeleteResult.md +20 -0
- data/docs/SfvbLibraryEntry.md +28 -0
- data/docs/SfvbLibraryEntryRequest.md +30 -0
- data/docs/SfvbLibraryFacet.md +2 -2
- data/docs/SfvbLibraryHistoryEntry.md +24 -0
- data/docs/SfvbLibraryInstallConflict.md +22 -0
- data/docs/SfvbLibraryInstallReceipt.md +32 -0
- data/docs/SfvbLibraryInstallRecord.md +32 -0
- data/docs/SfvbLibraryInstallRequest.md +22 -0
- data/docs/SfvbLibraryParameter.md +26 -0
- data/docs/SfvbLibraryPublishRequest.md +20 -0
- data/docs/SfvbLibraryScreenshotRequest.md +22 -0
- data/docs/SfvbLibraryShareRequest.md +18 -0
- data/docs/SfvbLibraryShareTarget.md +20 -0
- data/docs/SfvbLibraryTaxonomy.md +24 -0
- data/docs/SfvbLibraryTaxonomyCatalog.md +18 -0
- data/docs/SfvbLibraryUnshareResult.md +22 -0
- data/docs/SfvbWhoamiResponse.md +2 -0
- data/lib/ultracart_api/api/sfvb_api.rb +1334 -118
- data/lib/ultracart_api/models/sfvb_library_ai_review.rb +304 -0
- data/lib/ultracart_api/models/sfvb_library_content_manifest.rb +259 -0
- data/lib/ultracart_api/models/sfvb_library_delete_result.rb +264 -0
- data/lib/ultracart_api/models/sfvb_library_entry.rb +177 -1
- data/lib/ultracart_api/models/sfvb_library_entry_request.rb +280 -0
- data/lib/ultracart_api/models/sfvb_library_facet.rb +2 -2
- data/lib/ultracart_api/models/sfvb_library_history_entry.rb +250 -0
- data/lib/ultracart_api/models/sfvb_library_install_conflict.rb +240 -0
- data/lib/ultracart_api/models/sfvb_library_install_receipt.rb +297 -0
- data/lib/ultracart_api/models/sfvb_library_install_record.rb +290 -0
- data/lib/ultracart_api/models/sfvb_library_install_request.rb +274 -0
- data/lib/ultracart_api/models/sfvb_library_parameter.rb +260 -0
- data/lib/ultracart_api/models/sfvb_library_publish_request.rb +264 -0
- data/lib/ultracart_api/models/sfvb_library_screenshot_request.rb +274 -0
- data/lib/ultracart_api/models/sfvb_library_share_request.rb +220 -0
- data/lib/ultracart_api/models/sfvb_library_share_target.rb +230 -0
- data/lib/ultracart_api/models/sfvb_library_taxonomy.rb +258 -0
- data/lib/ultracart_api/models/sfvb_library_taxonomy_catalog.rb +220 -0
- data/lib/ultracart_api/models/sfvb_library_unshare_result.rb +242 -0
- data/lib/ultracart_api/models/sfvb_whoami_response.rb +11 -1
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +17 -0
- metadata +36 -2
|
@@ -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 SfvbLibraryEntryRequest
|
|
18
|
+
# The fragment, one widget and its children. Not a whole container.
|
|
19
|
+
attr_accessor :cjson
|
|
20
|
+
|
|
21
|
+
# What the fragment is for, at most 1024 characters.
|
|
22
|
+
attr_accessor :description
|
|
23
|
+
|
|
24
|
+
# Entry name, at most 100 characters.
|
|
25
|
+
attr_accessor :name
|
|
26
|
+
|
|
27
|
+
# Named values the fragment expects its installer to supply.
|
|
28
|
+
attr_accessor :parameters
|
|
29
|
+
|
|
30
|
+
attr_accessor :screenshot
|
|
31
|
+
|
|
32
|
+
# True to let the other users on this merchant account see the published revision.
|
|
33
|
+
attr_accessor :share_with_account
|
|
34
|
+
|
|
35
|
+
attr_accessor :taxonomy
|
|
36
|
+
|
|
37
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
38
|
+
def self.attribute_map
|
|
39
|
+
{
|
|
40
|
+
:'cjson' => :'cjson',
|
|
41
|
+
:'description' => :'description',
|
|
42
|
+
:'name' => :'name',
|
|
43
|
+
:'parameters' => :'parameters',
|
|
44
|
+
:'screenshot' => :'screenshot',
|
|
45
|
+
:'share_with_account' => :'share_with_account',
|
|
46
|
+
:'taxonomy' => :'taxonomy'
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns all the JSON keys this model knows about
|
|
51
|
+
def self.acceptable_attributes
|
|
52
|
+
attribute_map.values
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Attribute type mapping.
|
|
56
|
+
def self.openapi_types
|
|
57
|
+
{
|
|
58
|
+
:'cjson' => :'String',
|
|
59
|
+
:'description' => :'String',
|
|
60
|
+
:'name' => :'String',
|
|
61
|
+
:'parameters' => :'Array<SfvbLibraryParameter>',
|
|
62
|
+
:'screenshot' => :'SfvbLibraryScreenshotRequest',
|
|
63
|
+
:'share_with_account' => :'Boolean',
|
|
64
|
+
:'taxonomy' => :'SfvbLibraryTaxonomy'
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# List of attributes with nullable: true
|
|
69
|
+
def self.openapi_nullable
|
|
70
|
+
Set.new([
|
|
71
|
+
])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Initializes the object
|
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
76
|
+
def initialize(attributes = {})
|
|
77
|
+
if (!attributes.is_a?(Hash))
|
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbLibraryEntryRequest` initialize method"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbLibraryEntryRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
85
|
+
end
|
|
86
|
+
h[k.to_sym] = v
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'cjson')
|
|
90
|
+
self.cjson = attributes[:'cjson']
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
if attributes.key?(:'description')
|
|
94
|
+
self.description = attributes[:'description']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'name')
|
|
98
|
+
self.name = attributes[:'name']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'parameters')
|
|
102
|
+
if (value = attributes[:'parameters']).is_a?(Array)
|
|
103
|
+
self.parameters = value
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if attributes.key?(:'screenshot')
|
|
108
|
+
self.screenshot = attributes[:'screenshot']
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'share_with_account')
|
|
112
|
+
self.share_with_account = attributes[:'share_with_account']
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if attributes.key?(:'taxonomy')
|
|
116
|
+
self.taxonomy = attributes[:'taxonomy']
|
|
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
|
+
cjson == o.cjson &&
|
|
139
|
+
description == o.description &&
|
|
140
|
+
name == o.name &&
|
|
141
|
+
parameters == o.parameters &&
|
|
142
|
+
screenshot == o.screenshot &&
|
|
143
|
+
share_with_account == o.share_with_account &&
|
|
144
|
+
taxonomy == o.taxonomy
|
|
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
|
+
[cjson, description, name, parameters, screenshot, share_with_account, taxonomy].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
|
|
@@ -18,10 +18,10 @@ module UltracartClient
|
|
|
18
18
|
# Human readable facet name.
|
|
19
19
|
attr_accessor :display_name
|
|
20
20
|
|
|
21
|
-
# Facet key.
|
|
21
|
+
# Facet key, such as facet_purpose. To select an option, add a query parameter named after the key whose value is the key, a colon and the option.
|
|
22
22
|
attr_accessor :name
|
|
23
23
|
|
|
24
|
-
#
|
|
24
|
+
# Values present in the results. A facet with only one value is left out unless it is selected.
|
|
25
25
|
attr_accessor :options
|
|
26
26
|
|
|
27
27
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -0,0 +1,250 @@
|
|
|
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 SfvbLibraryHistoryEntry
|
|
18
|
+
# Hash of the published revision.
|
|
19
|
+
attr_accessor :hash_sha256
|
|
20
|
+
|
|
21
|
+
# When it was published, ISO 8601.
|
|
22
|
+
attr_accessor :published_dts
|
|
23
|
+
|
|
24
|
+
# What changed, as the publisher described it.
|
|
25
|
+
attr_accessor :release_notes
|
|
26
|
+
|
|
27
|
+
# The revision that was published.
|
|
28
|
+
attr_accessor :revision_number
|
|
29
|
+
|
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
31
|
+
def self.attribute_map
|
|
32
|
+
{
|
|
33
|
+
:'hash_sha256' => :'hash_sha256',
|
|
34
|
+
:'published_dts' => :'published_dts',
|
|
35
|
+
:'release_notes' => :'release_notes',
|
|
36
|
+
:'revision_number' => :'revision_number'
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns all the JSON keys this model knows about
|
|
41
|
+
def self.acceptable_attributes
|
|
42
|
+
attribute_map.values
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Attribute type mapping.
|
|
46
|
+
def self.openapi_types
|
|
47
|
+
{
|
|
48
|
+
:'hash_sha256' => :'String',
|
|
49
|
+
:'published_dts' => :'String',
|
|
50
|
+
:'release_notes' => :'String',
|
|
51
|
+
:'revision_number' => :'Integer'
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# List of attributes with nullable: true
|
|
56
|
+
def self.openapi_nullable
|
|
57
|
+
Set.new([
|
|
58
|
+
])
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Initializes the object
|
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
63
|
+
def initialize(attributes = {})
|
|
64
|
+
if (!attributes.is_a?(Hash))
|
|
65
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbLibraryHistoryEntry` initialize method"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
69
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
70
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
71
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbLibraryHistoryEntry`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
72
|
+
end
|
|
73
|
+
h[k.to_sym] = v
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if attributes.key?(:'hash_sha256')
|
|
77
|
+
self.hash_sha256 = attributes[:'hash_sha256']
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if attributes.key?(:'published_dts')
|
|
81
|
+
self.published_dts = attributes[:'published_dts']
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if attributes.key?(:'release_notes')
|
|
85
|
+
self.release_notes = attributes[:'release_notes']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:'revision_number')
|
|
89
|
+
self.revision_number = attributes[:'revision_number']
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
94
|
+
# @return Array for valid properties with the reasons
|
|
95
|
+
def list_invalid_properties
|
|
96
|
+
invalid_properties = Array.new
|
|
97
|
+
invalid_properties
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Check to see if the all the properties in the model are valid
|
|
101
|
+
# @return true if the model is valid
|
|
102
|
+
def valid?
|
|
103
|
+
true
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Checks equality by comparing each attribute.
|
|
107
|
+
# @param [Object] Object to be compared
|
|
108
|
+
def ==(o)
|
|
109
|
+
return true if self.equal?(o)
|
|
110
|
+
self.class == o.class &&
|
|
111
|
+
hash_sha256 == o.hash_sha256 &&
|
|
112
|
+
published_dts == o.published_dts &&
|
|
113
|
+
release_notes == o.release_notes &&
|
|
114
|
+
revision_number == o.revision_number
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# @see the `==` method
|
|
118
|
+
# @param [Object] Object to be compared
|
|
119
|
+
def eql?(o)
|
|
120
|
+
self == o
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Calculates hash code according to all attributes.
|
|
124
|
+
# @return [Integer] Hash code
|
|
125
|
+
def hash
|
|
126
|
+
[hash_sha256, published_dts, release_notes, revision_number].hash
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Builds the object from hash
|
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
131
|
+
# @return [Object] Returns the model itself
|
|
132
|
+
def self.build_from_hash(attributes)
|
|
133
|
+
new.build_from_hash(attributes)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Builds the object from hash
|
|
137
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
138
|
+
# @return [Object] Returns the model itself
|
|
139
|
+
def build_from_hash(attributes)
|
|
140
|
+
return nil unless attributes.is_a?(Hash)
|
|
141
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
142
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
143
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
144
|
+
self.send("#{key}=", nil)
|
|
145
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
146
|
+
# check to ensure the input is an array given that the attribute
|
|
147
|
+
# is documented as an array but the input is not
|
|
148
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
149
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
150
|
+
end
|
|
151
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
152
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
self
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Deserializes the data based on type
|
|
160
|
+
# @param string type Data type
|
|
161
|
+
# @param string value Value to be deserialized
|
|
162
|
+
# @return [Object] Deserialized data
|
|
163
|
+
def _deserialize(type, value)
|
|
164
|
+
case type.to_sym
|
|
165
|
+
when :Time
|
|
166
|
+
Time.parse(value)
|
|
167
|
+
when :Date
|
|
168
|
+
Date.parse(value)
|
|
169
|
+
when :String
|
|
170
|
+
value.to_s
|
|
171
|
+
when :Integer
|
|
172
|
+
value.to_i
|
|
173
|
+
when :Float
|
|
174
|
+
value.to_f
|
|
175
|
+
when :Boolean
|
|
176
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
177
|
+
true
|
|
178
|
+
else
|
|
179
|
+
false
|
|
180
|
+
end
|
|
181
|
+
when :Object
|
|
182
|
+
# generic object (usually a Hash), return directly
|
|
183
|
+
value
|
|
184
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
185
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
186
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
187
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
188
|
+
k_type = Regexp.last_match[:k_type]
|
|
189
|
+
v_type = Regexp.last_match[:v_type]
|
|
190
|
+
{}.tap do |hash|
|
|
191
|
+
value.each do |k, v|
|
|
192
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
else # model
|
|
196
|
+
# models (e.g. Pet) or oneOf
|
|
197
|
+
klass = UltracartClient.const_get(type)
|
|
198
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Returns the string representation of the object
|
|
203
|
+
# @return [String] String presentation of the object
|
|
204
|
+
def to_s
|
|
205
|
+
to_hash.to_s
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
209
|
+
# @return [Hash] Returns the object in the form of hash
|
|
210
|
+
def to_body
|
|
211
|
+
to_hash
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Returns the object in the form of hash
|
|
215
|
+
# @return [Hash] Returns the object in the form of hash
|
|
216
|
+
def to_hash
|
|
217
|
+
hash = {}
|
|
218
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
219
|
+
value = self.send(attr)
|
|
220
|
+
if value.nil?
|
|
221
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
222
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
hash[param] = _to_hash(value)
|
|
226
|
+
end
|
|
227
|
+
hash
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Outputs non-array value in the form of hash
|
|
231
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
232
|
+
# @param [Object] value Any valid value
|
|
233
|
+
# @return [Hash] Returns the value in the form of hash
|
|
234
|
+
def _to_hash(value)
|
|
235
|
+
if value.is_a?(Array)
|
|
236
|
+
value.compact.map { |v| _to_hash(v) }
|
|
237
|
+
elsif value.is_a?(Hash)
|
|
238
|
+
{}.tap do |hash|
|
|
239
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
240
|
+
end
|
|
241
|
+
elsif value.respond_to? :to_hash
|
|
242
|
+
value.to_hash
|
|
243
|
+
else
|
|
244
|
+
value
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
end
|