translate method
Translate a text.
Returns a Future containing a DynamiteResponse with the status code, deserialized body and headers. Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
text
Text to be translated.fromLanguage
Language to translate from.toLanguage
Language to translate to.oCSAPIRequest
Required to be true for the API request to pass. Defaults totrue
.
Status codes:
- 200: Translated text returned
- 400: Language not detected or unable to translate
- 412: Translating is not possible
- 500
See:
- translateRaw for an experimental operation that returns a DynamiteRawResponse that can be serialized.
Implementation
Future<DynamiteResponse<TranslationApiTranslateResponseApplicationJson, void>> translate({
required String text,
required String toLanguage,
String? fromLanguage,
bool? oCSAPIRequest,
}) async {
final rawResponse = translateRaw(
text: text,
toLanguage: toLanguage,
fromLanguage: fromLanguage,
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}