solifyn 1.1.4 → 1.1.6
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 +21 -4
- data/docs/CreateEntitlementDto.md +42 -0
- data/docs/CreateFramerTemplateDto.md +22 -0
- data/docs/EntitlementDetailResponseDto.md +56 -0
- data/docs/EntitlementGrantResponseDto.md +4 -0
- data/docs/EntitlementGrantsApi.md +5 -1
- data/docs/EntitlementsApi.md +331 -0
- data/docs/FramerIntegrationApi.md +355 -0
- data/docs/FramerTemplateResponseDto.md +30 -0
- data/docs/LinkedProductDto.md +20 -0
- data/docs/ProductCreate.md +7 -1
- data/docs/ProductUpdate.md +7 -1
- data/docs/UpdateEntitlementDto.md +42 -0
- data/docs/UpdateFramerTemplateDto.md +22 -0
- data/lib/solifyn/api/entitlement_grants_api.rb +6 -0
- data/lib/solifyn/api/entitlements_api.rb +347 -0
- data/lib/solifyn/api/framer_integration_api.rb +345 -0
- data/lib/solifyn/models/create_entitlement_dto.rb +385 -0
- data/lib/solifyn/models/create_framer_template_dto.rb +249 -0
- data/lib/solifyn/models/entitlement_detail_response_dto.rb +470 -0
- data/lib/solifyn/models/entitlement_grant_response_dto.rb +21 -1
- data/lib/solifyn/models/framer_template_response_dto.rb +317 -0
- data/lib/solifyn/models/linked_product_dto.rb +239 -0
- data/lib/solifyn/models/product_create.rb +38 -4
- data/lib/solifyn/models/product_update.rb +38 -4
- data/lib/solifyn/models/update_entitlement_dto.rb +371 -0
- data/lib/solifyn/models/update_framer_template_dto.rb +235 -0
- data/lib/solifyn/version.rb +1 -1
- data/lib/solifyn.rb +9 -0
- data/spec/api/entitlements_api_spec.rb +95 -0
- data/spec/api/framer_integration_api_spec.rb +95 -0
- data/spec/models/create_entitlement_dto_spec.rb +112 -0
- data/spec/models/create_framer_template_dto_spec.rb +48 -0
- data/spec/models/entitlement_detail_response_dto_spec.rb +150 -0
- data/spec/models/framer_template_response_dto_spec.rb +72 -0
- data/spec/models/linked_product_dto_spec.rb +42 -0
- data/spec/models/update_entitlement_dto_spec.rb +112 -0
- data/spec/models/update_framer_template_dto_spec.rb +48 -0
- metadata +172 -136
|
@@ -60,6 +60,12 @@ module Solifyn
|
|
|
60
60
|
# Discord Role ID to assign to the user.
|
|
61
61
|
attr_accessor :discord_role_id
|
|
62
62
|
|
|
63
|
+
# Whether the purchase includes Framer Template access.
|
|
64
|
+
attr_accessor :has_framer_access
|
|
65
|
+
|
|
66
|
+
# Framer Template ID to grant access to.
|
|
67
|
+
attr_accessor :framer_template_id
|
|
68
|
+
|
|
63
69
|
# Whether tax is included in the base price.
|
|
64
70
|
attr_accessor :is_tax_inclusive
|
|
65
71
|
|
|
@@ -102,6 +108,9 @@ module Solifyn
|
|
|
102
108
|
# Product addons configurations.
|
|
103
109
|
attr_accessor :addons
|
|
104
110
|
|
|
111
|
+
# Array of independent entitlement IDs to link to this product.
|
|
112
|
+
attr_accessor :entitlement_ids
|
|
113
|
+
|
|
105
114
|
class EnumAttributeValidator
|
|
106
115
|
attr_reader :datatype
|
|
107
116
|
attr_reader :allowable_values
|
|
@@ -142,6 +151,8 @@ module Solifyn
|
|
|
142
151
|
:'has_discord_access' => :'hasDiscordAccess',
|
|
143
152
|
:'discord_guild_id' => :'discordGuildId',
|
|
144
153
|
:'discord_role_id' => :'discordRoleId',
|
|
154
|
+
:'has_framer_access' => :'hasFramerAccess',
|
|
155
|
+
:'framer_template_id' => :'framerTemplateId',
|
|
145
156
|
:'is_tax_inclusive' => :'isTaxInclusive',
|
|
146
157
|
:'activation_limit' => :'activationLimit',
|
|
147
158
|
:'brand_id' => :'brandId',
|
|
@@ -155,7 +166,8 @@ module Solifyn
|
|
|
155
166
|
:'stock' => :'stock',
|
|
156
167
|
:'is_listed' => :'isListed',
|
|
157
168
|
:'is_free' => :'isFree',
|
|
158
|
-
:'addons' => :'addons'
|
|
169
|
+
:'addons' => :'addons',
|
|
170
|
+
:'entitlement_ids' => :'entitlementIds'
|
|
159
171
|
}
|
|
160
172
|
end
|
|
161
173
|
|
|
@@ -182,6 +194,8 @@ module Solifyn
|
|
|
182
194
|
:'has_discord_access' => :'Boolean',
|
|
183
195
|
:'discord_guild_id' => :'String',
|
|
184
196
|
:'discord_role_id' => :'String',
|
|
197
|
+
:'has_framer_access' => :'Boolean',
|
|
198
|
+
:'framer_template_id' => :'String',
|
|
185
199
|
:'is_tax_inclusive' => :'Boolean',
|
|
186
200
|
:'activation_limit' => :'Integer',
|
|
187
201
|
:'brand_id' => :'String',
|
|
@@ -195,7 +209,8 @@ module Solifyn
|
|
|
195
209
|
:'stock' => :'Integer',
|
|
196
210
|
:'is_listed' => :'Boolean',
|
|
197
211
|
:'is_free' => :'Boolean',
|
|
198
|
-
:'addons' => :'Array<ProductCreateAddonsInner>'
|
|
212
|
+
:'addons' => :'Array<ProductCreateAddonsInner>',
|
|
213
|
+
:'entitlement_ids' => :'Array<String>'
|
|
199
214
|
}
|
|
200
215
|
end
|
|
201
216
|
|
|
@@ -290,6 +305,16 @@ module Solifyn
|
|
|
290
305
|
self.discord_role_id = attributes[:'discord_role_id']
|
|
291
306
|
end
|
|
292
307
|
|
|
308
|
+
if attributes.key?(:'has_framer_access')
|
|
309
|
+
self.has_framer_access = attributes[:'has_framer_access']
|
|
310
|
+
else
|
|
311
|
+
self.has_framer_access = false
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
if attributes.key?(:'framer_template_id')
|
|
315
|
+
self.framer_template_id = attributes[:'framer_template_id']
|
|
316
|
+
end
|
|
317
|
+
|
|
293
318
|
if attributes.key?(:'is_tax_inclusive')
|
|
294
319
|
self.is_tax_inclusive = attributes[:'is_tax_inclusive']
|
|
295
320
|
else
|
|
@@ -359,6 +384,12 @@ module Solifyn
|
|
|
359
384
|
self.addons = value
|
|
360
385
|
end
|
|
361
386
|
end
|
|
387
|
+
|
|
388
|
+
if attributes.key?(:'entitlement_ids')
|
|
389
|
+
if (value = attributes[:'entitlement_ids']).is_a?(Array)
|
|
390
|
+
self.entitlement_ids = value
|
|
391
|
+
end
|
|
392
|
+
end
|
|
362
393
|
end
|
|
363
394
|
|
|
364
395
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -432,6 +463,8 @@ module Solifyn
|
|
|
432
463
|
has_discord_access == o.has_discord_access &&
|
|
433
464
|
discord_guild_id == o.discord_guild_id &&
|
|
434
465
|
discord_role_id == o.discord_role_id &&
|
|
466
|
+
has_framer_access == o.has_framer_access &&
|
|
467
|
+
framer_template_id == o.framer_template_id &&
|
|
435
468
|
is_tax_inclusive == o.is_tax_inclusive &&
|
|
436
469
|
activation_limit == o.activation_limit &&
|
|
437
470
|
brand_id == o.brand_id &&
|
|
@@ -445,7 +478,8 @@ module Solifyn
|
|
|
445
478
|
stock == o.stock &&
|
|
446
479
|
is_listed == o.is_listed &&
|
|
447
480
|
is_free == o.is_free &&
|
|
448
|
-
addons == o.addons
|
|
481
|
+
addons == o.addons &&
|
|
482
|
+
entitlement_ids == o.entitlement_ids
|
|
449
483
|
end
|
|
450
484
|
|
|
451
485
|
# @see the `==` method
|
|
@@ -457,7 +491,7 @@ module Solifyn
|
|
|
457
491
|
# Calculates hash code according to all attributes.
|
|
458
492
|
# @return [Integer] Hash code
|
|
459
493
|
def hash
|
|
460
|
-
[name, description, price, currency, image_url, tax_category, discount, has_license_key, has_digital_delivery, has_github_access, github_repo, github_permission, has_discord_access, discord_guild_id, discord_role_id, is_tax_inclusive, activation_limit, brand_id, billing_period, trial_period_days, expiration_days, statement_descriptor, pay_what_you_want, metadata, custom_fields, stock, is_listed, is_free, addons].hash
|
|
494
|
+
[name, description, price, currency, image_url, tax_category, discount, has_license_key, has_digital_delivery, has_github_access, github_repo, github_permission, has_discord_access, discord_guild_id, discord_role_id, has_framer_access, framer_template_id, is_tax_inclusive, activation_limit, brand_id, billing_period, trial_period_days, expiration_days, statement_descriptor, pay_what_you_want, metadata, custom_fields, stock, is_listed, is_free, addons, entitlement_ids].hash
|
|
461
495
|
end
|
|
462
496
|
|
|
463
497
|
# Builds the object from hash
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Solifyn API
|
|
3
|
+
|
|
4
|
+
#Welcome to the Solifyn API Reference. Leverage our secure endpoints to manage products and issue, validate, and manage software license keys programmatically.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.10.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Solifyn
|
|
17
|
+
class UpdateEntitlementDto
|
|
18
|
+
# The user-friendly name of the entitlement
|
|
19
|
+
attr_accessor :name
|
|
20
|
+
|
|
21
|
+
# The type of access to grant
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# The GitHub repository (e.g., owner/repo)
|
|
25
|
+
attr_accessor :github_repo
|
|
26
|
+
|
|
27
|
+
# The GitHub repository permission level
|
|
28
|
+
attr_accessor :github_permission
|
|
29
|
+
|
|
30
|
+
# The Discord Guild/Server ID
|
|
31
|
+
attr_accessor :discord_guild_id
|
|
32
|
+
|
|
33
|
+
# The Discord Role ID to assign
|
|
34
|
+
attr_accessor :discord_role_id
|
|
35
|
+
|
|
36
|
+
# The associated Framer Template ID
|
|
37
|
+
attr_accessor :framer_template_id
|
|
38
|
+
|
|
39
|
+
# The static License Key (if not dynamically generated)
|
|
40
|
+
attr_accessor :license_key
|
|
41
|
+
|
|
42
|
+
# The maximum activation limit for licenses
|
|
43
|
+
attr_accessor :activation_limit
|
|
44
|
+
|
|
45
|
+
# A message shown to the user upon license activation
|
|
46
|
+
attr_accessor :activation_message
|
|
47
|
+
|
|
48
|
+
# The number of hours until the entitlement expires
|
|
49
|
+
attr_accessor :expiry_hours
|
|
50
|
+
|
|
51
|
+
# The digital download URL or redirect link
|
|
52
|
+
attr_accessor :digital_link
|
|
53
|
+
|
|
54
|
+
# Custom setup instructions for the user
|
|
55
|
+
attr_accessor :instructions
|
|
56
|
+
|
|
57
|
+
class EnumAttributeValidator
|
|
58
|
+
attr_reader :datatype
|
|
59
|
+
attr_reader :allowable_values
|
|
60
|
+
|
|
61
|
+
def initialize(datatype, allowable_values)
|
|
62
|
+
@allowable_values = allowable_values.map do |value|
|
|
63
|
+
case datatype.to_s
|
|
64
|
+
when /Integer/i
|
|
65
|
+
value.to_i
|
|
66
|
+
when /Float/i
|
|
67
|
+
value.to_f
|
|
68
|
+
else
|
|
69
|
+
value
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def valid?(value)
|
|
75
|
+
!value || allowable_values.include?(value)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
80
|
+
def self.attribute_map
|
|
81
|
+
{
|
|
82
|
+
:'name' => :'name',
|
|
83
|
+
:'type' => :'type',
|
|
84
|
+
:'github_repo' => :'githubRepo',
|
|
85
|
+
:'github_permission' => :'githubPermission',
|
|
86
|
+
:'discord_guild_id' => :'discordGuildId',
|
|
87
|
+
:'discord_role_id' => :'discordRoleId',
|
|
88
|
+
:'framer_template_id' => :'framerTemplateId',
|
|
89
|
+
:'license_key' => :'licenseKey',
|
|
90
|
+
:'activation_limit' => :'activationLimit',
|
|
91
|
+
:'activation_message' => :'activationMessage',
|
|
92
|
+
:'expiry_hours' => :'expiryHours',
|
|
93
|
+
:'digital_link' => :'digitalLink',
|
|
94
|
+
:'instructions' => :'instructions'
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Returns all the JSON keys this model knows about
|
|
99
|
+
def self.acceptable_attributes
|
|
100
|
+
attribute_map.values
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Attribute type mapping.
|
|
104
|
+
def self.openapi_types
|
|
105
|
+
{
|
|
106
|
+
:'name' => :'String',
|
|
107
|
+
:'type' => :'String',
|
|
108
|
+
:'github_repo' => :'String',
|
|
109
|
+
:'github_permission' => :'String',
|
|
110
|
+
:'discord_guild_id' => :'String',
|
|
111
|
+
:'discord_role_id' => :'String',
|
|
112
|
+
:'framer_template_id' => :'String',
|
|
113
|
+
:'license_key' => :'String',
|
|
114
|
+
:'activation_limit' => :'Float',
|
|
115
|
+
:'activation_message' => :'String',
|
|
116
|
+
:'expiry_hours' => :'Float',
|
|
117
|
+
:'digital_link' => :'String',
|
|
118
|
+
:'instructions' => :'String'
|
|
119
|
+
}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# List of attributes with nullable: true
|
|
123
|
+
def self.openapi_nullable
|
|
124
|
+
Set.new([
|
|
125
|
+
])
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Initializes the object
|
|
129
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
130
|
+
def initialize(attributes = {})
|
|
131
|
+
if (!attributes.is_a?(Hash))
|
|
132
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Solifyn::UpdateEntitlementDto` initialize method"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
136
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
137
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
138
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Solifyn::UpdateEntitlementDto`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
139
|
+
end
|
|
140
|
+
h[k.to_sym] = v
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if attributes.key?(:'name')
|
|
144
|
+
self.name = attributes[:'name']
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if attributes.key?(:'type')
|
|
148
|
+
self.type = attributes[:'type']
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
if attributes.key?(:'github_repo')
|
|
152
|
+
self.github_repo = attributes[:'github_repo']
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if attributes.key?(:'github_permission')
|
|
156
|
+
self.github_permission = attributes[:'github_permission']
|
|
157
|
+
else
|
|
158
|
+
self.github_permission = 'pull'
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
if attributes.key?(:'discord_guild_id')
|
|
162
|
+
self.discord_guild_id = attributes[:'discord_guild_id']
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if attributes.key?(:'discord_role_id')
|
|
166
|
+
self.discord_role_id = attributes[:'discord_role_id']
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if attributes.key?(:'framer_template_id')
|
|
170
|
+
self.framer_template_id = attributes[:'framer_template_id']
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if attributes.key?(:'license_key')
|
|
174
|
+
self.license_key = attributes[:'license_key']
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if attributes.key?(:'activation_limit')
|
|
178
|
+
self.activation_limit = attributes[:'activation_limit']
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
if attributes.key?(:'activation_message')
|
|
182
|
+
self.activation_message = attributes[:'activation_message']
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if attributes.key?(:'expiry_hours')
|
|
186
|
+
self.expiry_hours = attributes[:'expiry_hours']
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
if attributes.key?(:'digital_link')
|
|
190
|
+
self.digital_link = attributes[:'digital_link']
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
if attributes.key?(:'instructions')
|
|
194
|
+
self.instructions = attributes[:'instructions']
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
199
|
+
# @return Array for valid properties with the reasons
|
|
200
|
+
def list_invalid_properties
|
|
201
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
202
|
+
invalid_properties = Array.new
|
|
203
|
+
invalid_properties
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Check to see if the all the properties in the model are valid
|
|
207
|
+
# @return true if the model is valid
|
|
208
|
+
def valid?
|
|
209
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
210
|
+
type_validator = EnumAttributeValidator.new('String', ["GITHUB", "DISCORD", "FRAMER", "LICENSE", "DIGITAL"])
|
|
211
|
+
return false unless type_validator.valid?(@type)
|
|
212
|
+
true
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
216
|
+
# @param [Object] type Object to be assigned
|
|
217
|
+
def type=(type)
|
|
218
|
+
validator = EnumAttributeValidator.new('String', ["GITHUB", "DISCORD", "FRAMER", "LICENSE", "DIGITAL"])
|
|
219
|
+
unless validator.valid?(type)
|
|
220
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
221
|
+
end
|
|
222
|
+
@type = type
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Checks equality by comparing each attribute.
|
|
226
|
+
# @param [Object] Object to be compared
|
|
227
|
+
def ==(o)
|
|
228
|
+
return true if self.equal?(o)
|
|
229
|
+
self.class == o.class &&
|
|
230
|
+
name == o.name &&
|
|
231
|
+
type == o.type &&
|
|
232
|
+
github_repo == o.github_repo &&
|
|
233
|
+
github_permission == o.github_permission &&
|
|
234
|
+
discord_guild_id == o.discord_guild_id &&
|
|
235
|
+
discord_role_id == o.discord_role_id &&
|
|
236
|
+
framer_template_id == o.framer_template_id &&
|
|
237
|
+
license_key == o.license_key &&
|
|
238
|
+
activation_limit == o.activation_limit &&
|
|
239
|
+
activation_message == o.activation_message &&
|
|
240
|
+
expiry_hours == o.expiry_hours &&
|
|
241
|
+
digital_link == o.digital_link &&
|
|
242
|
+
instructions == o.instructions
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# @see the `==` method
|
|
246
|
+
# @param [Object] Object to be compared
|
|
247
|
+
def eql?(o)
|
|
248
|
+
self == o
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Calculates hash code according to all attributes.
|
|
252
|
+
# @return [Integer] Hash code
|
|
253
|
+
def hash
|
|
254
|
+
[name, type, github_repo, github_permission, discord_guild_id, discord_role_id, framer_template_id, license_key, activation_limit, activation_message, expiry_hours, digital_link, instructions].hash
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Builds the object from hash
|
|
258
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
259
|
+
# @return [Object] Returns the model itself
|
|
260
|
+
def self.build_from_hash(attributes)
|
|
261
|
+
return nil unless attributes.is_a?(Hash)
|
|
262
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
263
|
+
transformed_hash = {}
|
|
264
|
+
openapi_types.each_pair do |key, type|
|
|
265
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
266
|
+
transformed_hash["#{key}"] = nil
|
|
267
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
268
|
+
# check to ensure the input is an array given that the attribute
|
|
269
|
+
# is documented as an array but the input is not
|
|
270
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
271
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
272
|
+
end
|
|
273
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
274
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
new(transformed_hash)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Deserializes the data based on type
|
|
281
|
+
# @param string type Data type
|
|
282
|
+
# @param string value Value to be deserialized
|
|
283
|
+
# @return [Object] Deserialized data
|
|
284
|
+
def self._deserialize(type, value)
|
|
285
|
+
case type.to_sym
|
|
286
|
+
when :Time
|
|
287
|
+
Time.parse(value)
|
|
288
|
+
when :Date
|
|
289
|
+
Date.parse(value)
|
|
290
|
+
when :String
|
|
291
|
+
value.to_s
|
|
292
|
+
when :Integer
|
|
293
|
+
value.to_i
|
|
294
|
+
when :Float
|
|
295
|
+
value.to_f
|
|
296
|
+
when :Boolean
|
|
297
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
298
|
+
true
|
|
299
|
+
else
|
|
300
|
+
false
|
|
301
|
+
end
|
|
302
|
+
when :Object
|
|
303
|
+
# generic object (usually a Hash), return directly
|
|
304
|
+
value
|
|
305
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
306
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
307
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
308
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
309
|
+
k_type = Regexp.last_match[:k_type]
|
|
310
|
+
v_type = Regexp.last_match[:v_type]
|
|
311
|
+
{}.tap do |hash|
|
|
312
|
+
value.each do |k, v|
|
|
313
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
else # model
|
|
317
|
+
# models (e.g. Pet) or oneOf
|
|
318
|
+
klass = Solifyn.const_get(type)
|
|
319
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Returns the string representation of the object
|
|
324
|
+
# @return [String] String presentation of the object
|
|
325
|
+
def to_s
|
|
326
|
+
to_hash.to_s
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
330
|
+
# @return [Hash] Returns the object in the form of hash
|
|
331
|
+
def to_body
|
|
332
|
+
to_hash
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Returns the object in the form of hash
|
|
336
|
+
# @return [Hash] Returns the object in the form of hash
|
|
337
|
+
def to_hash
|
|
338
|
+
hash = {}
|
|
339
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
340
|
+
value = self.send(attr)
|
|
341
|
+
if value.nil?
|
|
342
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
343
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
hash[param] = _to_hash(value)
|
|
347
|
+
end
|
|
348
|
+
hash
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# Outputs non-array value in the form of hash
|
|
352
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
353
|
+
# @param [Object] value Any valid value
|
|
354
|
+
# @return [Hash] Returns the value in the form of hash
|
|
355
|
+
def _to_hash(value)
|
|
356
|
+
if value.is_a?(Array)
|
|
357
|
+
value.compact.map { |v| _to_hash(v) }
|
|
358
|
+
elsif value.is_a?(Hash)
|
|
359
|
+
{}.tap do |hash|
|
|
360
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
361
|
+
end
|
|
362
|
+
elsif value.respond_to? :to_hash
|
|
363
|
+
value.to_hash
|
|
364
|
+
else
|
|
365
|
+
value
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
end
|