smooch-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +181 -0
  4. data/Rakefile +8 -0
  5. data/docs/Action.md +16 -0
  6. data/docs/App.md +10 -0
  7. data/docs/AppApi.md +609 -0
  8. data/docs/AppCreate.md +8 -0
  9. data/docs/AppResponse.md +8 -0
  10. data/docs/AppUser.md +18 -0
  11. data/docs/AppUserApi.md +561 -0
  12. data/docs/AppUserLink.md +9 -0
  13. data/docs/AppUserPreCreate.md +14 -0
  14. data/docs/AppUserResponse.md +8 -0
  15. data/docs/AppUserUpdate.md +12 -0
  16. data/docs/Client.md +14 -0
  17. data/docs/ClientInfo.md +15 -0
  18. data/docs/Conversation.md +9 -0
  19. data/docs/ConversationApi.md +282 -0
  20. data/docs/Destination.md +9 -0
  21. data/docs/DeviceInit.md +12 -0
  22. data/docs/DeviceResponse.md +8 -0
  23. data/docs/DeviceUpdate.md +10 -0
  24. data/docs/DisplaySettings.md +8 -0
  25. data/docs/Event.md +8 -0
  26. data/docs/GetMessagesResponse.md +10 -0
  27. data/docs/Init.md +9 -0
  28. data/docs/InitApi.md +61 -0
  29. data/docs/InitResponse.md +9 -0
  30. data/docs/Integration.md +24 -0
  31. data/docs/IntegrationApi.md +121 -0
  32. data/docs/IntegrationCreate.md +23 -0
  33. data/docs/IntegrationResponse.md +8 -0
  34. data/docs/JwtResponse.md +8 -0
  35. data/docs/ListAppsResponse.md +10 -0
  36. data/docs/ListIntegrationsResponse.md +8 -0
  37. data/docs/ListSecretKeysResponse.md +8 -0
  38. data/docs/ListWebhooksResponse.md +8 -0
  39. data/docs/Menu.md +9 -0
  40. data/docs/MenuApi.md +155 -0
  41. data/docs/MenuItem.md +11 -0
  42. data/docs/MenuResponse.md +8 -0
  43. data/docs/Message.md +23 -0
  44. data/docs/MessageItem.md +13 -0
  45. data/docs/MessagePost.md +20 -0
  46. data/docs/MessageResponse.md +9 -0
  47. data/docs/PostMessagesResponse.md +9 -0
  48. data/docs/SecretKey.md +10 -0
  49. data/docs/SecretKeyCreate.md +8 -0
  50. data/docs/SecretKeyResponse.md +8 -0
  51. data/docs/TrackEventResponse.md +8 -0
  52. data/docs/TypingActivityTrigger.md +11 -0
  53. data/docs/Webhook.md +11 -0
  54. data/docs/WebhookApi.md +287 -0
  55. data/docs/WebhookCreate.md +9 -0
  56. data/docs/WebhookResponse.md +8 -0
  57. data/docs/WebhookUpdate.md +9 -0
  58. data/git_push.sh +55 -0
  59. data/lib/smooch-api.rb +91 -0
  60. data/lib/smooch-api/api/app_api.rb +628 -0
  61. data/lib/smooch-api/api/app_user_api.rb +585 -0
  62. data/lib/smooch-api/api/conversation_api.rb +298 -0
  63. data/lib/smooch-api/api/init_api.rb +75 -0
  64. data/lib/smooch-api/api/integration_api.rb +135 -0
  65. data/lib/smooch-api/api/menu_api.rb +173 -0
  66. data/lib/smooch-api/api/webhook_api.rb +306 -0
  67. data/lib/smooch-api/api_client.rb +376 -0
  68. data/lib/smooch-api/api_error.rb +37 -0
  69. data/lib/smooch-api/configuration.rb +202 -0
  70. data/lib/smooch-api/models/action.rb +311 -0
  71. data/lib/smooch-api/models/app.rb +223 -0
  72. data/lib/smooch-api/models/app_create.rb +193 -0
  73. data/lib/smooch-api/models/app_response.rb +188 -0
  74. data/lib/smooch-api/models/app_user.rb +307 -0
  75. data/lib/smooch-api/models/app_user_link.rb +236 -0
  76. data/lib/smooch-api/models/app_user_pre_create.rb +253 -0
  77. data/lib/smooch-api/models/app_user_response.rb +193 -0
  78. data/lib/smooch-api/models/app_user_update.rb +228 -0
  79. data/lib/smooch-api/models/client.rb +290 -0
  80. data/lib/smooch-api/models/client_info.rb +258 -0
  81. data/lib/smooch-api/models/conversation.rb +208 -0
  82. data/lib/smooch-api/models/destination.rb +208 -0
  83. data/lib/smooch-api/models/device_init.rb +270 -0
  84. data/lib/smooch-api/models/device_response.rb +188 -0
  85. data/lib/smooch-api/models/device_update.rb +207 -0
  86. data/lib/smooch-api/models/display_settings.rb +188 -0
  87. data/lib/smooch-api/models/event.rb +193 -0
  88. data/lib/smooch-api/models/get_messages_response.rb +210 -0
  89. data/lib/smooch-api/models/init.rb +202 -0
  90. data/lib/smooch-api/models/init_response.rb +208 -0
  91. data/lib/smooch-api/models/integration.rb +358 -0
  92. data/lib/smooch-api/models/integration_create.rb +343 -0
  93. data/lib/smooch-api/models/integration_response.rb +188 -0
  94. data/lib/smooch-api/models/jwt_response.rb +188 -0
  95. data/lib/smooch-api/models/list_apps_response.rb +210 -0
  96. data/lib/smooch-api/models/list_integrations_response.rb +190 -0
  97. data/lib/smooch-api/models/list_secret_keys_response.rb +190 -0
  98. data/lib/smooch-api/models/list_webhooks_response.rb +195 -0
  99. data/lib/smooch-api/models/menu.rb +205 -0
  100. data/lib/smooch-api/models/menu_item.rb +228 -0
  101. data/lib/smooch-api/models/menu_response.rb +193 -0
  102. data/lib/smooch-api/models/message.rb +415 -0
  103. data/lib/smooch-api/models/message_item.rb +250 -0
  104. data/lib/smooch-api/models/message_post.rb +355 -0
  105. data/lib/smooch-api/models/message_response.rb +208 -0
  106. data/lib/smooch-api/models/post_messages_response.rb +200 -0
  107. data/lib/smooch-api/models/secret_key.rb +223 -0
  108. data/lib/smooch-api/models/secret_key_create.rb +193 -0
  109. data/lib/smooch-api/models/secret_key_response.rb +188 -0
  110. data/lib/smooch-api/models/track_event_response.rb +188 -0
  111. data/lib/smooch-api/models/typing_activity_trigger.rb +228 -0
  112. data/lib/smooch-api/models/webhook.rb +261 -0
  113. data/lib/smooch-api/models/webhook_create.rb +226 -0
  114. data/lib/smooch-api/models/webhook_response.rb +193 -0
  115. data/lib/smooch-api/models/webhook_update.rb +221 -0
  116. data/lib/smooch-api/version.rb +14 -0
  117. data/smooch-api.gemspec +44 -0
  118. data/spec/api_client_spec.rb +225 -0
  119. data/spec/configuration_spec.rb +41 -0
  120. data/spec/spec_helper.rb +110 -0
  121. metadata +349 -0
