OLD | NEW |
| 1 // This is a generated file (see the discoveryapis_generator project). |
| 2 |
1 library googleapis.translate.v2; | 3 library googleapis.translate.v2; |
2 | 4 |
3 import "dart:core" as core; | 5 import 'dart:core' as core; |
4 import "dart:collection" as collection; | 6 import 'dart:collection' as collection; |
5 import "dart:async" as async; | 7 import 'dart:async' as async; |
6 import "dart:convert" as convert; | 8 import 'dart:convert' as convert; |
7 | 9 |
8 import "package:crypto/crypto.dart" as crypto; | 10 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
| 11 import 'package:crypto/crypto.dart' as crypto; |
9 import 'package:http/http.dart' as http; | 12 import 'package:http/http.dart' as http; |
10 import '../src/common_internal.dart' as common_internal; | |
11 import '../common/common.dart' as common; | |
12 | 13 |
13 export '../common/common.dart' show ApiRequestError; | 14 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show |
14 export '../common/common.dart' show DetailedApiRequestError; | 15 ApiRequestError, DetailedApiRequestError; |
| 16 |
| 17 const core.String USER_AGENT = 'dart-api-client translate/v2'; |
15 | 18 |
16 /** Lets you translate text from one language to another */ | 19 /** Lets you translate text from one language to another */ |
17 class TranslateApi { | 20 class TranslateApi { |
18 | 21 |
19 final common_internal.ApiRequester _requester; | 22 final commons.ApiRequester _requester; |
20 | 23 |
21 DetectionsResourceApi get detections => new DetectionsResourceApi(_requester); | 24 DetectionsResourceApi get detections => new DetectionsResourceApi(_requester); |
22 LanguagesResourceApi get languages => new LanguagesResourceApi(_requester); | 25 LanguagesResourceApi get languages => new LanguagesResourceApi(_requester); |
23 TranslationsResourceApi get translations => new TranslationsResourceApi(_reque
ster); | 26 TranslationsResourceApi get translations => new TranslationsResourceApi(_reque
ster); |
24 | 27 |
25 TranslateApi(http.Client client, {core.String rootUrl: "https://www.googleapis
.com/", core.String servicePath: "language/translate/"}) : | 28 TranslateApi(http.Client client, {core.String rootUrl: "https://www.googleapis
.com/", core.String servicePath: "language/translate/"}) : |
26 _requester = new common_internal.ApiRequester(client, rootUrl, servicePath
); | 29 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); |
27 } | 30 } |
28 | 31 |
29 | 32 |
30 /** Not documented yet. */ | |
31 class DetectionsResourceApi { | 33 class DetectionsResourceApi { |
32 final common_internal.ApiRequester _requester; | 34 final commons.ApiRequester _requester; |
33 | 35 |
34 DetectionsResourceApi(common_internal.ApiRequester client) : | 36 DetectionsResourceApi(commons.ApiRequester client) : |
35 _requester = client; | 37 _requester = client; |
36 | 38 |
37 /** | 39 /** |
38 * Detect the language of text. | 40 * Detect the language of text. |
39 * | 41 * |
40 * Request parameters: | 42 * Request parameters: |
41 * | 43 * |
42 * [q] - The text to detect | 44 * [q] - The text to detect |
43 * | 45 * |
44 * Completes with a [DetectionsListResponse]. | 46 * Completes with a [DetectionsListResponse]. |
45 * | 47 * |
46 * Completes with a [common.ApiRequestError] if the API endpoint returned an | 48 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
47 * error. | 49 * error. |
48 * | 50 * |
49 * If the used [http.Client] completes with an error when making a REST call, | 51 * If the used [http.Client] completes with an error when making a REST call, |
50 * this method will complete with the same error. | 52 * this method will complete with the same error. |
51 */ | 53 */ |
52 async.Future<DetectionsListResponse> list(core.List<core.String> q) { | 54 async.Future<DetectionsListResponse> list(core.List<core.String> q) { |
53 var _url = null; | 55 var _url = null; |
54 var _queryParams = new core.Map(); | 56 var _queryParams = new core.Map(); |
55 var _uploadMedia = null; | 57 var _uploadMedia = null; |
56 var _uploadOptions = null; | 58 var _uploadOptions = null; |
57 var _downloadOptions = common.DownloadOptions.Metadata; | 59 var _downloadOptions = commons.DownloadOptions.Metadata; |
58 var _body = null; | 60 var _body = null; |
59 | 61 |
60 if (q == null || q.isEmpty) { | 62 if (q == null || q.isEmpty) { |
61 throw new core.ArgumentError("Parameter q is required."); | 63 throw new core.ArgumentError("Parameter q is required."); |
62 } | 64 } |
63 _queryParams["q"] = q; | 65 _queryParams["q"] = q; |
64 | 66 |
65 | 67 |
66 _url = 'v2/detect'; | 68 _url = 'v2/detect'; |
67 | 69 |
68 var _response = _requester.request(_url, | 70 var _response = _requester.request(_url, |
69 "GET", | 71 "GET", |
70 body: _body, | 72 body: _body, |
71 queryParams: _queryParams, | 73 queryParams: _queryParams, |
72 uploadOptions: _uploadOptions, | 74 uploadOptions: _uploadOptions, |
73 uploadMedia: _uploadMedia, | 75 uploadMedia: _uploadMedia, |
74 downloadOptions: _downloadOptions); | 76 downloadOptions: _downloadOptions); |
75 return _response.then((data) => new DetectionsListResponse.fromJson(data)); | 77 return _response.then((data) => new DetectionsListResponse.fromJson(data)); |
76 } | 78 } |
77 | 79 |
78 } | 80 } |
79 | 81 |
80 | 82 |
81 /** Not documented yet. */ | |
82 class LanguagesResourceApi { | 83 class LanguagesResourceApi { |
83 final common_internal.ApiRequester _requester; | 84 final commons.ApiRequester _requester; |
84 | 85 |
85 LanguagesResourceApi(common_internal.ApiRequester client) : | 86 LanguagesResourceApi(commons.ApiRequester client) : |
86 _requester = client; | 87 _requester = client; |
87 | 88 |
88 /** | 89 /** |
89 * List the source/target languages supported by the API | 90 * List the source/target languages supported by the API |
90 * | 91 * |
91 * Request parameters: | 92 * Request parameters: |
92 * | 93 * |
93 * [target] - the language and collation in which the localized results should | 94 * [target] - the language and collation in which the localized results should |
94 * be returned | 95 * be returned |
95 * | 96 * |
96 * Completes with a [LanguagesListResponse]. | 97 * Completes with a [LanguagesListResponse]. |
97 * | 98 * |
98 * Completes with a [common.ApiRequestError] if the API endpoint returned an | 99 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
99 * error. | 100 * error. |
100 * | 101 * |
101 * If the used [http.Client] completes with an error when making a REST call, | 102 * If the used [http.Client] completes with an error when making a REST call, |
102 * this method will complete with the same error. | 103 * this method will complete with the same error. |
103 */ | 104 */ |
104 async.Future<LanguagesListResponse> list({core.String target}) { | 105 async.Future<LanguagesListResponse> list({core.String target}) { |
105 var _url = null; | 106 var _url = null; |
106 var _queryParams = new core.Map(); | 107 var _queryParams = new core.Map(); |
107 var _uploadMedia = null; | 108 var _uploadMedia = null; |
108 var _uploadOptions = null; | 109 var _uploadOptions = null; |
109 var _downloadOptions = common.DownloadOptions.Metadata; | 110 var _downloadOptions = commons.DownloadOptions.Metadata; |
110 var _body = null; | 111 var _body = null; |
111 | 112 |
112 if (target != null) { | 113 if (target != null) { |
113 _queryParams["target"] = [target]; | 114 _queryParams["target"] = [target]; |
114 } | 115 } |
115 | 116 |
116 | 117 |
117 _url = 'v2/languages'; | 118 _url = 'v2/languages'; |
118 | 119 |
119 var _response = _requester.request(_url, | 120 var _response = _requester.request(_url, |
120 "GET", | 121 "GET", |
121 body: _body, | 122 body: _body, |
122 queryParams: _queryParams, | 123 queryParams: _queryParams, |
123 uploadOptions: _uploadOptions, | 124 uploadOptions: _uploadOptions, |
124 uploadMedia: _uploadMedia, | 125 uploadMedia: _uploadMedia, |
125 downloadOptions: _downloadOptions); | 126 downloadOptions: _downloadOptions); |
126 return _response.then((data) => new LanguagesListResponse.fromJson(data)); | 127 return _response.then((data) => new LanguagesListResponse.fromJson(data)); |
127 } | 128 } |
128 | 129 |
129 } | 130 } |
130 | 131 |
131 | 132 |
132 /** Not documented yet. */ | |
133 class TranslationsResourceApi { | 133 class TranslationsResourceApi { |
134 final common_internal.ApiRequester _requester; | 134 final commons.ApiRequester _requester; |
135 | 135 |
136 TranslationsResourceApi(common_internal.ApiRequester client) : | 136 TranslationsResourceApi(commons.ApiRequester client) : |
137 _requester = client; | 137 _requester = client; |
138 | 138 |
139 /** | 139 /** |
140 * Returns text translations from one language to another. | 140 * Returns text translations from one language to another. |
141 * | 141 * |
142 * Request parameters: | 142 * Request parameters: |
143 * | 143 * |
144 * [q] - The text to translate | 144 * [q] - The text to translate |
145 * | 145 * |
146 * [target] - The target language into which the text should be translated | 146 * [target] - The target language into which the text should be translated |
147 * | 147 * |
148 * [cid] - The customization id for translate | 148 * [cid] - The customization id for translate |
149 * | 149 * |
150 * [format] - The format of the text | 150 * [format] - The format of the text |
151 * Possible string values are: | 151 * Possible string values are: |
152 * - "html" : Specifies the input is in HTML | 152 * - "html" : Specifies the input is in HTML |
153 * - "text" : Specifies the input is in plain textual format | 153 * - "text" : Specifies the input is in plain textual format |
154 * | 154 * |
155 * [source] - The source language of the text | 155 * [source] - The source language of the text |
156 * | 156 * |
157 * Completes with a [TranslationsListResponse]. | 157 * Completes with a [TranslationsListResponse]. |
158 * | 158 * |
159 * Completes with a [common.ApiRequestError] if the API endpoint returned an | 159 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
160 * error. | 160 * error. |
161 * | 161 * |
162 * If the used [http.Client] completes with an error when making a REST call, | 162 * If the used [http.Client] completes with an error when making a REST call, |
163 * this method will complete with the same error. | 163 * this method will complete with the same error. |
164 */ | 164 */ |
165 async.Future<TranslationsListResponse> list(core.List<core.String> q, core.Str
ing target, {core.List<core.String> cid, core.String format, core.String source}
) { | 165 async.Future<TranslationsListResponse> list(core.List<core.String> q, core.Str
ing target, {core.List<core.String> cid, core.String format, core.String source}
) { |
166 var _url = null; | 166 var _url = null; |
167 var _queryParams = new core.Map(); | 167 var _queryParams = new core.Map(); |
168 var _uploadMedia = null; | 168 var _uploadMedia = null; |
169 var _uploadOptions = null; | 169 var _uploadOptions = null; |
170 var _downloadOptions = common.DownloadOptions.Metadata; | 170 var _downloadOptions = commons.DownloadOptions.Metadata; |
171 var _body = null; | 171 var _body = null; |
172 | 172 |
173 if (q == null || q.isEmpty) { | 173 if (q == null || q.isEmpty) { |
174 throw new core.ArgumentError("Parameter q is required."); | 174 throw new core.ArgumentError("Parameter q is required."); |
175 } | 175 } |
176 _queryParams["q"] = q; | 176 _queryParams["q"] = q; |
177 if (target == null) { | 177 if (target == null) { |
178 throw new core.ArgumentError("Parameter target is required."); | 178 throw new core.ArgumentError("Parameter target is required."); |
179 } | 179 } |
180 _queryParams["target"] = [target]; | 180 _queryParams["target"] = [target]; |
(...skipping 17 matching lines...) Expand all Loading... |
198 uploadOptions: _uploadOptions, | 198 uploadOptions: _uploadOptions, |
199 uploadMedia: _uploadMedia, | 199 uploadMedia: _uploadMedia, |
200 downloadOptions: _downloadOptions); | 200 downloadOptions: _downloadOptions); |
201 return _response.then((data) => new TranslationsListResponse.fromJson(data))
; | 201 return _response.then((data) => new TranslationsListResponse.fromJson(data))
; |
202 } | 202 } |
203 | 203 |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 | 207 |
208 /** Not documented yet. */ | |
209 class DetectionsListResponse { | 208 class DetectionsListResponse { |
210 /** A detections contains detection results of several text */ | 209 /** A detections contains detection results of several text */ |
211 core.List<DetectionsResource> detections; | 210 core.List<DetectionsResource> detections; |
212 | 211 |
213 | 212 |
214 DetectionsListResponse(); | 213 DetectionsListResponse(); |
215 | 214 |
216 DetectionsListResponse.fromJson(core.Map _json) { | 215 DetectionsListResponse.fromJson(core.Map _json) { |
217 if (_json.containsKey("detections")) { | 216 if (_json.containsKey("detections")) { |
218 detections = _json["detections"].map((value) => new DetectionsResource.fro
mJson(value)).toList(); | 217 detections = _json["detections"].map((value) => new DetectionsResource.fro
mJson(value)).toList(); |
219 } | 218 } |
220 } | 219 } |
221 | 220 |
222 core.Map toJson() { | 221 core.Map toJson() { |
223 var _json = new core.Map(); | 222 var _json = new core.Map(); |
224 if (detections != null) { | 223 if (detections != null) { |
225 _json["detections"] = detections.map((value) => (value).toJson()).toList()
; | 224 _json["detections"] = detections.map((value) => (value).toJson()).toList()
; |
226 } | 225 } |
227 return _json; | 226 return _json; |
228 } | 227 } |
229 } | 228 } |
230 | 229 |
231 | 230 |
232 /** Not documented yet. */ | |
233 class DetectionsResourceElement { | 231 class DetectionsResourceElement { |
234 /** The confidence of the detection resul of this language. */ | 232 /** The confidence of the detection resul of this language. */ |
235 core.double confidence; | 233 core.double confidence; |
236 | 234 |
237 /** A boolean to indicate is the language detection result reliable. */ | 235 /** A boolean to indicate is the language detection result reliable. */ |
238 core.bool isReliable; | 236 core.bool isReliable; |
239 | 237 |
240 /** The language we detect */ | 238 /** The language we detect */ |
241 core.String language; | 239 core.String language; |
242 | 240 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 293 } |
296 | 294 |
297 core.int get length => _inner.length; | 295 core.int get length => _inner.length; |
298 | 296 |
299 void set length(core.int newLength) { | 297 void set length(core.int newLength) { |
300 _inner.length = newLength; | 298 _inner.length = newLength; |
301 } | 299 } |
302 } | 300 } |
303 | 301 |
304 | 302 |
305 /** Not documented yet. */ | |
306 class LanguagesListResponse { | 303 class LanguagesListResponse { |
307 /** | 304 /** |
308 * List of source/target languages supported by the translation API. If target | 305 * List of source/target languages supported by the translation API. If target |
309 * parameter is unspecified, the list is sorted by the ASCII code point order | 306 * parameter is unspecified, the list is sorted by the ASCII code point order |
310 * of the language code. If target parameter is specified, the list is sorted | 307 * of the language code. If target parameter is specified, the list is sorted |
311 * by the collation order of the language name in the target language. | 308 * by the collation order of the language name in the target language. |
312 */ | 309 */ |
313 core.List<LanguagesResource> languages; | 310 core.List<LanguagesResource> languages; |
314 | 311 |
315 | 312 |
316 LanguagesListResponse(); | 313 LanguagesListResponse(); |
317 | 314 |
318 LanguagesListResponse.fromJson(core.Map _json) { | 315 LanguagesListResponse.fromJson(core.Map _json) { |
319 if (_json.containsKey("languages")) { | 316 if (_json.containsKey("languages")) { |
320 languages = _json["languages"].map((value) => new LanguagesResource.fromJs
on(value)).toList(); | 317 languages = _json["languages"].map((value) => new LanguagesResource.fromJs
on(value)).toList(); |
321 } | 318 } |
322 } | 319 } |
323 | 320 |
324 core.Map toJson() { | 321 core.Map toJson() { |
325 var _json = new core.Map(); | 322 var _json = new core.Map(); |
326 if (languages != null) { | 323 if (languages != null) { |
327 _json["languages"] = languages.map((value) => (value).toJson()).toList(); | 324 _json["languages"] = languages.map((value) => (value).toJson()).toList(); |
328 } | 325 } |
329 return _json; | 326 return _json; |
330 } | 327 } |
331 } | 328 } |
332 | 329 |
333 | 330 |
334 /** Not documented yet. */ | |
335 class LanguagesResource { | 331 class LanguagesResource { |
336 /** The language code. */ | 332 /** The language code. */ |
337 core.String language; | 333 core.String language; |
338 | 334 |
339 /** The localized name of the language if target parameter is given. */ | 335 /** The localized name of the language if target parameter is given. */ |
340 core.String name; | 336 core.String name; |
341 | 337 |
342 | 338 |
343 LanguagesResource(); | 339 LanguagesResource(); |
344 | 340 |
(...skipping 12 matching lines...) Expand all Loading... |
357 _json["language"] = language; | 353 _json["language"] = language; |
358 } | 354 } |
359 if (name != null) { | 355 if (name != null) { |
360 _json["name"] = name; | 356 _json["name"] = name; |
361 } | 357 } |
362 return _json; | 358 return _json; |
363 } | 359 } |
364 } | 360 } |
365 | 361 |
366 | 362 |
367 /** Not documented yet. */ | |
368 class TranslationsListResponse { | 363 class TranslationsListResponse { |
369 /** Translations contains list of translation results of given text */ | 364 /** Translations contains list of translation results of given text */ |
370 core.List<TranslationsResource> translations; | 365 core.List<TranslationsResource> translations; |
371 | 366 |
372 | 367 |
373 TranslationsListResponse(); | 368 TranslationsListResponse(); |
374 | 369 |
375 TranslationsListResponse.fromJson(core.Map _json) { | 370 TranslationsListResponse.fromJson(core.Map _json) { |
376 if (_json.containsKey("translations")) { | 371 if (_json.containsKey("translations")) { |
377 translations = _json["translations"].map((value) => new TranslationsResour
ce.fromJson(value)).toList(); | 372 translations = _json["translations"].map((value) => new TranslationsResour
ce.fromJson(value)).toList(); |
378 } | 373 } |
379 } | 374 } |
380 | 375 |
381 core.Map toJson() { | 376 core.Map toJson() { |
382 var _json = new core.Map(); | 377 var _json = new core.Map(); |
383 if (translations != null) { | 378 if (translations != null) { |
384 _json["translations"] = translations.map((value) => (value).toJson()).toLi
st(); | 379 _json["translations"] = translations.map((value) => (value).toJson()).toLi
st(); |
385 } | 380 } |
386 return _json; | 381 return _json; |
387 } | 382 } |
388 } | 383 } |
389 | 384 |
390 | 385 |
391 /** Not documented yet. */ | |
392 class TranslationsResource { | 386 class TranslationsResource { |
393 /** Detected source language if source parameter is unspecified. */ | 387 /** Detected source language if source parameter is unspecified. */ |
394 core.String detectedSourceLanguage; | 388 core.String detectedSourceLanguage; |
395 | 389 |
396 /** The translation. */ | 390 /** The translation. */ |
397 core.String translatedText; | 391 core.String translatedText; |
398 | 392 |
399 | 393 |
400 TranslationsResource(); | 394 TranslationsResource(); |
401 | 395 |
(...skipping 10 matching lines...) Expand all Loading... |
412 var _json = new core.Map(); | 406 var _json = new core.Map(); |
413 if (detectedSourceLanguage != null) { | 407 if (detectedSourceLanguage != null) { |
414 _json["detectedSourceLanguage"] = detectedSourceLanguage; | 408 _json["detectedSourceLanguage"] = detectedSourceLanguage; |
415 } | 409 } |
416 if (translatedText != null) { | 410 if (translatedText != null) { |
417 _json["translatedText"] = translatedText; | 411 _json["translatedText"] = translatedText; |
418 } | 412 } |
419 return _json; | 413 return _json; |
420 } | 414 } |
421 } | 415 } |
422 | |
423 | |
OLD | NEW |