bombbomb 2.0.25797 → 2.0.25798
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -0
- data/README.md +68 -33
- data/Rakefile +8 -3
- data/bombbomb.gemspec +8 -17
- data/docs/AccountsApi.md +164 -5
- data/docs/AutomationsApi.md +52 -0
- data/docs/ClientGroupAssetMetaData.md +11 -0
- data/docs/ContactsApi.md +9 -6
- data/docs/EmailsApi.md +220 -0
- data/docs/FormsApi.md +60 -0
- data/docs/InlineResponse200.md +1 -1
- data/docs/IntegrationsApi.md +223 -0
- data/docs/JerichoConfiguration.md +2 -0
- data/docs/PromptMonthlyPerformance.md +11 -0
- data/docs/PromptOverview.md +11 -0
- data/docs/PromptSocialPrompt.md +20 -0
- data/docs/PromptsApi.md +230 -3
- data/docs/SocialsApi.md +167 -2
- data/docs/TeamsApi.md +300 -16
- data/docs/UsersApi.md +100 -0
- data/docs/VideoEmailPrompt.md +15 -15
- data/git_push.sh +1 -13
- data/lib/bombbomb.rb +8 -14
- data/lib/bombbomb/api/accounts_api.rb +189 -51
- data/lib/bombbomb/api/automations_api.rb +71 -30
- data/lib/bombbomb/api/contacts_api.rb +58 -86
- data/lib/bombbomb/api/curriculum_api.rb +8 -27
- data/lib/bombbomb/api/emails_api.rb +262 -66
- data/lib/bombbomb/api/files_api.rb +32 -53
- data/lib/bombbomb/api/forms_api.rb +77 -0
- data/lib/bombbomb/api/integrations_api.rb +238 -20
- data/lib/bombbomb/api/lists_api.rb +32 -53
- data/lib/bombbomb/api/orders_api.rb +8 -21
- data/lib/bombbomb/api/prompts_api.rb +347 -112
- data/lib/bombbomb/api/socials_api.rb +242 -87
- data/lib/bombbomb/api/teams_api.rb +485 -193
- data/lib/bombbomb/api/users_api.rb +119 -0
- data/lib/bombbomb/api/utilities_api.rb +23 -44
- data/lib/bombbomb/api/videos_api.rb +38 -55
- data/lib/bombbomb/api/webhooks_api.rb +23 -50
- data/lib/bombbomb/api_client.rb +55 -45
- data/lib/bombbomb/api_error.rb +9 -18
- data/lib/bombbomb/configuration.rb +8 -13
- data/lib/bombbomb/models/bb_web_hook.rb +6 -17
- data/lib/bombbomb/models/client_group_asset_meta_data.rb +215 -0
- data/lib/bombbomb/models/curriculum.rb +6 -17
- data/lib/bombbomb/models/curriculum_user_progress.rb +6 -17
- data/lib/bombbomb/models/curriculum_with_progress.rb +6 -17
- data/lib/bombbomb/models/hosted_doc.rb +6 -17
- data/lib/bombbomb/models/inline_response_200.rb +7 -18
- data/lib/bombbomb/models/inline_response_200_items.rb +1 -1
- data/lib/bombbomb/models/jericho_configuration.rb +34 -21
- data/lib/bombbomb/models/jericho_performance.rb +6 -17
- data/lib/bombbomb/models/o_auth_client.rb +6 -17
- data/lib/bombbomb/models/prompt_bot.rb +6 -17
- data/lib/bombbomb/models/prompt_monthly_performance.rb +219 -0
- data/lib/bombbomb/models/prompt_overview.rb +219 -0
- data/lib/bombbomb/models/prompt_social_prompt.rb +311 -0
- data/lib/bombbomb/models/sign_upload_request.rb +6 -17
- data/lib/bombbomb/models/sign_upload_response.rb +6 -17
- data/lib/bombbomb/models/string.rb +6 -17
- data/lib/bombbomb/models/team_public_representation.rb +6 -17
- data/lib/bombbomb/models/video_email_prompt.rb +128 -144
- data/lib/bombbomb/models/video_encoding_status_response.rb +6 -17
- data/lib/bombbomb/models/video_public_representation.rb +6 -17
- data/lib/bombbomb/models/video_recorder_method_response.rb +6 -17
- data/lib/bombbomb/version.rb +3 -14
- data/spec/api/forms_api_spec.rb +58 -0
- data/spec/api/users_api_spec.rb +57 -0
- data/spec/models/{inline_response_200_items_spec.rb → client_group_asset_meta_data_spec.rb} +8 -19
- data/spec/models/prompt_monthly_performance_spec.rb +60 -0
- data/spec/models/prompt_overview_spec.rb +60 -0
- data/spec/models/{prompt_bot_bot_spec.rb → prompt_social_prompt_spec.rb} +27 -15
- metadata +40 -20
data/lib/bombbomb/api_client.rb
CHANGED
@@ -3,21 +3,10 @@
|
|
3
3
|
|
4
4
|
#We make it easy to build relationships using simple videos.
|
5
5
|
|
6
|
-
OpenAPI spec version: 2.0.
|
6
|
+
OpenAPI spec version: 2.0.831
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
you may not use this file except in compliance with the License.
|
12
|
-
You may obtain a copy of the License at
|
13
|
-
|
14
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
|
16
|
-
Unless required by applicable law or agreed to in writing, software
|
17
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
See the License for the specific language governing permissions and
|
20
|
-
limitations under the License.
|
9
|
+
Swagger Codegen version: 2.3.1
|
21
10
|
|
22
11
|
=end
|
23
12
|
|
@@ -66,10 +55,18 @@ module BombBomb
|
|
66
55
|
end
|
67
56
|
|
68
57
|
unless response.success?
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
if response.timed_out?
|
59
|
+
fail ApiError.new('Connection timed out')
|
60
|
+
elsif response.code == 0
|
61
|
+
# Errors from libcurl will be made visible here
|
62
|
+
fail ApiError.new(:code => 0,
|
63
|
+
:message => response.return_message)
|
64
|
+
else
|
65
|
+
fail ApiError.new(:code => response.code,
|
66
|
+
:response_headers => response.headers,
|
67
|
+
:response_body => response.body),
|
68
|
+
response.status_message
|
69
|
+
end
|
73
70
|
end
|
74
71
|
|
75
72
|
if opts[:return_type]
|
@@ -126,7 +123,9 @@ module BombBomb
|
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
|
-
Typhoeus::Request.new(url, req_opts)
|
126
|
+
request = Typhoeus::Request.new(url, req_opts)
|
127
|
+
download_file(request) if opts[:return_type] == 'File'
|
128
|
+
request
|
130
129
|
end
|
131
130
|
|
132
131
|
# Check if the given MIME is a JSON MIME.
|
@@ -134,10 +133,11 @@ module BombBomb
|
|
134
133
|
# application/json
|
135
134
|
# application/json; charset=UTF8
|
136
135
|
# APPLICATION/JSON
|
136
|
+
# */*
|
137
137
|
# @param [String] mime MIME
|
138
|
-
# @return [Boolean] True if the MIME is
|
138
|
+
# @return [Boolean] True if the MIME is application/json
|
139
139
|
def json_mime?(mime)
|
140
|
-
!(mime =~
|
140
|
+
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
141
141
|
end
|
142
142
|
|
143
143
|
# Deserialize the response to the given return type.
|
@@ -146,14 +146,16 @@ module BombBomb
|
|
146
146
|
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
147
147
|
def deserialize(response, return_type)
|
148
148
|
body = response.body
|
149
|
+
|
150
|
+
# handle file downloading - return the File instance processed in request callbacks
|
151
|
+
# note that response body is empty when the file is written in chunks in request on_body callback
|
152
|
+
return @tempfile if return_type == 'File'
|
153
|
+
|
149
154
|
return nil if body.nil? || body.empty?
|
150
155
|
|
151
156
|
# return response body directly for String return type
|
152
157
|
return body if return_type == 'String'
|
153
158
|
|
154
|
-
# handle file downloading - save response body into a tmp file and return the File instance
|
155
|
-
return download_file(response) if return_type == 'File'
|
156
|
-
|
157
159
|
# ensuring a default content type
|
158
160
|
content_type = response.headers['Content-Type'] || 'application/json'
|
159
161
|
|
@@ -216,30 +218,38 @@ module BombBomb
|
|
216
218
|
|
217
219
|
# Save response body into a file in (the defined) temporary folder, using the filename
|
218
220
|
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
221
|
+
# The response body is written to the file in chunks in order to handle files which
|
222
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
223
|
+
# process can use.
|
219
224
|
#
|
220
225
|
# @see Configuration#temp_folder_path
|
221
|
-
|
222
|
-
def download_file(response)
|
223
|
-
content_disposition = response.headers['Content-Disposition']
|
224
|
-
if content_disposition and content_disposition =~ /filename=/i
|
225
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
226
|
-
prefix = sanitize_filename(filename)
|
227
|
-
else
|
228
|
-
prefix = 'download-'
|
229
|
-
end
|
230
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
231
|
-
|
226
|
+
def download_file(request)
|
232
227
|
tempfile = nil
|
233
|
-
encoding =
|
234
|
-
|
235
|
-
|
236
|
-
|
228
|
+
encoding = nil
|
229
|
+
request.on_headers do |response|
|
230
|
+
content_disposition = response.headers['Content-Disposition']
|
231
|
+
if content_disposition and content_disposition =~ /filename=/i
|
232
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
233
|
+
prefix = sanitize_filename(filename)
|
234
|
+
else
|
235
|
+
prefix = 'download-'
|
236
|
+
end
|
237
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
238
|
+
encoding = response.body.encoding
|
239
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
240
|
+
@tempfile = tempfile
|
241
|
+
end
|
242
|
+
request.on_body do |chunk|
|
243
|
+
chunk.force_encoding(encoding)
|
244
|
+
tempfile.write(chunk)
|
245
|
+
end
|
246
|
+
request.on_complete do |response|
|
247
|
+
tempfile.close
|
248
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
249
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
250
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
251
|
+
"explicitly with `tempfile.delete`"
|
237
252
|
end
|
238
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
239
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
240
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
241
|
-
"explicitly with `tempfile.delete`"
|
242
|
-
tempfile
|
243
253
|
end
|
244
254
|
|
245
255
|
# Sanitize filename by removing path.
|
@@ -270,7 +280,7 @@ module BombBomb
|
|
270
280
|
data = {}
|
271
281
|
form_params.each do |key, value|
|
272
282
|
case value
|
273
|
-
when File, Array, nil
|
283
|
+
when ::File, ::Array, nil
|
274
284
|
# let typhoeus handle File, Array and nil parameters
|
275
285
|
data[key] = value
|
276
286
|
else
|
@@ -288,7 +298,7 @@ module BombBomb
|
|
288
298
|
# Update hearder and query params based on authentication settings.
|
289
299
|
#
|
290
300
|
# @param [Hash] header_params Header parameters
|
291
|
-
# @param [Hash]
|
301
|
+
# @param [Hash] query_params Query parameters
|
292
302
|
# @param [String] auth_names Authentication scheme name
|
293
303
|
def update_params_for_auth!(header_params, query_params, auth_names)
|
294
304
|
Array(auth_names).each do |auth_name|
|
data/lib/bombbomb/api_error.rb
CHANGED
@@ -3,21 +3,10 @@
|
|
3
3
|
|
4
4
|
#We make it easy to build relationships using simple videos.
|
5
5
|
|
6
|
-
OpenAPI spec version: 2.0.
|
6
|
+
OpenAPI spec version: 2.0.831
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
you may not use this file except in compliance with the License.
|
12
|
-
You may obtain a copy of the License at
|
13
|
-
|
14
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
|
16
|
-
Unless required by applicable law or agreed to in writing, software
|
17
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
See the License for the specific language governing permissions and
|
20
|
-
limitations under the License.
|
9
|
+
Swagger Codegen version: 2.3.1
|
21
10
|
|
22
11
|
=end
|
23
12
|
|
@@ -32,12 +21,14 @@ module BombBomb
|
|
32
21
|
# ApiError.new(:code => 404, :message => "Not Found")
|
33
22
|
def initialize(arg = nil)
|
34
23
|
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
35
30
|
arg.each do |k, v|
|
36
|
-
|
37
|
-
super v
|
38
|
-
else
|
39
|
-
instance_variable_set "@#{k}", v
|
40
|
-
end
|
31
|
+
instance_variable_set "@#{k}", v
|
41
32
|
end
|
42
33
|
else
|
43
34
|
super arg
|
@@ -3,21 +3,10 @@
|
|
3
3
|
|
4
4
|
#We make it easy to build relationships using simple videos.
|
5
5
|
|
6
|
-
OpenAPI spec version: 2.0.
|
6
|
+
OpenAPI spec version: 2.0.831
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
you may not use this file except in compliance with the License.
|
12
|
-
You may obtain a copy of the License at
|
13
|
-
|
14
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
|
16
|
-
Unless required by applicable law or agreed to in writing, software
|
17
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
See the License for the specific language governing permissions and
|
20
|
-
limitations under the License.
|
9
|
+
Swagger Codegen version: 2.3.1
|
21
10
|
|
22
11
|
=end
|
23
12
|
|
@@ -87,6 +76,11 @@ module BombBomb
|
|
87
76
|
# Default to 0 (never times out).
|
88
77
|
attr_accessor :timeout
|
89
78
|
|
79
|
+
# Set this to false to skip client side validation in the operation.
|
80
|
+
# Default to true.
|
81
|
+
# @return [true, false]
|
82
|
+
attr_accessor :client_side_validation
|
83
|
+
|
90
84
|
### TLS/SSL setting
|
91
85
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
92
86
|
# Default to true.
|
@@ -140,6 +134,7 @@ module BombBomb
|
|
140
134
|
@api_key = {}
|
141
135
|
@api_key_prefix = {}
|
142
136
|
@timeout = 0
|
137
|
+
@client_side_validation = true
|
143
138
|
@verify_ssl = true
|
144
139
|
@verify_ssl_host = true
|
145
140
|
@params_encoding = nil
|
@@ -3,21 +3,10 @@
|
|
3
3
|
|
4
4
|
#We make it easy to build relationships using simple videos.
|
5
5
|
|
6
|
-
OpenAPI spec version: 2.0.
|
6
|
+
OpenAPI spec version: 2.0.831
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
you may not use this file except in compliance with the License.
|
12
|
-
You may obtain a copy of the License at
|
13
|
-
|
14
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
|
16
|
-
Unless required by applicable law or agreed to in writing, software
|
17
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
See the License for the specific language governing permissions and
|
20
|
-
limitations under the License.
|
9
|
+
Swagger Codegen version: 2.3.1
|
21
10
|
|
22
11
|
=end
|
23
12
|
|
@@ -86,7 +75,7 @@ module BombBomb
|
|
86
75
|
end
|
87
76
|
|
88
77
|
# Show invalid properties with the reasons. Usually used together with valid?
|
89
|
-
# @return Array for valid
|
78
|
+
# @return Array for valid properties with the reasons
|
90
79
|
def list_invalid_properties
|
91
80
|
invalid_properties = Array.new
|
92
81
|
return invalid_properties
|
@@ -127,7 +116,7 @@ module BombBomb
|
|
127
116
|
def build_from_hash(attributes)
|
128
117
|
return nil unless attributes.is_a?(Hash)
|
129
118
|
self.class.swagger_types.each_pair do |key, type|
|
130
|
-
if type =~
|
119
|
+
if type =~ /\AArray<(.*)>/i
|
131
120
|
# check to ensure the input is an array given that the the attribute
|
132
121
|
# is documented as an array but the input is not
|
133
122
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -158,7 +147,7 @@ module BombBomb
|
|
158
147
|
when :Float
|
159
148
|
value.to_f
|
160
149
|
when :BOOLEAN
|
161
|
-
if value.to_s =~
|
150
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
151
|
true
|
163
152
|
else
|
164
153
|
false
|
@@ -169,7 +158,7 @@ module BombBomb
|
|
169
158
|
when /\AArray<(?<inner_type>.+)>\z/
|
170
159
|
inner_type = Regexp.last_match[:inner_type]
|
171
160
|
value.map { |v| _deserialize(inner_type, v) }
|
172
|
-
when /\AHash<(?<k_type
|
161
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
173
162
|
k_type = Regexp.last_match[:k_type]
|
174
163
|
v_type = Regexp.last_match[:v_type]
|
175
164
|
{}.tap do |hash|
|
@@ -0,0 +1,215 @@
|
|
1
|
+
=begin
|
2
|
+
#BombBomb
|
3
|
+
|
4
|
+
#We make it easy to build relationships using simple videos.
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.831
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BombBomb
|
16
|
+
|
17
|
+
class ClientGroupAssetMetaData
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
attr_accessor :user_id
|
23
|
+
|
24
|
+
attr_accessor :thumb_url
|
25
|
+
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'id' => :'id',
|
31
|
+
:'name' => :'name',
|
32
|
+
:'user_id' => :'userId',
|
33
|
+
:'thumb_url' => :'thumbUrl'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Attribute type mapping.
|
38
|
+
def self.swagger_types
|
39
|
+
{
|
40
|
+
:'id' => :'String',
|
41
|
+
:'name' => :'String',
|
42
|
+
:'user_id' => :'String',
|
43
|
+
:'thumb_url' => :'String'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initializes the object
|
48
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
49
|
+
def initialize(attributes = {})
|
50
|
+
return unless attributes.is_a?(Hash)
|
51
|
+
|
52
|
+
# convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
54
|
+
|
55
|
+
if attributes.has_key?(:'id')
|
56
|
+
self.id = attributes[:'id']
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.has_key?(:'name')
|
60
|
+
self.name = attributes[:'name']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'userId')
|
64
|
+
self.user_id = attributes[:'userId']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'thumbUrl')
|
68
|
+
self.thumb_url = attributes[:'thumbUrl']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
return invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
return true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
id == o.id &&
|
92
|
+
name == o.name &&
|
93
|
+
user_id == o.user_id &&
|
94
|
+
thumb_url == o.thumb_url
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Fixnum] Hash code
|
105
|
+
def hash
|
106
|
+
[id, name, user_id, thumb_url].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
self.class.swagger_types.each_pair do |key, type|
|
115
|
+
if type =~ /\AArray<(.*)>/i
|
116
|
+
# check to ensure the input is an array given that the the attribute
|
117
|
+
# is documented as an array but the input is not
|
118
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
119
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
120
|
+
end
|
121
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
122
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
123
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# Deserializes the data based on type
|
130
|
+
# @param string type Data type
|
131
|
+
# @param string value Value to be deserialized
|
132
|
+
# @return [Object] Deserialized data
|
133
|
+
def _deserialize(type, value)
|
134
|
+
case type.to_sym
|
135
|
+
when :DateTime
|
136
|
+
DateTime.parse(value)
|
137
|
+
when :Date
|
138
|
+
Date.parse(value)
|
139
|
+
when :String
|
140
|
+
value.to_s
|
141
|
+
when :Integer
|
142
|
+
value.to_i
|
143
|
+
when :Float
|
144
|
+
value.to_f
|
145
|
+
when :BOOLEAN
|
146
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
150
|
+
end
|
151
|
+
when :Object
|
152
|
+
# generic object (usually a Hash), return directly
|
153
|
+
value
|
154
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
155
|
+
inner_type = Regexp.last_match[:inner_type]
|
156
|
+
value.map { |v| _deserialize(inner_type, v) }
|
157
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
158
|
+
k_type = Regexp.last_match[:k_type]
|
159
|
+
v_type = Regexp.last_match[:v_type]
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each do |k, v|
|
162
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else # model
|
166
|
+
temp_model = BombBomb.const_get(type).new
|
167
|
+
temp_model.build_from_hash(value)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the string representation of the object
|
172
|
+
# @return [String] String presentation of the object
|
173
|
+
def to_s
|
174
|
+
to_hash.to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
# to_body is an alias to to_hash (backward compatibility)
|
178
|
+
# @return [Hash] Returns the object in the form of hash
|
179
|
+
def to_body
|
180
|
+
to_hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns the object in the form of hash
|
184
|
+
# @return [Hash] Returns the object in the form of hash
|
185
|
+
def to_hash
|
186
|
+
hash = {}
|
187
|
+
self.class.attribute_map.each_pair do |attr, param|
|
188
|
+
value = self.send(attr)
|
189
|
+
next if value.nil?
|
190
|
+
hash[param] = _to_hash(value)
|
191
|
+
end
|
192
|
+
hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Outputs non-array value in the form of hash
|
196
|
+
# For object, use to_hash. Otherwise, just return the value
|
197
|
+
# @param [Object] value Any valid value
|
198
|
+
# @return [Hash] Returns the value in the form of hash
|
199
|
+
def _to_hash(value)
|
200
|
+
if value.is_a?(Array)
|
201
|
+
value.compact.map{ |v| _to_hash(v) }
|
202
|
+
elsif value.is_a?(Hash)
|
203
|
+
{}.tap do |hash|
|
204
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
205
|
+
end
|
206
|
+
elsif value.respond_to? :to_hash
|
207
|
+
value.to_hash
|
208
|
+
else
|
209
|
+
value
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|