notifo-io 1.0.1.1 → 1.0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +205 -4
- data/docs/AppDetailsDto.md +0 -8
- data/docs/AppIdMediaBody.md +7 -0
- data/docs/AppsApi.md +188 -2
- data/docs/AuthorizationApi.md +121 -0
- data/docs/ConfigsApi.md +1 -1
- data/docs/ConfiguredIntegrationDto.md +12 -0
- data/docs/ConfiguredIntegrationsDto.md +8 -0
- data/docs/CreateIntegrationDto.md +11 -0
- data/docs/EventDto.md +1 -0
- data/docs/EventsApi.md +45 -1
- data/docs/IntegrationCreatedDto.md +8 -0
- data/docs/IntegrationDefinitionDto.md +11 -0
- data/docs/IntegrationProperties.md +6 -0
- data/docs/IntegrationPropertyDto.md +17 -0
- data/docs/IntegrationPropertyType.md +6 -0
- data/docs/IntegrationStatus.md +6 -0
- data/docs/ListResponseDtoOfMobilePushTokenDto.md +8 -0
- data/docs/ListResponseDtoOfNotificationDto.md +8 -0
- data/docs/LogsApi.md +1 -1
- data/docs/MediaApi.md +1 -1
- data/docs/MobileDeviceType.md +6 -0
- data/docs/MobilePushApi.md +135 -0
- data/docs/MobilePushTokenDto.md +8 -0
- data/docs/NotificationDto.md +21 -0
- data/docs/NotificationsApi.md +141 -0
- data/docs/PublishDto.md +2 -0
- data/docs/RegisterMobileTokenDto.md +8 -0
- data/docs/TemplatesApi.md +1 -1
- data/docs/TopicsApi.md +1 -1
- data/docs/TrackNotificationDto.md +10 -0
- data/docs/UpdateIntegrationDto.md +10 -0
- data/docs/UpsertUserDto.md +1 -0
- data/docs/UserApi.md +1 -1
- data/docs/UserDto.md +3 -0
- data/docs/UserInfoApi.md +83 -0
- data/docs/UsersApi.md +1 -1
- data/lib/notifo.rb +23 -3
- data/lib/notifo/api/apps_api.rb +246 -2
- data/lib/notifo/api/authorization_api.rb +158 -0
- data/lib/notifo/api/configs_api.rb +1 -1
- data/lib/notifo/api/events_api.rb +57 -1
- data/lib/notifo/api/logs_api.rb +1 -1
- data/lib/notifo/api/media_api.rb +1 -1
- data/lib/notifo/api/mobile_push_api.rb +178 -0
- data/lib/notifo/api/notifications_api.rb +181 -0
- data/lib/notifo/api/templates_api.rb +1 -1
- data/lib/notifo/api/topics_api.rb +1 -1
- data/lib/notifo/api/user_api.rb +1 -1
- data/lib/notifo/api/user_info_api.rb +112 -0
- data/lib/notifo/api/users_api.rb +1 -1
- data/lib/notifo/api_client.rb +1 -1
- data/lib/notifo/api_error.rb +1 -1
- data/lib/notifo/configuration.rb +3 -3
- data/lib/notifo/models/add_allowed_topic_dto.rb +1 -1
- data/lib/notifo/models/add_contributor_dto.rb +1 -1
- data/lib/notifo/models/app_contributor_dto.rb +1 -1
- data/lib/notifo/models/app_details_dto.rb +3 -96
- data/lib/notifo/models/app_dto.rb +1 -1
- data/lib/notifo/models/app_id_media_body.rb +207 -0
- data/lib/notifo/models/configured_integration_dto.rb +271 -0
- data/lib/notifo/models/configured_integrations_dto.rb +231 -0
- data/lib/notifo/models/confirm_mode.rb +1 -1
- data/lib/notifo/models/create_email_template_dto.rb +1 -1
- data/lib/notifo/models/create_integration_dto.rb +257 -0
- data/lib/notifo/models/email_template_dto.rb +2 -1
- data/lib/notifo/models/email_templates_dto.rb +1 -1
- data/lib/notifo/models/error_dto.rb +5 -1
- data/lib/notifo/models/event_dto.rb +18 -5
- data/lib/notifo/models/event_properties.rb +1 -1
- data/lib/notifo/models/integration_created_dto.rb +226 -0
- data/lib/notifo/models/integration_definition_dto.rb +272 -0
- data/lib/notifo/models/integration_properties.rb +201 -0
- data/lib/notifo/models/integration_property_dto.rb +319 -0
- data/lib/notifo/models/integration_property_type.rb +31 -0
- data/lib/notifo/models/integration_status.rb +29 -0
- data/lib/notifo/models/iso_day_of_week.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_event_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_log_entry_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_media_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_mobile_push_token_dto.rb +229 -0
- data/lib/notifo/models/list_response_dto_of_notification_dto.rb +229 -0
- data/lib/notifo/models/list_response_dto_of_subscription_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_template_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_topic_dto.rb +1 -1
- data/lib/notifo/models/list_response_dto_of_user_dto.rb +1 -1
- data/lib/notifo/models/localized_text.rb +1 -1
- data/lib/notifo/models/log_entry_dto.rb +1 -1
- data/lib/notifo/models/media_dto.rb +1 -1
- data/lib/notifo/models/media_metadata.rb +1 -1
- data/lib/notifo/models/media_type.rb +1 -1
- data/lib/notifo/models/mobile_device_type.rb +29 -0
- data/lib/notifo/models/mobile_push_token_dto.rb +221 -0
- data/lib/notifo/models/notification_dto.rb +386 -0
- data/lib/notifo/models/notification_formatting_dto.rb +1 -1
- data/lib/notifo/models/notification_send.rb +1 -1
- data/lib/notifo/models/notification_setting_dto.rb +2 -1
- data/lib/notifo/models/profile_dto.rb +4 -1
- data/lib/notifo/models/publish_dto.rb +30 -5
- data/lib/notifo/models/publish_many_dto.rb +1 -1
- data/lib/notifo/models/register_mobile_token_dto.rb +221 -0
- data/lib/notifo/models/resize_mode.rb +1 -1
- data/lib/notifo/models/scheduling_dto.rb +2 -1
- data/lib/notifo/models/scheduling_type.rb +1 -1
- data/lib/notifo/models/subscription_dto.rb +2 -1
- data/lib/notifo/models/template_dto.rb +1 -1
- data/lib/notifo/models/topic_dto.rb +1 -1
- data/lib/notifo/models/track_notification_dto.rb +243 -0
- data/lib/notifo/models/update_integration_dto.rb +242 -0
- data/lib/notifo/models/update_profile_dto.rb +7 -1
- data/lib/notifo/models/upsert_app_dto.rb +11 -1
- data/lib/notifo/models/upsert_template_dto.rb +2 -1
- data/lib/notifo/models/upsert_templates_dto.rb +1 -1
- data/lib/notifo/models/upsert_user_dto.rb +21 -2
- data/lib/notifo/models/upsert_users_dto.rb +1 -1
- data/lib/notifo/models/user_dto.rb +48 -2
- data/lib/notifo/version.rb +1 -1
- data/notifo-io-1.0.1.1.gem +0 -0
- data/notifo.gemspec +2 -2
- data/spec/api/authorization_api_spec.rb +61 -0
- data/spec/api/mobile_push_api_spec.rb +66 -0
- data/spec/api/notifications_api_spec.rb +68 -0
- data/spec/api/user_info_api_spec.rb +52 -0
- data/spec/models/app_id_media_body_spec.rb +40 -0
- data/spec/models/configured_integration_dto_spec.rb +70 -0
- data/spec/models/configured_integrations_dto_spec.rb +46 -0
- data/spec/models/create_integration_dto_spec.rb +64 -0
- data/spec/models/integration_created_dto_spec.rb +46 -0
- data/spec/models/integration_definition_dto_spec.rb +64 -0
- data/spec/models/integration_properties_spec.rb +34 -0
- data/spec/models/integration_property_dto_spec.rb +100 -0
- data/spec/models/integration_property_type_spec.rb +34 -0
- data/spec/models/integration_status_spec.rb +34 -0
- data/spec/models/list_response_dto_of_mobile_push_token_dto_spec.rb +46 -0
- data/spec/models/list_response_dto_of_notification_dto_spec.rb +46 -0
- data/spec/models/mobile_device_type_spec.rb +34 -0
- data/spec/models/mobile_push_token_dto_spec.rb +46 -0
- data/spec/models/notification_dto_spec.rb +124 -0
- data/spec/models/register_mobile_token_dto_spec.rb +46 -0
- data/spec/models/track_notification_dto_spec.rb +58 -0
- data/spec/models/update_integration_dto_spec.rb +58 -0
- metadata +91 -2
@@ -0,0 +1,272 @@
|
|
1
|
+
=begin
|
2
|
+
#Notifo API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.26
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module Notifo
|
15
|
+
class IntegrationDefinitionDto
|
16
|
+
# The title of the integration.
|
17
|
+
attr_accessor :title
|
18
|
+
|
19
|
+
# The logo URL for the integration.
|
20
|
+
attr_accessor :logo_url
|
21
|
+
|
22
|
+
# The optional description of the integration.
|
23
|
+
attr_accessor :description
|
24
|
+
|
25
|
+
# The properties to configure.
|
26
|
+
attr_accessor :properties
|
27
|
+
|
28
|
+
# The features of the integration.
|
29
|
+
attr_accessor :capabilities
|
30
|
+
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
32
|
+
def self.attribute_map
|
33
|
+
{
|
34
|
+
:'title' => :'title',
|
35
|
+
:'logo_url' => :'logoUrl',
|
36
|
+
:'description' => :'description',
|
37
|
+
:'properties' => :'properties',
|
38
|
+
:'capabilities' => :'capabilities'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute type mapping.
|
43
|
+
def self.openapi_types
|
44
|
+
{
|
45
|
+
:'title' => :'Object',
|
46
|
+
:'logo_url' => :'Object',
|
47
|
+
:'description' => :'Object',
|
48
|
+
:'properties' => :'Object',
|
49
|
+
:'capabilities' => :'Object'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# List of attributes with nullable: true
|
54
|
+
def self.openapi_nullable
|
55
|
+
Set.new([
|
56
|
+
:'description',
|
57
|
+
])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Initializes the object
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
62
|
+
def initialize(attributes = {})
|
63
|
+
if (!attributes.is_a?(Hash))
|
64
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Notifo::IntegrationDefinitionDto` initialize method"
|
65
|
+
end
|
66
|
+
|
67
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
68
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
69
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
70
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Notifo::IntegrationDefinitionDto`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
71
|
+
end
|
72
|
+
h[k.to_sym] = v
|
73
|
+
}
|
74
|
+
|
75
|
+
if attributes.key?(:'title')
|
76
|
+
self.title = attributes[:'title']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'logo_url')
|
80
|
+
self.logo_url = attributes[:'logo_url']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'description')
|
84
|
+
self.description = attributes[:'description']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.key?(:'properties')
|
88
|
+
if (value = attributes[:'properties']).is_a?(Array)
|
89
|
+
self.properties = value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'capabilities')
|
94
|
+
if (value = attributes[:'capabilities']).is_a?(Array)
|
95
|
+
self.capabilities = value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
101
|
+
# @return Array for valid properties with the reasons
|
102
|
+
def list_invalid_properties
|
103
|
+
invalid_properties = Array.new
|
104
|
+
if @title.nil?
|
105
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
106
|
+
end
|
107
|
+
|
108
|
+
if @logo_url.nil?
|
109
|
+
invalid_properties.push('invalid value for "logo_url", logo_url cannot be nil.')
|
110
|
+
end
|
111
|
+
|
112
|
+
if @properties.nil?
|
113
|
+
invalid_properties.push('invalid value for "properties", properties cannot be nil.')
|
114
|
+
end
|
115
|
+
|
116
|
+
if @capabilities.nil?
|
117
|
+
invalid_properties.push('invalid value for "capabilities", capabilities cannot be nil.')
|
118
|
+
end
|
119
|
+
|
120
|
+
invalid_properties
|
121
|
+
end
|
122
|
+
|
123
|
+
# Check to see if the all the properties in the model are valid
|
124
|
+
# @return true if the model is valid
|
125
|
+
def valid?
|
126
|
+
return false if @title.nil?
|
127
|
+
return false if @logo_url.nil?
|
128
|
+
return false if @properties.nil?
|
129
|
+
return false if @capabilities.nil?
|
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
|
+
title == o.title &&
|
139
|
+
logo_url == o.logo_url &&
|
140
|
+
description == o.description &&
|
141
|
+
properties == o.properties &&
|
142
|
+
capabilities == o.capabilities
|
143
|
+
end
|
144
|
+
|
145
|
+
# @see the `==` method
|
146
|
+
# @param [Object] Object to be compared
|
147
|
+
def eql?(o)
|
148
|
+
self == o
|
149
|
+
end
|
150
|
+
|
151
|
+
# Calculates hash code according to all attributes.
|
152
|
+
# @return [Integer] Hash code
|
153
|
+
def hash
|
154
|
+
[title, logo_url, description, properties, capabilities].hash
|
155
|
+
end
|
156
|
+
|
157
|
+
# Builds the object from hash
|
158
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
159
|
+
# @return [Object] Returns the model itself
|
160
|
+
def self.build_from_hash(attributes)
|
161
|
+
new.build_from_hash(attributes)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Builds the object from hash
|
165
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
166
|
+
# @return [Object] Returns the model itself
|
167
|
+
def build_from_hash(attributes)
|
168
|
+
return nil unless attributes.is_a?(Hash)
|
169
|
+
self.class.openapi_types.each_pair do |key, type|
|
170
|
+
if type =~ /\AArray<(.*)>/i
|
171
|
+
# check to ensure the input is an array given that the attribute
|
172
|
+
# is documented as an array but the input is not
|
173
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
174
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
175
|
+
end
|
176
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
177
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
178
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
179
|
+
self.send("#{key}=", nil)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
self
|
184
|
+
end
|
185
|
+
|
186
|
+
# Deserializes the data based on type
|
187
|
+
# @param string type Data type
|
188
|
+
# @param string value Value to be deserialized
|
189
|
+
# @return [Object] Deserialized data
|
190
|
+
def _deserialize(type, value)
|
191
|
+
case type.to_sym
|
192
|
+
when :DateTime
|
193
|
+
DateTime.parse(value)
|
194
|
+
when :Date
|
195
|
+
Date.parse(value)
|
196
|
+
when :String
|
197
|
+
value.to_s
|
198
|
+
when :Integer
|
199
|
+
value.to_i
|
200
|
+
when :Float
|
201
|
+
value.to_f
|
202
|
+
when :Boolean
|
203
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
204
|
+
true
|
205
|
+
else
|
206
|
+
false
|
207
|
+
end
|
208
|
+
when :Object
|
209
|
+
# generic object (usually a Hash), return directly
|
210
|
+
value
|
211
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
212
|
+
inner_type = Regexp.last_match[:inner_type]
|
213
|
+
value.map { |v| _deserialize(inner_type, v) }
|
214
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
215
|
+
k_type = Regexp.last_match[:k_type]
|
216
|
+
v_type = Regexp.last_match[:v_type]
|
217
|
+
{}.tap do |hash|
|
218
|
+
value.each do |k, v|
|
219
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
else # model
|
223
|
+
Notifo.const_get(type).build_from_hash(value)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the string representation of the object
|
228
|
+
# @return [String] String presentation of the object
|
229
|
+
def to_s
|
230
|
+
to_hash.to_s
|
231
|
+
end
|
232
|
+
|
233
|
+
# to_body is an alias to to_hash (backward compatibility)
|
234
|
+
# @return [Hash] Returns the object in the form of hash
|
235
|
+
def to_body
|
236
|
+
to_hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the object in the form of hash
|
240
|
+
# @return [Hash] Returns the object in the form of hash
|
241
|
+
def to_hash
|
242
|
+
hash = {}
|
243
|
+
self.class.attribute_map.each_pair do |attr, param|
|
244
|
+
value = self.send(attr)
|
245
|
+
if value.nil?
|
246
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
247
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
248
|
+
end
|
249
|
+
|
250
|
+
hash[param] = _to_hash(value)
|
251
|
+
end
|
252
|
+
hash
|
253
|
+
end
|
254
|
+
|
255
|
+
# Outputs non-array value in the form of hash
|
256
|
+
# For object, use to_hash. Otherwise, just return the value
|
257
|
+
# @param [Object] value Any valid value
|
258
|
+
# @return [Hash] Returns the value in the form of hash
|
259
|
+
def _to_hash(value)
|
260
|
+
if value.is_a?(Array)
|
261
|
+
value.compact.map { |v| _to_hash(v) }
|
262
|
+
elsif value.is_a?(Hash)
|
263
|
+
{}.tap do |hash|
|
264
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
265
|
+
end
|
266
|
+
elsif value.respond_to? :to_hash
|
267
|
+
value.to_hash
|
268
|
+
else
|
269
|
+
value
|
270
|
+
end
|
271
|
+
end end
|
272
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
=begin
|
2
|
+
#Notifo API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.26
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module Notifo
|
15
|
+
class IntegrationProperties
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.openapi_types
|
24
|
+
{
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# List of attributes with nullable: true
|
29
|
+
def self.openapi_nullable
|
30
|
+
Set.new([
|
31
|
+
])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
if (!attributes.is_a?(Hash))
|
38
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Notifo::IntegrationProperties` initialize method"
|
39
|
+
end
|
40
|
+
|
41
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
43
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
44
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Notifo::IntegrationProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
45
|
+
end
|
46
|
+
h[k.to_sym] = v
|
47
|
+
}
|
48
|
+
|
49
|
+
# call parent's initialize
|
50
|
+
super(attributes)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
54
|
+
# @return Array for valid properties with the reasons
|
55
|
+
def list_invalid_properties
|
56
|
+
invalid_properties = super
|
57
|
+
invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(o)
|
69
|
+
return true if self.equal?(o)
|
70
|
+
self.class == o.class && super(o)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @see the `==` method
|
74
|
+
# @param [Object] Object to be compared
|
75
|
+
def eql?(o)
|
76
|
+
self == o
|
77
|
+
end
|
78
|
+
|
79
|
+
# Calculates hash code according to all attributes.
|
80
|
+
# @return [Integer] Hash code
|
81
|
+
def hash
|
82
|
+
[].hash
|
83
|
+
end
|
84
|
+
|
85
|
+
# Builds the object from hash
|
86
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
87
|
+
# @return [Object] Returns the model itself
|
88
|
+
def self.build_from_hash(attributes)
|
89
|
+
new.build_from_hash(attributes)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Builds the object from hash
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
+
# @return [Object] Returns the model itself
|
95
|
+
def build_from_hash(attributes)
|
96
|
+
return nil unless attributes.is_a?(Hash)
|
97
|
+
super(attributes)
|
98
|
+
self.class.openapi_types.each_pair do |key, type|
|
99
|
+
if type =~ /\AArray<(.*)>/i
|
100
|
+
# check to ensure the input is an array given that the attribute
|
101
|
+
# is documented as an array but the input is not
|
102
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
103
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
104
|
+
end
|
105
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
106
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
107
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
108
|
+
self.send("#{key}=", nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
# Deserializes the data based on type
|
116
|
+
# @param string type Data type
|
117
|
+
# @param string value Value to be deserialized
|
118
|
+
# @return [Object] Deserialized data
|
119
|
+
def _deserialize(type, value)
|
120
|
+
case type.to_sym
|
121
|
+
when :DateTime
|
122
|
+
DateTime.parse(value)
|
123
|
+
when :Date
|
124
|
+
Date.parse(value)
|
125
|
+
when :String
|
126
|
+
value.to_s
|
127
|
+
when :Integer
|
128
|
+
value.to_i
|
129
|
+
when :Float
|
130
|
+
value.to_f
|
131
|
+
when :Boolean
|
132
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
133
|
+
true
|
134
|
+
else
|
135
|
+
false
|
136
|
+
end
|
137
|
+
when :Object
|
138
|
+
# generic object (usually a Hash), return directly
|
139
|
+
value
|
140
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
141
|
+
inner_type = Regexp.last_match[:inner_type]
|
142
|
+
value.map { |v| _deserialize(inner_type, v) }
|
143
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
144
|
+
k_type = Regexp.last_match[:k_type]
|
145
|
+
v_type = Regexp.last_match[:v_type]
|
146
|
+
{}.tap do |hash|
|
147
|
+
value.each do |k, v|
|
148
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
else # model
|
152
|
+
Notifo.const_get(type).build_from_hash(value)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the string representation of the object
|
157
|
+
# @return [String] String presentation of the object
|
158
|
+
def to_s
|
159
|
+
to_hash.to_s
|
160
|
+
end
|
161
|
+
|
162
|
+
# to_body is an alias to to_hash (backward compatibility)
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_body
|
165
|
+
to_hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns the object in the form of hash
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
170
|
+
def to_hash
|
171
|
+
hash = super
|
172
|
+
self.class.attribute_map.each_pair do |attr, param|
|
173
|
+
value = self.send(attr)
|
174
|
+
if value.nil?
|
175
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
176
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
177
|
+
end
|
178
|
+
|
179
|
+
hash[param] = _to_hash(value)
|
180
|
+
end
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Outputs non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
# @param [Object] value Any valid value
|
187
|
+
# @return [Hash] Returns the value in the form of hash
|
188
|
+
def _to_hash(value)
|
189
|
+
if value.is_a?(Array)
|
190
|
+
value.compact.map { |v| _to_hash(v) }
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
194
|
+
end
|
195
|
+
elsif value.respond_to? :to_hash
|
196
|
+
value.to_hash
|
197
|
+
else
|
198
|
+
value
|
199
|
+
end
|
200
|
+
end end
|
201
|
+
end
|