Class: TranslationApiClient::TranslationApi
- Defined in:
- lib/translationApi_client/api/translation_api.rb
Class Method Summary collapse
-
.translation_profile_get(opts = {}) ⇒ ProfilesResponse
List of profiles List of profiles available for translation.n.
-
.translation_supported_languages_get(opts = {}) ⇒ SupportedLanguageResponse
Supported Languages List of language pairs in which translation is supported.nnThis list can be limited to a specific source language or target language.n.
-
.translation_translate_cancel_get(request_id, opts = {}) ⇒ TranslationCancel
Translate Cancel Cancel an asynchronous translation requestn.
-
.translation_translate_file_get(input, target, opts = {}) ⇒ file
Translate file Translate a file from source language to target languagennn* In asynchronous mode (async=true), the response will be a JSON containing a request identifier.
-
.translation_translate_get(input, target, opts = {}) ⇒ TranslationResponse
Translate Translate text from source language to target languagen.
-
.translation_translate_result_get(request_id, opts = {}) ⇒ TranslationResponse
Translate Result Get the result of an asynchronous translation requestnnDepending on the initial request, the response can have multiple formats:n* ‘/translation/translate` initiated requestnn → the response will be a JSON document (model below)nn* `/translation/translate/file` initiated requestnn → the response will be either:nn * The **translated document**, directly, if `source` parameters was not `auto` and `withSource` was not truen * A `multipart/mixed` document with the following parts:nn 1.
-
.translation_translate_status_get(request_id, opts = {}) ⇒ TranslationStatus
Translate Status Get the status of an asynchronous translation requestnnThe translation result is available when the value of the status field is ‘finished`.nnThe translation request is unsuccessful when the value of the status field is `error`.n.
Class Method Details
.translation_profile_get(opts = {}) ⇒ ProfilesResponse
List of profiles List of profiles available for translation.n
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/translationApi_client/api/translation_api.rb', line 18 def self.translation_profile_get(opts = {}) # resource path path = "/translation/profile".sub('{format}','json') # query parameters query_params = {} query_params[:'source'] = opts[:'source'] if opts[:'source'] query_params[:'target'] = opts[:'target'] if opts[:'target'] query_params[:'id'] = opts[:'id'] if opts[:'id'] query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = ProfilesResponse.new() and obj.build_from_hash(response) end |
.translation_supported_languages_get(opts = {}) ⇒ SupportedLanguageResponse
Supported Languages List of language pairs in which translation is supported.nnThis list can be limited to a specific source language or target language.n
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/translationApi_client/api/translation_api.rb', line 61 def self.translation_supported_languages_get(opts = {}) # resource path path = "/translation/supportedLanguages".sub('{format}','json') # query parameters query_params = {} query_params[:'source'] = opts[:'source'] if opts[:'source'] query_params[:'target'] = opts[:'target'] if opts[:'target'] query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = SupportedLanguageResponse.new() and obj.build_from_hash(response) end |
.translation_translate_cancel_get(request_id, opts = {}) ⇒ TranslationCancel
Translate Cancel Cancel an asynchronous translation requestn
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/translationApi_client/api/translation_api.rb', line 170 def self.translation_translate_cancel_get(request_id, opts = {}) # verify the required parameter 'request_id' is set raise "Missing the required parameter 'request_id' when calling translation_translate_cancel_get" if request_id.nil? # resource path path = "/translation/file/cancel".sub('{format}','json') # query parameters query_params = {} query_params[:'requestId'] = request_id query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = TranslationCancel.new() and obj.build_from_hash(response) end |
.translation_translate_file_get(input, target, opts = {}) ⇒ file
Translate file Translate a file from source language to target languagennn* In asynchronous mode (async=true), the response will be a JSON containing a request identifier. This identifier can then be used to poll the request status and its result when completed.nn “‘n {n "requestId": "54a3d860e62ea467b136eddb" /* Request identifier to use to get the status,n the result of the request and to cancel it */n "error": "", /* Error at request level */n }n “`nn* In synchronous mode, the response will be either:nn * The **translated document**, directly, if `source` parameters was not `auto` and `withSource` was not truen * A `multipart/mixed` document with the following parts:nn 1. **Detected language**, if request was done with `auto` source languagenn * Header:nn `part-name: detectedLanguage`nn * Body: JSON documentn “`n {n detectedLanguage: "string"n detectedLanguageConfidence : numbern }n “`nn 2. **Source document**, if request was done with `withSource`:nn * Header: `part-name: source`n * Body: Source documentnn 3. **Translated document**nn * Header: `part-name: output`nn * Body: Translated documentn
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/translationApi_client/api/translation_api.rb', line 223 def self.translation_translate_file_get(input, target, opts = {}) # verify the required parameter 'input' is set raise "Missing the required parameter 'input' when calling translation_translate_file_get" if input.nil? # verify the required parameter 'target' is set raise "Missing the required parameter 'target' when calling translation_translate_file_get" if target.nil? # resource path path = "/translation/file/translate".sub('{format}','json') # query parameters query_params = {} query_params[:'target'] = target query_params[:'source'] = opts[:'source'] if opts[:'source'] query_params[:'format'] = opts[:'format'] if opts[:'format'] query_params[:'profile'] = opts[:'profile'] if opts[:'profile'] query_params[:'withSource'] = opts[:'with_source'] if opts[:'with_source'] query_params[:'withAnnotations'] = opts[:'with_annotations'] if opts[:'with_annotations'] query_params[:'withDictionary'] = opts[:'with_dictionary'] if opts[:'with_dictionary'] query_params[:'options'] = opts[:'options'] if opts[:'options'] query_params[:'encoding'] = opts[:'encoding'] if opts[:'encoding'] query_params[:'async'] = opts[:'async'] if opts[:'async'] query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json', 'multipart/mixed', '*/*'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = ['multipart/form-data', 'application/x-www-form-urlencoded', '*/*'] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} form_params["input"] = input # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body if query_params[:'async'] OpenStruct.new(response) else response end end |
.translation_translate_get(input, target, opts = {}) ⇒ TranslationResponse
Translate Translate text from source language to target languagen
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/translationApi_client/api/translation_api.rb', line 113 def self.translation_translate_get(input, target, opts = {}) # verify the required parameter 'input' is set raise "Missing the required parameter 'input' when calling translation_translate_get" if input.nil? # verify the required parameter 'target' is set raise "Missing the required parameter 'target' when calling translation_translate_get" if target.nil? # resource path path = "/translation/text/translate".sub('{format}','json') # query parameters query_params = {} query_params[:'input'] = input query_params[:'target'] = target query_params[:'source'] = opts[:'source'] if opts[:'source'] query_params[:'format'] = opts[:'format'] if opts[:'format'] query_params[:'profile'] = opts[:'profile'] if opts[:'profile'] query_params[:'withSource'] = opts[:'with_source'] if opts[:'with_source'] query_params[:'withAnnotations'] = opts[:'with_annotations'] if opts[:'with_annotations'] query_params[:'withDictionary'] = opts[:'with_dictionary'] if opts[:'with_dictionary'] query_params[:'backTranslation'] = opts[:'back_translation'] if opts[:'back_translation'] query_params[:'options'] = opts[:'options'] if opts[:'options'] query_params[:'encoding'] = opts[:'encoding'] if opts[:'encoding'] #query_params[:'async'] = opts[:'async'] if opts[:'async'] query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = TranslationResponse.new() and obj.build_from_hash(response) end |
.translation_translate_result_get(request_id, opts = {}) ⇒ TranslationResponse
Translate Result Get the result of an asynchronous translation requestnnDepending on the initial request, the response can have multiple formats:n* ‘/translation/translate` initiated requestnn → the response will be a JSON document (model below)nn* `/translation/translate/file` initiated requestnn → the response will be either:nn * The **translated document**, directly, if `source` parameters was not `auto` and `withSource` was not truen * A `multipart/mixed` document with the following parts:nn 1. **Detected language**, if request was done with `auto` source languagenn * Header:nn `part-name: detectedLanguage`nn * Body: JSON documentn “`n {n detectedLanguage: "string"n detectedLanguageConfidence : numbern }n “`nn 2. **Source document**, if request was done with `withSource`:nn * Header: `part-name: source`n * Body: Source documentnn 3. **Translated document**nn * Header: `part-name: output`nn * Body: Translated documentnnAn error can occur in the following cases:n* Invalid request IDn* No result available (see request status for more information)n* Unable to retrieve the resultn* …n
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/translationApi_client/api/translation_api.rb', line 283 def self.translation_translate_result_get(request_id, opts = {}) # verify the required parameter 'request_id' is set raise "Missing the required parameter 'request_id' when calling translation_translate_result_get" if request_id.nil? # resource path path = "/translation/file/result".sub('{format}','json') # query parameters query_params = {} query_params[:'requestId'] = request_id query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json', 'multipart/mixed', '*/*'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = TranslationResponse.new() and obj.build_from_hash(response) end |
.translation_translate_status_get(request_id, opts = {}) ⇒ TranslationStatus
Translate Status Get the status of an asynchronous translation requestnnThe translation result is available when the value of the status field is ‘finished`.nnThe translation request is unsuccessful when the value of the status field is `error`.n
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/translationApi_client/api/translation_api.rb', line 326 def self.translation_translate_status_get(request_id, opts = {}) # verify the required parameter 'request_id' is set raise "Missing the required parameter 'request_id' when calling translation_translate_status_get" if request_id.nil? # resource path path = "/translation/file/status".sub('{format}','json') # query parameters query_params = {} query_params[:'requestId'] = request_id query_params[:'callback'] = opts[:'callback'] if opts[:'callback'] # header parameters header_params = {} # HTTP header 'Accept' (if needed) _header_accept = ['application/json'] _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result # HTTP header 'Content-Type' _header_content_type = [] header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken', 'apiKey'] response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body obj = TranslationStatus.new() and obj.build_from_hash(response) end |