smooch-api 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/docs/Action.md +2 -2
- data/docs/App.md +2 -2
- data/docs/AppApi.md +48 -48
- data/docs/AppSettings.md +2 -2
- data/docs/AppUser.md +6 -6
- data/docs/AppUserApi.md +78 -78
- data/docs/AppUserBusinessSystemsResponse.md +1 -1
- data/docs/AppUserLink.md +2 -2
- data/docs/AppUserPreCreate.md +3 -3
- data/docs/AppUserResponse.md +1 -1
- data/docs/AppUserUpdate.md +2 -2
- data/docs/AttachmentRemove.md +1 -1
- data/docs/AttachmentResponse.md +2 -2
- data/docs/AttachmentsApi.md +16 -16
- data/docs/AuthCodeResponse.md +1 -1
- data/docs/BusinessSystemItem.md +4 -4
- data/docs/ChannelEntityItem.md +3 -3
- data/docs/Client.md +4 -4
- data/docs/ClientInfo.md +8 -8
- data/docs/Conversation.md +2 -2
- data/docs/ConversationApi.md +42 -42
- data/docs/Destination.md +2 -2
- data/docs/DisplaySettings.md +1 -1
- data/docs/GetMessagesResponse.md +1 -1
- data/docs/Integration.md +44 -44
- data/docs/IntegrationApi.md +66 -66
- data/docs/IntegrationCreate.md +36 -36
- data/docs/IntegrationProfileUpdate.md +1 -1
- data/docs/IntegrationUpdate.md +16 -16
- data/docs/LinkRequestResponse.md +1 -1
- data/docs/LinkRequestResponseLinkRequests.md +1 -1
- data/docs/ListAppsResponse.md +1 -1
- data/docs/ListServiceAccountsResponse.md +2 -2
- data/docs/ListTemplatesResponse.md +1 -1
- data/docs/MenuApi.md +14 -14
- data/docs/Message.md +6 -6
- data/docs/MessageItem.md +2 -2
- data/docs/MessageOverride.md +8 -0
- data/docs/MessageOverrideWhatsapp.md +8 -0
- data/docs/MessagePost.md +4 -3
- data/docs/MessageResponse.md +1 -1
- data/docs/SecretKey.md +1 -1
- data/docs/ServiceAccount.md +1 -1
- data/docs/ServiceAccountApi.md +46 -46
- data/docs/ServiceAccountResponse.md +1 -1
- data/docs/Template.md +1 -1
- data/docs/TemplateApi.md +30 -30
- data/docs/TypingActivityTrigger.md +1 -1
- data/docs/Webhook.md +1 -1
- data/docs/WebhookApi.md +30 -30
- data/lib/smooch-api.rb +3 -1
- data/lib/smooch-api/api/app_api.rb +112 -112
- data/lib/smooch-api/api/app_user_api.rb +190 -190
- data/lib/smooch-api/api/attachments_api.rb +34 -34
- data/lib/smooch-api/api/conversation_api.rb +102 -102
- data/lib/smooch-api/api/integration_api.rb +161 -161
- data/lib/smooch-api/api/menu_api.rb +34 -34
- data/lib/smooch-api/api/service_account_api.rb +109 -109
- data/lib/smooch-api/api/template_api.rb +73 -73
- data/lib/smooch-api/api/webhook_api.rb +73 -73
- data/lib/smooch-api/api_client.rb +1 -1
- data/lib/smooch-api/api_error.rb +1 -1
- data/lib/smooch-api/configuration.rb +1 -1
- data/lib/smooch-api/models/action.rb +12 -12
- data/lib/smooch-api/models/app.rb +18 -18
- data/lib/smooch-api/models/app_create.rb +1 -1
- data/lib/smooch-api/models/app_response.rb +1 -1
- data/lib/smooch-api/models/app_settings.rb +12 -12
- data/lib/smooch-api/models/app_update.rb +1 -1
- data/lib/smooch-api/models/app_user.rb +38 -38
- data/lib/smooch-api/models/app_user_business_systems_response.rb +10 -10
- data/lib/smooch-api/models/app_user_channels_response.rb +1 -1
- data/lib/smooch-api/models/app_user_link.rb +12 -12
- data/lib/smooch-api/models/app_user_pre_create.rb +20 -20
- data/lib/smooch-api/models/app_user_response.rb +10 -10
- data/lib/smooch-api/models/app_user_update.rb +12 -12
- data/lib/smooch-api/models/attachment_remove.rb +10 -10
- data/lib/smooch-api/models/attachment_response.rb +18 -18
- data/lib/smooch-api/models/auth_code_response.rb +10 -10
- data/lib/smooch-api/models/business_system_item.rb +22 -22
- data/lib/smooch-api/models/channel_entity_item.rb +17 -17
- data/lib/smooch-api/models/client.rb +22 -22
- data/lib/smooch-api/models/client_info.rb +42 -42
- data/lib/smooch-api/models/confirmation.rb +1 -1
- data/lib/smooch-api/models/conversation.rb +18 -18
- data/lib/smooch-api/models/destination.rb +18 -18
- data/lib/smooch-api/models/display_settings.rb +7 -7
- data/lib/smooch-api/models/get_messages_response.rb +7 -7
- data/lib/smooch-api/models/integration.rb +225 -225
- data/lib/smooch-api/models/integration_create.rb +182 -182
- data/lib/smooch-api/models/integration_profile_update.rb +7 -7
- data/lib/smooch-api/models/integration_response.rb +1 -1
- data/lib/smooch-api/models/integration_update.rb +82 -82
- data/lib/smooch-api/models/jwt_response.rb +1 -1
- data/lib/smooch-api/models/link_request_response.rb +7 -7
- data/lib/smooch-api/models/link_request_response_link_requests.rb +10 -10
- data/lib/smooch-api/models/list_apps_response.rb +7 -7
- data/lib/smooch-api/models/list_integrations_response.rb +1 -1
- data/lib/smooch-api/models/list_secret_keys_response.rb +1 -1
- data/lib/smooch-api/models/list_service_accounts_response.rb +12 -12
- data/lib/smooch-api/models/list_templates_response.rb +7 -7
- data/lib/smooch-api/models/list_webhooks_response.rb +1 -1
- data/lib/smooch-api/models/menu.rb +1 -1
- data/lib/smooch-api/models/menu_item.rb +1 -1
- data/lib/smooch-api/models/menu_response.rb +1 -1
- data/lib/smooch-api/models/message.rb +41 -41
- data/lib/smooch-api/models/message_item.rb +12 -12
- data/lib/smooch-api/models/message_override.rb +188 -0
- data/lib/smooch-api/models/message_override_whatsapp.rb +189 -0
- data/lib/smooch-api/models/message_post.rb +30 -20
- data/lib/smooch-api/models/message_response.rb +7 -7
- data/lib/smooch-api/models/secret_key.rb +10 -10
- data/lib/smooch-api/models/secret_key_create.rb +1 -1
- data/lib/smooch-api/models/secret_key_response.rb +1 -1
- data/lib/smooch-api/models/service_account.rb +10 -10
- data/lib/smooch-api/models/service_account_create.rb +1 -1
- data/lib/smooch-api/models/service_account_response.rb +7 -7
- data/lib/smooch-api/models/service_account_update.rb +1 -1
- data/lib/smooch-api/models/source.rb +1 -1
- data/lib/smooch-api/models/sub_menu_item.rb +1 -1
- data/lib/smooch-api/models/template.rb +10 -10
- data/lib/smooch-api/models/template_create.rb +1 -1
- data/lib/smooch-api/models/template_response.rb +1 -1
- data/lib/smooch-api/models/template_update.rb +1 -1
- data/lib/smooch-api/models/typing_activity_trigger.rb +7 -7
- data/lib/smooch-api/models/webhook.rb +10 -10
- data/lib/smooch-api/models/webhook_create.rb +1 -1
- data/lib/smooch-api/models/webhook_response.rb +1 -1
- data/lib/smooch-api/models/webhook_update.rb +1 -1
- data/lib/smooch-api/version.rb +2 -2
- data/smooch-api.gemspec +1 -1
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +6 -2
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
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
5
|
|
6
|
-
OpenAPI spec version: 4.
|
6
|
+
OpenAPI spec version: 4.2
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
Swagger Codegen version: 2.2.3-SNAPSHOT
|
@@ -22,13 +22,13 @@ module SmoochApi
|
|
22
22
|
attr_accessor :description
|
23
23
|
|
24
24
|
# The image URL to be shown in the carousel/list item.
|
25
|
-
attr_accessor :
|
25
|
+
attr_accessor :mediaUrl
|
26
26
|
|
27
27
|
# The size of the image to be shown in the carousel/list item. Only top item of Facebook Messenger carousel supported. Choose from *compact* and *large*.
|
28
28
|
attr_accessor :size
|
29
29
|
|
30
30
|
# If a *mediaUrl* was specified, the media type is defined here, for example *image/jpeg*.
|
31
|
-
attr_accessor :
|
31
|
+
attr_accessor :mediaType
|
32
32
|
|
33
33
|
# Array of [action buttons](https://docs.smooch.io/rest/#action-buttons). At least 1 is required, a maximum of 3 are allowed.
|
34
34
|
attr_accessor :actions
|
@@ -39,9 +39,9 @@ module SmoochApi
|
|
39
39
|
{
|
40
40
|
:'title' => :'title',
|
41
41
|
:'description' => :'description',
|
42
|
-
:'
|
42
|
+
:'mediaUrl' => :'mediaUrl',
|
43
43
|
:'size' => :'size',
|
44
|
-
:'
|
44
|
+
:'mediaType' => :'mediaType',
|
45
45
|
:'actions' => :'actions'
|
46
46
|
}
|
47
47
|
end
|
@@ -51,9 +51,9 @@ module SmoochApi
|
|
51
51
|
{
|
52
52
|
:'title' => :'String',
|
53
53
|
:'description' => :'String',
|
54
|
-
:'
|
54
|
+
:'mediaUrl' => :'String',
|
55
55
|
:'size' => :'String',
|
56
|
-
:'
|
56
|
+
:'mediaType' => :'String',
|
57
57
|
:'actions' => :'Array<Action>'
|
58
58
|
}
|
59
59
|
end
|
@@ -75,7 +75,7 @@ module SmoochApi
|
|
75
75
|
end
|
76
76
|
|
77
77
|
if attributes.has_key?(:'mediaUrl')
|
78
|
-
self.
|
78
|
+
self.mediaUrl = attributes[:'mediaUrl']
|
79
79
|
end
|
80
80
|
|
81
81
|
if attributes.has_key?(:'size')
|
@@ -83,7 +83,7 @@ module SmoochApi
|
|
83
83
|
end
|
84
84
|
|
85
85
|
if attributes.has_key?(:'mediaType')
|
86
|
-
self.
|
86
|
+
self.mediaType = attributes[:'mediaType']
|
87
87
|
end
|
88
88
|
|
89
89
|
if attributes.has_key?(:'actions')
|
@@ -124,9 +124,9 @@ module SmoochApi
|
|
124
124
|
self.class == o.class &&
|
125
125
|
title == o.title &&
|
126
126
|
description == o.description &&
|
127
|
-
|
127
|
+
mediaUrl == o.mediaUrl &&
|
128
128
|
size == o.size &&
|
129
|
-
|
129
|
+
mediaType == o.mediaType &&
|
130
130
|
actions == o.actions
|
131
131
|
end
|
132
132
|
|
@@ -139,7 +139,7 @@ module SmoochApi
|
|
139
139
|
# Calculates hash code according to all attributes.
|
140
140
|
# @return [Fixnum] Hash code
|
141
141
|
def hash
|
142
|
-
[title, description,
|
142
|
+
[title, description, mediaUrl, size, mediaType, actions].hash
|
143
143
|
end
|
144
144
|
|
145
145
|
# Builds the object from hash
|
@@ -0,0 +1,188 @@
|
|
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: 4.2
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SmoochApi
|
16
|
+
|
17
|
+
class MessageOverride
|
18
|
+
attr_accessor :whatsapp
|
19
|
+
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'whatsapp' => :'whatsapp'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'whatsapp' => :'MessageOverrideWhatsapp'
|
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?(:'whatsapp')
|
44
|
+
self.whatsapp = attributes[:'whatsapp']
|
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
|
+
return invalid_properties
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check to see if the all the properties in the model are valid
|
57
|
+
# @return true if the model is valid
|
58
|
+
def valid?
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks equality by comparing each attribute.
|
63
|
+
# @param [Object] Object to be compared
|
64
|
+
def ==(o)
|
65
|
+
return true if self.equal?(o)
|
66
|
+
self.class == o.class &&
|
67
|
+
whatsapp == o.whatsapp
|
68
|
+
end
|
69
|
+
|
70
|
+
# @see the `==` method
|
71
|
+
# @param [Object] Object to be compared
|
72
|
+
def eql?(o)
|
73
|
+
self == o
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculates hash code according to all attributes.
|
77
|
+
# @return [Fixnum] Hash code
|
78
|
+
def hash
|
79
|
+
[whatsapp].hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds the object from hash
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
# @return [Object] Returns the model itself
|
85
|
+
def build_from_hash(attributes)
|
86
|
+
return nil unless attributes.is_a?(Hash)
|
87
|
+
self.class.swagger_types.each_pair do |key, type|
|
88
|
+
if type =~ /\AArray<(.*)>/i
|
89
|
+
# check to ensure the input is an array given that the the attribute
|
90
|
+
# is documented as an array but the input is not
|
91
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
93
|
+
end
|
94
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
95
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
96
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
97
|
+
end
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# Deserializes the data based on type
|
103
|
+
# @param string type Data type
|
104
|
+
# @param string value Value to be deserialized
|
105
|
+
# @return [Object] Deserialized data
|
106
|
+
def _deserialize(type, value)
|
107
|
+
case type.to_sym
|
108
|
+
when :DateTime
|
109
|
+
DateTime.parse(value)
|
110
|
+
when :Date
|
111
|
+
Date.parse(value)
|
112
|
+
when :String
|
113
|
+
value.to_s
|
114
|
+
when :Integer
|
115
|
+
value.to_i
|
116
|
+
when :Float
|
117
|
+
value.to_f
|
118
|
+
when :BOOLEAN
|
119
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
120
|
+
true
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
when :Object
|
125
|
+
# generic object (usually a Hash), return directly
|
126
|
+
value
|
127
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
128
|
+
inner_type = Regexp.last_match[:inner_type]
|
129
|
+
value.map { |v| _deserialize(inner_type, v) }
|
130
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
131
|
+
k_type = Regexp.last_match[:k_type]
|
132
|
+
v_type = Regexp.last_match[:v_type]
|
133
|
+
{}.tap do |hash|
|
134
|
+
value.each do |k, v|
|
135
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
else # model
|
139
|
+
temp_model = SmoochApi.const_get(type).new
|
140
|
+
temp_model.build_from_hash(value)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the string representation of the object
|
145
|
+
# @return [String] String presentation of the object
|
146
|
+
def to_s
|
147
|
+
to_hash.to_s
|
148
|
+
end
|
149
|
+
|
150
|
+
# to_body is an alias to to_hash (backward compatibility)
|
151
|
+
# @return [Hash] Returns the object in the form of hash
|
152
|
+
def to_body
|
153
|
+
to_hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the object in the form of hash
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_hash
|
159
|
+
hash = {}
|
160
|
+
self.class.attribute_map.each_pair do |attr, param|
|
161
|
+
value = self.send(attr)
|
162
|
+
next if value.nil?
|
163
|
+
hash[param] = _to_hash(value)
|
164
|
+
end
|
165
|
+
hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Outputs non-array value in the form of hash
|
169
|
+
# For object, use to_hash. Otherwise, just return the value
|
170
|
+
# @param [Object] value Any valid value
|
171
|
+
# @return [Hash] Returns the value in the form of hash
|
172
|
+
def _to_hash(value)
|
173
|
+
if value.is_a?(Array)
|
174
|
+
value.compact.map{ |v| _to_hash(v) }
|
175
|
+
elsif value.is_a?(Hash)
|
176
|
+
{}.tap do |hash|
|
177
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
178
|
+
end
|
179
|
+
elsif value.respond_to? :to_hash
|
180
|
+
value.to_hash
|
181
|
+
else
|
182
|
+
value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
@@ -0,0 +1,189 @@
|
|
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: 4.2
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SmoochApi
|
16
|
+
|
17
|
+
class MessageOverrideWhatsapp
|
18
|
+
# The exact payload to send to WhatsApp.
|
19
|
+
attr_accessor :payload
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'payload' => :'payload'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'payload' => :'Object'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
return unless attributes.is_a?(Hash)
|
40
|
+
|
41
|
+
# convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
43
|
+
|
44
|
+
if attributes.has_key?(:'payload')
|
45
|
+
self.payload = attributes[:'payload']
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
51
|
+
# @return Array for valid properies with the reasons
|
52
|
+
def list_invalid_properties
|
53
|
+
invalid_properties = Array.new
|
54
|
+
return invalid_properties
|
55
|
+
end
|
56
|
+
|
57
|
+
# Check to see if the all the properties in the model are valid
|
58
|
+
# @return true if the model is valid
|
59
|
+
def valid?
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
|
63
|
+
# Checks equality by comparing each attribute.
|
64
|
+
# @param [Object] Object to be compared
|
65
|
+
def ==(o)
|
66
|
+
return true if self.equal?(o)
|
67
|
+
self.class == o.class &&
|
68
|
+
payload == o.payload
|
69
|
+
end
|
70
|
+
|
71
|
+
# @see the `==` method
|
72
|
+
# @param [Object] Object to be compared
|
73
|
+
def eql?(o)
|
74
|
+
self == o
|
75
|
+
end
|
76
|
+
|
77
|
+
# Calculates hash code according to all attributes.
|
78
|
+
# @return [Fixnum] Hash code
|
79
|
+
def hash
|
80
|
+
[payload].hash
|
81
|
+
end
|
82
|
+
|
83
|
+
# Builds the object from hash
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
+
# @return [Object] Returns the model itself
|
86
|
+
def build_from_hash(attributes)
|
87
|
+
return nil unless attributes.is_a?(Hash)
|
88
|
+
self.class.swagger_types.each_pair do |key, type|
|
89
|
+
if type =~ /\AArray<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
94
|
+
end
|
95
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
+
end
|
99
|
+
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
# Deserializes the data based on type
|
104
|
+
# @param string type Data type
|
105
|
+
# @param string value Value to be deserialized
|
106
|
+
# @return [Object] Deserialized data
|
107
|
+
def _deserialize(type, value)
|
108
|
+
case type.to_sym
|
109
|
+
when :DateTime
|
110
|
+
DateTime.parse(value)
|
111
|
+
when :Date
|
112
|
+
Date.parse(value)
|
113
|
+
when :String
|
114
|
+
value.to_s
|
115
|
+
when :Integer
|
116
|
+
value.to_i
|
117
|
+
when :Float
|
118
|
+
value.to_f
|
119
|
+
when :BOOLEAN
|
120
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
+
true
|
122
|
+
else
|
123
|
+
false
|
124
|
+
end
|
125
|
+
when :Object
|
126
|
+
# generic object (usually a Hash), return directly
|
127
|
+
value
|
128
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
+
inner_type = Regexp.last_match[:inner_type]
|
130
|
+
value.map { |v| _deserialize(inner_type, v) }
|
131
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
+
k_type = Regexp.last_match[:k_type]
|
133
|
+
v_type = Regexp.last_match[:v_type]
|
134
|
+
{}.tap do |hash|
|
135
|
+
value.each do |k, v|
|
136
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
else # model
|
140
|
+
temp_model = SmoochApi.const_get(type).new
|
141
|
+
temp_model.build_from_hash(value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the string representation of the object
|
146
|
+
# @return [String] String presentation of the object
|
147
|
+
def to_s
|
148
|
+
to_hash.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# to_body is an alias to to_hash (backward compatibility)
|
152
|
+
# @return [Hash] Returns the object in the form of hash
|
153
|
+
def to_body
|
154
|
+
to_hash
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the object in the form of hash
|
158
|
+
# @return [Hash] Returns the object in the form of hash
|
159
|
+
def to_hash
|
160
|
+
hash = {}
|
161
|
+
self.class.attribute_map.each_pair do |attr, param|
|
162
|
+
value = self.send(attr)
|
163
|
+
next if value.nil?
|
164
|
+
hash[param] = _to_hash(value)
|
165
|
+
end
|
166
|
+
hash
|
167
|
+
end
|
168
|
+
|
169
|
+
# Outputs non-array value in the form of hash
|
170
|
+
# For object, use to_hash. Otherwise, just return the value
|
171
|
+
# @param [Object] value Any valid value
|
172
|
+
# @return [Hash] Returns the value in the form of hash
|
173
|
+
def _to_hash(value)
|
174
|
+
if value.is_a?(Array)
|
175
|
+
value.compact.map{ |v| _to_hash(v) }
|
176
|
+
elsif value.is_a?(Hash)
|
177
|
+
{}.tap do |hash|
|
178
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
179
|
+
end
|
180
|
+
elsif value.respond_to? :to_hash
|
181
|
+
value.to_hash
|
182
|
+
else
|
183
|
+
value
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|