phrase 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +10 -5
- data/docs/KeyCreateParameters.md +1 -1
- data/docs/KeyUpdateParameters.md +1 -1
- data/docs/LocaleDownload.md +29 -0
- data/docs/LocaleDownloadCreateParameters.md +43 -0
- data/docs/LocaleDownloadParams.md +29 -0
- data/docs/LocaleDownloadResult.md +17 -0
- data/docs/LocaleDownloadsApi.md +148 -0
- data/docs/ProjectCreateParameters.md +1 -1
- data/docs/ProjectUpdateParameters.md +1 -1
- data/docs/ReleaseCreateParameters.md +4 -0
- data/docs/ReleaseUpdateParameters.md +4 -0
- data/docs/RepoSyncEvent.md +3 -1
- data/docs/RepoSyncsApi.md +70 -4
- data/docs/ScreenshotUpdateParameters.md +1 -1
- data/lib/phrase/api/locale_downloads_api.rb +180 -0
- data/lib/phrase/api/repo_syncs_api.rb +84 -6
- data/lib/phrase/models/locale_download.rb +285 -0
- data/lib/phrase/models/locale_download_create_parameters.rb +332 -0
- data/lib/phrase/models/{repo_sync_import.rb → locale_download_params.rb} +65 -10
- data/lib/phrase/models/{repo_sync_export.rb → locale_download_result.rb} +11 -10
- data/lib/phrase/models/release_create_parameters.rb +21 -1
- data/lib/phrase/models/release_update_parameters.rb +21 -1
- data/lib/phrase/models/repo_sync_event.rb +10 -1
- data/lib/phrase/version.rb +1 -1
- data/lib/phrase.rb +5 -2
- data/spec/api/locale_downloads_api_spec.rb +57 -0
- data/spec/api/repo_syncs_api_spec.rb +17 -2
- data/spec/models/locale_download_create_parameters_spec.rb +107 -0
- data/spec/models/locale_download_params_spec.rb +65 -0
- data/spec/models/{repo_sync_export_spec.rb → locale_download_result_spec.rb} +7 -7
- data/spec/models/locale_download_spec.rb +69 -0
- data/spec/models/release_create_parameters_spec.rb +12 -0
- data/spec/models/release_update_parameters_spec.rb +12 -0
- data/spec/models/repo_sync_event_spec.rb +6 -0
- metadata +258 -246
- data/docs/RepoSyncExport.md +0 -17
- data/docs/RepoSyncImport.md +0 -17
- data/spec/models/repo_sync_import_spec.rb +0 -29
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module Phrase
|
4
|
+
class LocaleDownloadsApi
|
5
|
+
attr_accessor :api_client
|
6
|
+
|
7
|
+
def initialize(api_client = ApiClient.default)
|
8
|
+
@api_client = api_client
|
9
|
+
end
|
10
|
+
# Initiate async download of a locale
|
11
|
+
# Prepare a locale for download in a specific file format.
|
12
|
+
# @param project_id [String] Project ID
|
13
|
+
# @param locale_id [String] Locale ID
|
14
|
+
# @param locale_download_create_parameters [LocaleDownloadCreateParameters]
|
15
|
+
# @param [Hash] opts the optional parameters
|
16
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
17
|
+
# @option opts [String] :if_modified_since Last modified condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
18
|
+
# @option opts [String] :if_none_match ETag condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
19
|
+
# @return [LocaleDownload]
|
20
|
+
def locale_download_create(project_id, locale_id, locale_download_create_parameters, opts = {})
|
21
|
+
data, _status_code, _headers = locale_download_create_with_http_info(project_id, locale_id, locale_download_create_parameters, opts)
|
22
|
+
data
|
23
|
+
end
|
24
|
+
|
25
|
+
# Initiate async download of a locale
|
26
|
+
# Prepare a locale for download in a specific file format.
|
27
|
+
# @param project_id [String] Project ID
|
28
|
+
# @param locale_id [String] Locale ID
|
29
|
+
# @param locale_download_create_parameters [LocaleDownloadCreateParameters]
|
30
|
+
# @param [Hash] opts the optional parameters
|
31
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
32
|
+
# @option opts [String] :if_modified_since Last modified condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
33
|
+
# @option opts [String] :if_none_match ETag condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
34
|
+
# @return [Array<(Response<(LocaleDownload)>, Integer, Hash)>] Response<(LocaleDownload)> data, response status code and response headers
|
35
|
+
def locale_download_create_with_http_info(project_id, locale_id, locale_download_create_parameters, opts = {})
|
36
|
+
if @api_client.config.debugging
|
37
|
+
@api_client.config.logger.debug 'Calling API: LocaleDownloadsApi.locale_download_create ...'
|
38
|
+
end
|
39
|
+
# verify the required parameter 'project_id' is set
|
40
|
+
if @api_client.config.client_side_validation && project_id.nil?
|
41
|
+
fail ArgumentError, "Missing the required parameter 'project_id' when calling LocaleDownloadsApi.locale_download_create"
|
42
|
+
end
|
43
|
+
# verify the required parameter 'locale_id' is set
|
44
|
+
if @api_client.config.client_side_validation && locale_id.nil?
|
45
|
+
fail ArgumentError, "Missing the required parameter 'locale_id' when calling LocaleDownloadsApi.locale_download_create"
|
46
|
+
end
|
47
|
+
# verify the required parameter 'locale_download_create_parameters' is set
|
48
|
+
if @api_client.config.client_side_validation && locale_download_create_parameters.nil?
|
49
|
+
fail ArgumentError, "Missing the required parameter 'locale_download_create_parameters' when calling LocaleDownloadsApi.locale_download_create"
|
50
|
+
end
|
51
|
+
# resource path
|
52
|
+
local_var_path = '/projects/{project_id}/locales/{locale_id}/downloads'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'locale_id' + '}', CGI.escape(locale_id.to_s))
|
53
|
+
|
54
|
+
# query parameters
|
55
|
+
query_params = opts[:query_params] || {}
|
56
|
+
|
57
|
+
# header parameters
|
58
|
+
header_params = opts[:header_params] || {}
|
59
|
+
# HTTP header 'Accept' (if needed)
|
60
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
61
|
+
# HTTP header 'Content-Type'
|
62
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
63
|
+
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
|
64
|
+
header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?
|
65
|
+
header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?
|
66
|
+
|
67
|
+
# form parameters
|
68
|
+
form_params = opts[:form_params] || {}
|
69
|
+
|
70
|
+
# http body (model)
|
71
|
+
post_body = opts[:body] || @api_client.object_to_http_body(locale_download_create_parameters)
|
72
|
+
|
73
|
+
# return_type
|
74
|
+
return_type = opts[:return_type] || 'LocaleDownload'
|
75
|
+
|
76
|
+
# auth_names
|
77
|
+
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
78
|
+
|
79
|
+
new_options = opts.merge(
|
80
|
+
:header_params => header_params,
|
81
|
+
:query_params => query_params,
|
82
|
+
:form_params => form_params,
|
83
|
+
:body => post_body,
|
84
|
+
:auth_names => auth_names,
|
85
|
+
:return_type => return_type
|
86
|
+
)
|
87
|
+
|
88
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
89
|
+
if @api_client.config.debugging
|
90
|
+
@api_client.config.logger.debug "API called: LocaleDownloadsApi#locale_download_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
91
|
+
end
|
92
|
+
response = ::Phrase::Response.new(data, headers)
|
93
|
+
return response, status_code, headers
|
94
|
+
end
|
95
|
+
|
96
|
+
# Show status of an async locale download
|
97
|
+
# Show status of already started async locale download. If the download is finished, the download link will be returned.
|
98
|
+
# @param project_id [String] Project ID
|
99
|
+
# @param locale_id [String] Locale ID
|
100
|
+
# @param id [String] ID
|
101
|
+
# @param [Hash] opts the optional parameters
|
102
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
103
|
+
# @option opts [String] :if_modified_since Last modified condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
104
|
+
# @option opts [String] :if_none_match ETag condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
105
|
+
# @return [LocaleDownload]
|
106
|
+
def locale_download_show(project_id, locale_id, id, opts = {})
|
107
|
+
data, _status_code, _headers = locale_download_show_with_http_info(project_id, locale_id, id, opts)
|
108
|
+
data
|
109
|
+
end
|
110
|
+
|
111
|
+
# Show status of an async locale download
|
112
|
+
# Show status of already started async locale download. If the download is finished, the download link will be returned.
|
113
|
+
# @param project_id [String] Project ID
|
114
|
+
# @param locale_id [String] Locale ID
|
115
|
+
# @param id [String] ID
|
116
|
+
# @param [Hash] opts the optional parameters
|
117
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
118
|
+
# @option opts [String] :if_modified_since Last modified condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
119
|
+
# @option opts [String] :if_none_match ETag condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
|
120
|
+
# @return [Array<(Response<(LocaleDownload)>, Integer, Hash)>] Response<(LocaleDownload)> data, response status code and response headers
|
121
|
+
def locale_download_show_with_http_info(project_id, locale_id, id, opts = {})
|
122
|
+
if @api_client.config.debugging
|
123
|
+
@api_client.config.logger.debug 'Calling API: LocaleDownloadsApi.locale_download_show ...'
|
124
|
+
end
|
125
|
+
# verify the required parameter 'project_id' is set
|
126
|
+
if @api_client.config.client_side_validation && project_id.nil?
|
127
|
+
fail ArgumentError, "Missing the required parameter 'project_id' when calling LocaleDownloadsApi.locale_download_show"
|
128
|
+
end
|
129
|
+
# verify the required parameter 'locale_id' is set
|
130
|
+
if @api_client.config.client_side_validation && locale_id.nil?
|
131
|
+
fail ArgumentError, "Missing the required parameter 'locale_id' when calling LocaleDownloadsApi.locale_download_show"
|
132
|
+
end
|
133
|
+
# verify the required parameter 'id' is set
|
134
|
+
if @api_client.config.client_side_validation && id.nil?
|
135
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling LocaleDownloadsApi.locale_download_show"
|
136
|
+
end
|
137
|
+
# resource path
|
138
|
+
local_var_path = '/projects/{project_id}/locales/{locale_id}/downloads/{id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'locale_id' + '}', CGI.escape(locale_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
139
|
+
|
140
|
+
# query parameters
|
141
|
+
query_params = opts[:query_params] || {}
|
142
|
+
|
143
|
+
# header parameters
|
144
|
+
header_params = opts[:header_params] || {}
|
145
|
+
# HTTP header 'Accept' (if needed)
|
146
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
147
|
+
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
|
148
|
+
header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?
|
149
|
+
header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?
|
150
|
+
|
151
|
+
# form parameters
|
152
|
+
form_params = opts[:form_params] || {}
|
153
|
+
|
154
|
+
# http body (model)
|
155
|
+
post_body = opts[:body]
|
156
|
+
|
157
|
+
# return_type
|
158
|
+
return_type = opts[:return_type] || 'LocaleDownload'
|
159
|
+
|
160
|
+
# auth_names
|
161
|
+
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
162
|
+
|
163
|
+
new_options = opts.merge(
|
164
|
+
:header_params => header_params,
|
165
|
+
:query_params => query_params,
|
166
|
+
:form_params => form_params,
|
167
|
+
:body => post_body,
|
168
|
+
:auth_names => auth_names,
|
169
|
+
:return_type => return_type
|
170
|
+
)
|
171
|
+
|
172
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
173
|
+
if @api_client.config.debugging
|
174
|
+
@api_client.config.logger.debug "API called: LocaleDownloadsApi#locale_download_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
175
|
+
end
|
176
|
+
response = ::Phrase::Response.new(data, headers)
|
177
|
+
return response, status_code, headers
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -151,6 +151,84 @@ module Phrase
|
|
151
151
|
return response, status_code, headers
|
152
152
|
end
|
153
153
|
|
154
|
+
# Get a single Repo Sync Event
|
155
|
+
# Shows a single Repo Sync event.
|
156
|
+
# @param account_id [String] Account ID
|
157
|
+
# @param repo_sync_id [String] Repo Sync ID
|
158
|
+
# @param id [String] ID
|
159
|
+
# @param [Hash] opts the optional parameters
|
160
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
161
|
+
# @return [RepoSyncEvent]
|
162
|
+
def repo_sync_event_show(account_id, repo_sync_id, id, opts = {})
|
163
|
+
data, _status_code, _headers = repo_sync_event_show_with_http_info(account_id, repo_sync_id, id, opts)
|
164
|
+
data
|
165
|
+
end
|
166
|
+
|
167
|
+
# Get a single Repo Sync Event
|
168
|
+
# Shows a single Repo Sync event.
|
169
|
+
# @param account_id [String] Account ID
|
170
|
+
# @param repo_sync_id [String] Repo Sync ID
|
171
|
+
# @param id [String] ID
|
172
|
+
# @param [Hash] opts the optional parameters
|
173
|
+
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
174
|
+
# @return [Array<(Response<(RepoSyncEvent)>, Integer, Hash)>] Response<(RepoSyncEvent)> data, response status code and response headers
|
175
|
+
def repo_sync_event_show_with_http_info(account_id, repo_sync_id, id, opts = {})
|
176
|
+
if @api_client.config.debugging
|
177
|
+
@api_client.config.logger.debug 'Calling API: RepoSyncsApi.repo_sync_event_show ...'
|
178
|
+
end
|
179
|
+
# verify the required parameter 'account_id' is set
|
180
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
181
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling RepoSyncsApi.repo_sync_event_show"
|
182
|
+
end
|
183
|
+
# verify the required parameter 'repo_sync_id' is set
|
184
|
+
if @api_client.config.client_side_validation && repo_sync_id.nil?
|
185
|
+
fail ArgumentError, "Missing the required parameter 'repo_sync_id' when calling RepoSyncsApi.repo_sync_event_show"
|
186
|
+
end
|
187
|
+
# verify the required parameter 'id' is set
|
188
|
+
if @api_client.config.client_side_validation && id.nil?
|
189
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling RepoSyncsApi.repo_sync_event_show"
|
190
|
+
end
|
191
|
+
# resource path
|
192
|
+
local_var_path = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/events/{id}'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)).sub('{' + 'repo_sync_id' + '}', CGI.escape(repo_sync_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
193
|
+
|
194
|
+
# query parameters
|
195
|
+
query_params = opts[:query_params] || {}
|
196
|
+
|
197
|
+
# header parameters
|
198
|
+
header_params = opts[:header_params] || {}
|
199
|
+
# HTTP header 'Accept' (if needed)
|
200
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
201
|
+
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
|
202
|
+
|
203
|
+
# form parameters
|
204
|
+
form_params = opts[:form_params] || {}
|
205
|
+
|
206
|
+
# http body (model)
|
207
|
+
post_body = opts[:body]
|
208
|
+
|
209
|
+
# return_type
|
210
|
+
return_type = opts[:return_type] || 'RepoSyncEvent'
|
211
|
+
|
212
|
+
# auth_names
|
213
|
+
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
214
|
+
|
215
|
+
new_options = opts.merge(
|
216
|
+
:header_params => header_params,
|
217
|
+
:query_params => query_params,
|
218
|
+
:form_params => form_params,
|
219
|
+
:body => post_body,
|
220
|
+
:auth_names => auth_names,
|
221
|
+
:return_type => return_type
|
222
|
+
)
|
223
|
+
|
224
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
225
|
+
if @api_client.config.debugging
|
226
|
+
@api_client.config.logger.debug "API called: RepoSyncsApi#repo_sync_event_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
227
|
+
end
|
228
|
+
response = ::Phrase::Response.new(data, headers)
|
229
|
+
return response, status_code, headers
|
230
|
+
end
|
231
|
+
|
154
232
|
# Repository Syncs History
|
155
233
|
# Get the history of a single Repo Sync. The history includes all imports and exports performed by the Repo Sync.
|
156
234
|
# @param account_id [String] Account ID
|
@@ -229,7 +307,7 @@ module Phrase
|
|
229
307
|
# @param id [String] ID
|
230
308
|
# @param [Hash] opts the optional parameters
|
231
309
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
232
|
-
# @return [
|
310
|
+
# @return [RepoSyncEvent]
|
233
311
|
def repo_sync_export(account_id, id, opts = {})
|
234
312
|
data, _status_code, _headers = repo_sync_export_with_http_info(account_id, id, opts)
|
235
313
|
data
|
@@ -241,7 +319,7 @@ module Phrase
|
|
241
319
|
# @param id [String] ID
|
242
320
|
# @param [Hash] opts the optional parameters
|
243
321
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
244
|
-
# @return [Array<(Response<(
|
322
|
+
# @return [Array<(Response<(RepoSyncEvent)>, Integer, Hash)>] Response<(RepoSyncEvent)> data, response status code and response headers
|
245
323
|
def repo_sync_export_with_http_info(account_id, id, opts = {})
|
246
324
|
if @api_client.config.debugging
|
247
325
|
@api_client.config.logger.debug 'Calling API: RepoSyncsApi.repo_sync_export ...'
|
@@ -273,7 +351,7 @@ module Phrase
|
|
273
351
|
post_body = opts[:body]
|
274
352
|
|
275
353
|
# return_type
|
276
|
-
return_type = opts[:return_type] || '
|
354
|
+
return_type = opts[:return_type] || 'RepoSyncEvent'
|
277
355
|
|
278
356
|
# auth_names
|
279
357
|
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
@@ -301,7 +379,7 @@ module Phrase
|
|
301
379
|
# @param id [String] ID
|
302
380
|
# @param [Hash] opts the optional parameters
|
303
381
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
304
|
-
# @return [
|
382
|
+
# @return [RepoSyncEvent]
|
305
383
|
def repo_sync_import(account_id, id, opts = {})
|
306
384
|
data, _status_code, _headers = repo_sync_import_with_http_info(account_id, id, opts)
|
307
385
|
data
|
@@ -313,7 +391,7 @@ module Phrase
|
|
313
391
|
# @param id [String] ID
|
314
392
|
# @param [Hash] opts the optional parameters
|
315
393
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
316
|
-
# @return [Array<(Response<(
|
394
|
+
# @return [Array<(Response<(RepoSyncEvent)>, Integer, Hash)>] Response<(RepoSyncEvent)> data, response status code and response headers
|
317
395
|
def repo_sync_import_with_http_info(account_id, id, opts = {})
|
318
396
|
if @api_client.config.debugging
|
319
397
|
@api_client.config.logger.debug 'Calling API: RepoSyncsApi.repo_sync_import ...'
|
@@ -345,7 +423,7 @@ module Phrase
|
|
345
423
|
post_body = opts[:body]
|
346
424
|
|
347
425
|
# return_type
|
348
|
-
return_type = opts[:return_type] || '
|
426
|
+
return_type = opts[:return_type] || 'RepoSyncEvent'
|
349
427
|
|
350
428
|
# auth_names
|
351
429
|
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
@@ -0,0 +1,285 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Phrase
|
4
|
+
class LocaleDownload
|
5
|
+
attr_accessor :id
|
6
|
+
|
7
|
+
# The status of the download request. Possible values are `processing`, `completed`, and `error`.
|
8
|
+
attr_accessor :status
|
9
|
+
|
10
|
+
attr_accessor :result
|
11
|
+
|
12
|
+
attr_accessor :params
|
13
|
+
|
14
|
+
attr_accessor :error
|
15
|
+
|
16
|
+
attr_accessor :created_at
|
17
|
+
|
18
|
+
attr_accessor :completed_at
|
19
|
+
|
20
|
+
class EnumAttributeValidator
|
21
|
+
attr_reader :datatype
|
22
|
+
attr_reader :allowable_values
|
23
|
+
|
24
|
+
def initialize(datatype, allowable_values)
|
25
|
+
@allowable_values = allowable_values.map do |value|
|
26
|
+
case datatype.to_s
|
27
|
+
when /Integer/i
|
28
|
+
value.to_i
|
29
|
+
when /Float/i
|
30
|
+
value.to_f
|
31
|
+
else
|
32
|
+
value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def valid?(value)
|
38
|
+
!value || allowable_values.include?(value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
43
|
+
def self.attribute_map
|
44
|
+
{
|
45
|
+
:'id' => :'id',
|
46
|
+
:'status' => :'status',
|
47
|
+
:'result' => :'result',
|
48
|
+
:'params' => :'params',
|
49
|
+
:'error' => :'error',
|
50
|
+
:'created_at' => :'created_at',
|
51
|
+
:'completed_at' => :'completed_at'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.openapi_types
|
57
|
+
{
|
58
|
+
:'id' => :'String',
|
59
|
+
:'status' => :'String',
|
60
|
+
:'result' => :'LocaleDownloadResult',
|
61
|
+
:'params' => :'LocaleDownloadParams',
|
62
|
+
:'error' => :'String',
|
63
|
+
:'created_at' => :'DateTime',
|
64
|
+
:'completed_at' => :'DateTime'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# List of attributes with nullable: true
|
69
|
+
def self.openapi_nullable
|
70
|
+
Set.new([
|
71
|
+
])
|
72
|
+
end
|
73
|
+
|
74
|
+
# Initializes the object
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
76
|
+
def initialize(attributes = {})
|
77
|
+
if (!attributes.is_a?(Hash))
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::LocaleDownload` initialize method"
|
79
|
+
end
|
80
|
+
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::LocaleDownload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
85
|
+
end
|
86
|
+
h[k.to_sym] = v
|
87
|
+
}
|
88
|
+
|
89
|
+
if attributes.key?(:'id')
|
90
|
+
self.id = attributes[:'id']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'status')
|
94
|
+
self.status = attributes[:'status']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'result')
|
98
|
+
self.result = attributes[:'result']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'params')
|
102
|
+
self.params = attributes[:'params']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'error')
|
106
|
+
self.error = attributes[:'error']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'created_at')
|
110
|
+
self.created_at = attributes[:'created_at']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'completed_at')
|
114
|
+
self.completed_at = attributes[:'completed_at']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
119
|
+
# @return Array for valid properties with the reasons
|
120
|
+
def list_invalid_properties
|
121
|
+
invalid_properties = Array.new
|
122
|
+
invalid_properties
|
123
|
+
end
|
124
|
+
|
125
|
+
# Check to see if the all the properties in the model are valid
|
126
|
+
# @return true if the model is valid
|
127
|
+
def valid?
|
128
|
+
status_validator = EnumAttributeValidator.new('String', ["processing", "completed", "error"])
|
129
|
+
return false unless status_validator.valid?(@status)
|
130
|
+
true
|
131
|
+
end
|
132
|
+
|
133
|
+
# Custom attribute writer method checking allowed values (enum).
|
134
|
+
# @param [Object] status Object to be assigned
|
135
|
+
def status=(status)
|
136
|
+
validator = EnumAttributeValidator.new('String', ["processing", "completed", "error"])
|
137
|
+
unless validator.valid?(status)
|
138
|
+
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
139
|
+
end
|
140
|
+
@status = status
|
141
|
+
end
|
142
|
+
|
143
|
+
# Checks equality by comparing each attribute.
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def ==(o)
|
146
|
+
return true if self.equal?(o)
|
147
|
+
self.class == o.class &&
|
148
|
+
id == o.id &&
|
149
|
+
status == o.status &&
|
150
|
+
result == o.result &&
|
151
|
+
params == o.params &&
|
152
|
+
error == o.error &&
|
153
|
+
created_at == o.created_at &&
|
154
|
+
completed_at == o.completed_at
|
155
|
+
end
|
156
|
+
|
157
|
+
# @see the `==` method
|
158
|
+
# @param [Object] Object to be compared
|
159
|
+
def eql?(o)
|
160
|
+
self == o
|
161
|
+
end
|
162
|
+
|
163
|
+
# Calculates hash code according to all attributes.
|
164
|
+
# @return [Integer] Hash code
|
165
|
+
def hash
|
166
|
+
[id, status, result, params, error, created_at, completed_at].hash
|
167
|
+
end
|
168
|
+
|
169
|
+
# Builds the object from hash
|
170
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
171
|
+
# @return [Object] Returns the model itself
|
172
|
+
def self.build_from_hash(attributes)
|
173
|
+
new.build_from_hash(attributes)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Builds the object from hash
|
177
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
178
|
+
# @return [Object] Returns the model itself
|
179
|
+
def build_from_hash(attributes)
|
180
|
+
return nil unless attributes.is_a?(Hash)
|
181
|
+
self.class.openapi_types.each_pair do |key, type|
|
182
|
+
if type =~ /\AArray<(.*)>/i
|
183
|
+
# check to ensure the input is an array given that the attribute
|
184
|
+
# is documented as an array but the input is not
|
185
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
186
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
187
|
+
end
|
188
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
189
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
190
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
191
|
+
end
|
192
|
+
|
193
|
+
self
|
194
|
+
end
|
195
|
+
|
196
|
+
# Deserializes the data based on type
|
197
|
+
# @param string type Data type
|
198
|
+
# @param string value Value to be deserialized
|
199
|
+
# @return [Object] Deserialized data
|
200
|
+
def _deserialize(type, value)
|
201
|
+
case type.to_sym
|
202
|
+
when :DateTime
|
203
|
+
DateTime.parse(value)
|
204
|
+
when :Date
|
205
|
+
Date.parse(value)
|
206
|
+
when :Time
|
207
|
+
Time.parse(value)
|
208
|
+
when :String
|
209
|
+
value.to_s
|
210
|
+
when :Integer
|
211
|
+
value.to_i
|
212
|
+
when :Float
|
213
|
+
value.to_f
|
214
|
+
when :Boolean
|
215
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
216
|
+
true
|
217
|
+
else
|
218
|
+
false
|
219
|
+
end
|
220
|
+
when :Object
|
221
|
+
# generic object (usually a Hash), return directly
|
222
|
+
value
|
223
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
224
|
+
inner_type = Regexp.last_match[:inner_type]
|
225
|
+
value.map { |v| _deserialize(inner_type, v) }
|
226
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
227
|
+
k_type = Regexp.last_match[:k_type]
|
228
|
+
v_type = Regexp.last_match[:v_type]
|
229
|
+
{}.tap do |hash|
|
230
|
+
value.each do |k, v|
|
231
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
else # model
|
235
|
+
Phrase.const_get(type).build_from_hash(value)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the string representation of the object
|
240
|
+
# @return [String] String presentation of the object
|
241
|
+
def to_s
|
242
|
+
to_hash.to_s
|
243
|
+
end
|
244
|
+
|
245
|
+
# to_body is an alias to to_hash (backward compatibility)
|
246
|
+
# @return [Hash] Returns the object in the form of hash
|
247
|
+
def to_body
|
248
|
+
to_hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns the object in the form of hash
|
252
|
+
# @return [Hash] Returns the object in the form of hash
|
253
|
+
def to_hash
|
254
|
+
hash = {}
|
255
|
+
self.class.attribute_map.each_pair do |attr, param|
|
256
|
+
value = self.send(attr)
|
257
|
+
if value.nil?
|
258
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
259
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
260
|
+
end
|
261
|
+
|
262
|
+
hash[param] = _to_hash(value)
|
263
|
+
end
|
264
|
+
hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Outputs non-array value in the form of hash
|
268
|
+
# For object, use to_hash. Otherwise, just return the value
|
269
|
+
# @param [Object] value Any valid value
|
270
|
+
# @return [Hash] Returns the value in the form of hash
|
271
|
+
def _to_hash(value)
|
272
|
+
if value.is_a?(Array)
|
273
|
+
value.compact.map { |v| _to_hash(v) }
|
274
|
+
elsif value.is_a?(Hash)
|
275
|
+
{}.tap do |hash|
|
276
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
277
|
+
end
|
278
|
+
elsif value.respond_to? :to_hash
|
279
|
+
value.to_hash
|
280
|
+
else
|
281
|
+
value
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|