@@ -0,0 +1,228 @@
1
+ =begin
2
+ #Smooch
3
+
4
+ #The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our [official documentation](https://docs.smooch.io).
5
+
6
+ OpenAPI spec version: 1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SmoochApi
15
+
16
+ class MenuItem
17
+ # The button text of the menu item.
18
+ attr_accessor :text
19
+
20
+ # A valid address, like http://smooch.io. Required for a *link* type item.
21
+ attr_accessor :uri
22
+
23
+ # Can either be [link](https://docs.smooch.io/javascript/#links) or [postback](https://docs.smooch.io/javascript/#postbacks), which correspond to Smooch’s [link and postback actions]((https://docs.smooch.io/javascript/#action-buttons).
24
+ attr_accessor :type
25
+
26
+ # A payload for a postback. Required for a *postback* type item.
27
+ attr_accessor :postback
28
+
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'text' => :'text',
34
+ :'uri' => :'uri',
35
+ :'type' => :'type',
36
+ :'postback' => :'postback'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'text' => :'String',
44
+ :'uri' => :'String',
45
+ :'type' => :'String',
46
+ :'postback' => :'String'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
57
+
58
+ if attributes.has_key?(:'text')
59
+ self.text = attributes[:'text']
60
+ end
61
+
62
+ if attributes.has_key?(:'uri')
63
+ self.uri = attributes[:'uri']
64
+ end
65
+
66
+ if attributes.has_key?(:'type')
67
+ self.type = attributes[:'type']
68
+ end
69
+
70
+ if attributes.has_key?(:'postback')
71
+ self.postback = attributes[:'postback']
72
+ end
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properies with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ if @text.nil?
81
+ invalid_properties.push("invalid value for 'text', text cannot be nil.")
82
+ end
83
+
84
+ if @type.nil?
85
+ invalid_properties.push("invalid value for 'type', type cannot be nil.")
86
+ end
87
+
88
+ return invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ return false if @text.nil?
95
+ return false if @type.nil?
96
+ return true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ text == o.text &&
105
+ uri == o.uri &&
106
+ type == o.type &&
107
+ postback == o.postback
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Fixnum] Hash code
118
+ def hash
119
+ [text, uri, type, postback].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.swagger_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :BOOLEAN
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ temp_model = SmoochApi.const_get(type).new
180
+ temp_model.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ next if value.nil?
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map{ |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ end
@@ -0,0 +1,193 @@
1
+ =begin
2
+ #Smooch
3
+
4
+ #The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our [official documentation](https://docs.smooch.io).
5
+
6
+ OpenAPI spec version: 1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SmoochApi
15
+
16
+ class MenuResponse
17
+ # The menu.
18
+ attr_accessor :menu
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'menu' => :'menu'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'menu' => :'Menu'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'menu')
44
+ self.menu = attributes[:'menu']
45
+ end
46
+
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properies with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = Array.new
53
+ if @menu.nil?
54
+ invalid_properties.push("invalid value for 'menu', menu cannot be nil.")
55
+ end
56
+
57
+ return 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
+ return false if @menu.nil?
64
+ return true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ menu == o.menu
73
+ end
74
+
75
+ # @see the `==` method
76
+ # @param [Object] Object to be compared
77
+ def eql?(o)
78
+ self == o
79
+ end
80
+
81
+ # Calculates hash code according to all attributes.
82
+ # @return [Fixnum] Hash code
83
+ def hash
84
+ [menu].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.swagger_types.each_pair do |key, type|
93
+ if type =~ /\AArray<(.*)>/i
94
+ # check to ensure the input is an array given that the the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
97
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+
104
+ self
105
+ end
106
+
107
+ # Deserializes the data based on type
108
+ # @param string type Data type
109
+ # @param string value Value to be deserialized
110
+ # @return [Object] Deserialized data
111
+ def _deserialize(type, value)
112
+ case type.to_sym
113
+ when :DateTime
114
+ DateTime.parse(value)
115
+ when :Date
116
+ Date.parse(value)
117
+ when :String
118
+ value.to_s
119
+ when :Integer
120
+ value.to_i
121
+ when :Float
122
+ value.to_f
123
+ when :BOOLEAN
124
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
+ true
126
+ else
127
+ false
128
+ end
129
+ when :Object
130
+ # generic object (usually a Hash), return directly
131
+ value
132
+ when /\AArray<(?<inner_type>.+)>\z/
133
+ inner_type = Regexp.last_match[:inner_type]
134
+ value.map { |v| _deserialize(inner_type, v) }
135
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
136
+ k_type = Regexp.last_match[:k_type]
137
+ v_type = Regexp.last_match[:v_type]
138
+ {}.tap do |hash|
139
+ value.each do |k, v|
140
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
141
+ end
142
+ end
143
+ else # model
144
+ temp_model = SmoochApi.const_get(type).new
145
+ temp_model.build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ next if value.nil?
168
+ hash[param] = _to_hash(value)
169
+ end
170
+ hash
171
+ end
172
+
173
+ # Outputs non-array value in the form of hash
174
+ # For object, use to_hash. Otherwise, just return the value
175
+ # @param [Object] value Any valid value
176
+ # @return [Hash] Returns the value in the form of hash
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map{ |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end
@@ -0,0 +1,415 @@
1
+ =begin
2
+ #Smooch
3
+
4
+ #The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our [official documentation](https://docs.smooch.io).
5
+
6
+ OpenAPI spec version: 1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SmoochApi
15
+
16
+ class Message
17
+ # The message ID, generated automatically.
18
+ attr_accessor :_id
19
+
20
+ # The ID of the message's author.
21
+ attr_accessor :author_id
22
+
23
+ # The role of the individual posting the message. Can be either *appUser* or *appMaker*.
24
+ attr_accessor :role
25
+
26
+ # The message type.
27
+ attr_accessor :type
28
+
29
+ # The display name of the message author.
30
+ attr_accessor :name
31
+
32
+ # The message text. Required for text messages.
33
+ attr_accessor :text
34
+
35
+ # The email address of the message author.
36
+ attr_accessor :email
37
+
38
+ # The URL of the desired message avatar image.
39
+ attr_accessor :avatar_url
40
+
41
+ # The unix timestamp of the moment the message was received.
42
+ attr_accessor :received
43
+
44
+ # The mediaUrl for the image. Required for image messages.
45
+ attr_accessor :media_url
46
+
47
+ # The mediaType for the image. Required for image messages.
48
+ attr_accessor :media_type
49
+
50
+ # Flat JSON object containing any custom properties associated with the message.
51
+ attr_accessor :metadata
52
+
53
+ # The items in the message list. Required for carousel and list messages.
54
+ attr_accessor :items
55
+
56
+ # The actions in the message.
57
+ attr_accessor :actions
58
+
59
+ # The payload of a reply action, if applicable.
60
+ attr_accessor :payload
61
+
62
+ # Settings to adjust the carousel layout. See [Display Settings](https://docs.smooch.io/rest/#display-settings).
63
+ attr_accessor :display_settings
64
+
65
+ class EnumAttributeValidator
66
+ attr_reader :datatype
67
+ attr_reader :allowable_values
68
+
69
+ def initialize(datatype, allowable_values)
70
+ @allowable_values = allowable_values.map do |value|
71
+ case datatype.to_s
72
+ when /Integer/i
73
+ value.to_i
74
+ when /Float/i
75
+ value.to_f
76
+ else
77
+ value
78
+ end
79
+ end
80
+ end
81
+
82
+ def valid?(value)
83
+ !value || allowable_values.include?(value)
84
+ end
85
+ end
86
+
87
+ # Attribute mapping from ruby-style variable name to JSON key.
88
+ def self.attribute_map
89
+ {
90
+ :'_id' => :'_id',
91
+ :'author_id' => :'authorId',
92
+ :'role' => :'role',
93
+ :'type' => :'type',
94
+ :'name' => :'name',
95
+ :'text' => :'text',
96
+ :'email' => :'email',
97
+ :'avatar_url' => :'avatarUrl',
98
+ :'received' => :'received',
99
+ :'media_url' => :'mediaUrl',
100
+ :'media_type' => :'mediaType',
101
+ :'metadata' => :'metadata',
102
+ :'items' => :'items',
103
+ :'actions' => :'actions',
104
+ :'payload' => :'payload',
105
+ :'display_settings' => :'displaySettings'
106
+ }
107
+ end
108
+
109
+ # Attribute type mapping.
110
+ def self.swagger_types
111
+ {
112
+ :'_id' => :'String',
113
+ :'author_id' => :'String',
114
+ :'role' => :'String',
115
+ :'type' => :'String',
116
+ :'name' => :'String',
117
+ :'text' => :'String',
118
+ :'email' => :'String',
119
+ :'avatar_url' => :'String',
120
+ :'received' => :'Float',
121
+ :'media_url' => :'String',
122
+ :'media_type' => :'String',
123
+ :'metadata' => :'Object',
124
+ :'items' => :'Array<MessageItem>',
125
+ :'actions' => :'Array<Action>',
126
+ :'payload' => :'String',
127
+ :'display_settings' => :'DisplaySettings'
128
+ }
129
+ end
130
+
131
+ # Initializes the object
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ def initialize(attributes = {})
134
+ return unless attributes.is_a?(Hash)
135
+
136
+ # convert string to symbol for hash key
137
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
138
+
139
+ if attributes.has_key?(:'_id')
140
+ self._id = attributes[:'_id']
141
+ end
142
+
143
+ if attributes.has_key?(:'authorId')
144
+ self.author_id = attributes[:'authorId']
145
+ end
146
+
147
+ if attributes.has_key?(:'role')
148
+ self.role = attributes[:'role']
149
+ end
150
+
151
+ if attributes.has_key?(:'type')
152
+ self.type = attributes[:'type']
153
+ end
154
+
155
+ if attributes.has_key?(:'name')
156
+ self.name = attributes[:'name']
157
+ end
158
+
159
+ if attributes.has_key?(:'text')
160
+ self.text = attributes[:'text']
161
+ end
162
+
163
+ if attributes.has_key?(:'email')
164
+ self.email = attributes[:'email']
165
+ end
166
+
167
+ if attributes.has_key?(:'avatarUrl')
168
+ self.avatar_url = attributes[:'avatarUrl']
169
+ end
170
+
171
+ if attributes.has_key?(:'received')
172
+ self.received = attributes[:'received']
173
+ end
174
+
175
+ if attributes.has_key?(:'mediaUrl')
176
+ self.media_url = attributes[:'mediaUrl']
177
+ end
178
+
179
+ if attributes.has_key?(:'mediaType')
180
+ self.media_type = attributes[:'mediaType']
181
+ end
182
+
183
+ if attributes.has_key?(:'metadata')
184
+ self.metadata = attributes[:'metadata']
185
+ end
186
+
187
+ if attributes.has_key?(:'items')
188
+ if (value = attributes[:'items']).is_a?(Array)
189
+ self.items = value
190
+ end
191
+ end
192
+
193
+ if attributes.has_key?(:'actions')
194
+ if (value = attributes[:'actions']).is_a?(Array)
195
+ self.actions = value
196
+ end
197
+ end
198
+
199
+ if attributes.has_key?(:'payload')
200
+ self.payload = attributes[:'payload']
201
+ end
202
+
203
+ if attributes.has_key?(:'displaySettings')
204
+ self.display_settings = attributes[:'displaySettings']
205
+ end
206
+
207
+ end
208
+
209
+ # Show invalid properties with the reasons. Usually used together with valid?
210
+ # @return Array for valid properies with the reasons
211
+ def list_invalid_properties
212
+ invalid_properties = Array.new
213
+ if @_id.nil?
214
+ invalid_properties.push("invalid value for '_id', _id cannot be nil.")
215
+ end
216
+
217
+ if @author_id.nil?
218
+ invalid_properties.push("invalid value for 'author_id', author_id cannot be nil.")
219
+ end
220
+
221
+ if @role.nil?
222
+ invalid_properties.push("invalid value for 'role', role cannot be nil.")
223
+ end
224
+
225
+ if @type.nil?
226
+ invalid_properties.push("invalid value for 'type', type cannot be nil.")
227
+ end
228
+
229
+ if @name.nil?
230
+ invalid_properties.push("invalid value for 'name', name cannot be nil.")
231
+ end
232
+
233
+ if @text.nil?
234
+ invalid_properties.push("invalid value for 'text', text cannot be nil.")
235
+ end
236
+
237
+ if @avatar_url.nil?
238
+ invalid_properties.push("invalid value for 'avatar_url', avatar_url cannot be nil.")
239
+ end
240
+
241
+ if @received.nil?
242
+ invalid_properties.push("invalid value for 'received', received cannot be nil.")
243
+ end
244
+
245
+ return invalid_properties
246
+ end
247
+
248
+ # Check to see if the all the properties in the model are valid
249
+ # @return true if the model is valid
250
+ def valid?
251
+ return false if @_id.nil?
252
+ return false if @author_id.nil?
253
+ return false if @role.nil?
254
+ return false if @type.nil?
255
+ type_validator = EnumAttributeValidator.new('String', ["text", "image", "carousel", "list"])
256
+ return false unless type_validator.valid?(@type)
257
+ return false if @name.nil?
258
+ return false if @text.nil?
259
+ return false if @avatar_url.nil?
260
+ return false if @received.nil?
261
+ return true
262
+ end
263
+
264
+ # Custom attribute writer method checking allowed values (enum).
265
+ # @param [Object] type Object to be assigned
266
+ def type=(type)
267
+ validator = EnumAttributeValidator.new('String', ["text", "image", "carousel", "list"])
268
+ unless validator.valid?(type)
269
+ fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
270
+ end
271
+ @type = type
272
+ end
273
+
274
+ # Checks equality by comparing each attribute.
275
+ # @param [Object] Object to be compared
276
+ def ==(o)
277
+ return true if self.equal?(o)
278
+ self.class == o.class &&
279
+ _id == o._id &&
280
+ author_id == o.author_id &&
281
+ role == o.role &&
282
+ type == o.type &&
283
+ name == o.name &&
284
+ text == o.text &&
285
+ email == o.email &&
286
+ avatar_url == o.avatar_url &&
287
+ received == o.received &&
288
+ media_url == o.media_url &&
289
+ media_type == o.media_type &&
290
+ metadata == o.metadata &&
291
+ items == o.items &&
292
+ actions == o.actions &&
293
+ payload == o.payload &&
294
+ display_settings == o.display_settings
295
+ end
296
+
297
+ # @see the `==` method
298
+ # @param [Object] Object to be compared
299
+ def eql?(o)
300
+ self == o
301
+ end
302
+
303
+ # Calculates hash code according to all attributes.
304
+ # @return [Fixnum] Hash code
305
+ def hash
306
+ [_id, author_id, role, type, name, text, email, avatar_url, received, media_url, media_type, metadata, items, actions, payload, display_settings].hash
307
+ end
308
+
309
+ # Builds the object from hash
310
+ # @param [Hash] attributes Model attributes in the form of hash
311
+ # @return [Object] Returns the model itself
312
+ def build_from_hash(attributes)
313
+ return nil unless attributes.is_a?(Hash)
314
+ self.class.swagger_types.each_pair do |key, type|
315
+ if type =~ /\AArray<(.*)>/i
316
+ # check to ensure the input is an array given that the the attribute
317
+ # is documented as an array but the input is not
318
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
319
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
320
+ end
321
+ elsif !attributes[self.class.attribute_map[key]].nil?
322
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
323
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
324
+ end
325
+
326
+ self
327
+ end
328
+
329
+ # Deserializes the data based on type
330
+ # @param string type Data type
331
+ # @param string value Value to be deserialized
332
+ # @return [Object] Deserialized data
333
+ def _deserialize(type, value)
334
+ case type.to_sym
335
+ when :DateTime
336
+ DateTime.parse(value)
337
+ when :Date
338
+ Date.parse(value)
339
+ when :String
340
+ value.to_s
341
+ when :Integer
342
+ value.to_i
343
+ when :Float
344
+ value.to_f
345
+ when :BOOLEAN
346
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
347
+ true
348
+ else
349
+ false
350
+ end
351
+ when :Object
352
+ # generic object (usually a Hash), return directly
353
+ value
354
+ when /\AArray<(?<inner_type>.+)>\z/
355
+ inner_type = Regexp.last_match[:inner_type]
356
+ value.map { |v| _deserialize(inner_type, v) }
357
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
358
+ k_type = Regexp.last_match[:k_type]
359
+ v_type = Regexp.last_match[:v_type]
360
+ {}.tap do |hash|
361
+ value.each do |k, v|
362
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
363
+ end
364
+ end
365
+ else # model
366
+ temp_model = SmoochApi.const_get(type).new
367
+ temp_model.build_from_hash(value)
368
+ end
369
+ end
370
+
371
+ # Returns the string representation of the object
372
+ # @return [String] String presentation of the object
373
+ def to_s
374
+ to_hash.to_s
375
+ end
376
+
377
+ # to_body is an alias to to_hash (backward compatibility)
378
+ # @return [Hash] Returns the object in the form of hash
379
+ def to_body
380
+ to_hash
381
+ end
382
+
383
+ # Returns the object in the form of hash
384
+ # @return [Hash] Returns the object in the form of hash
385
+ def to_hash
386
+ hash = {}
387
+ self.class.attribute_map.each_pair do |attr, param|
388
+ value = self.send(attr)
389
+ next if value.nil?
390
+ hash[param] = _to_hash(value)
391
+ end
392
+ hash
393
+ end
394
+
395
+ # Outputs non-array value in the form of hash
396
+ # For object, use to_hash. Otherwise, just return the value
397
+ # @param [Object] value Any valid value
398
+ # @return [Hash] Returns the value in the form of hash
399
+ def _to_hash(value)
400
+ if value.is_a?(Array)
401
+ value.compact.map{ |v| _to_hash(v) }
402
+ elsif value.is_a?(Hash)
403
+ {}.tap do |hash|
404
+ value.each { |k, v| hash[k] = _to_hash(v) }
405
+ end
406
+ elsif value.respond_to? :to_hash
407
+ value.to_hash
408
+ else
409
+ value
410
+ end
411
+ end
412
+
413
+ end
414
+
415
+ end