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