google_api_rust_client_unoffical/services/translate_service/
mod.rs1
2pub mod translate_text;
3pub mod list_languages;
4pub mod detect_language;
5
6
7use crate::auth::service_account::ServiceAccountCredentials;
8use super::ServiceBase;
9
10
11static TRANSLATE_SERVICE_SCOPE: &str = "https://www.googleapis.com/auth/cloud-translation";
12static TRANSLATE_SERVICE_BASE_URL: &str = "https://translation.googleapis.com/language/translate";
13
14#[derive(Debug, Clone)]
15pub struct TranslateService {
16 base: ServiceBase
17}
18
19
20impl TranslateService {
21 pub fn new_with_api_key(api_key: String) -> Self {
25 return Self { base: ServiceBase::new_with_api_key(api_key) }
26 }
27
28 pub fn new_with_credentials(service_account_credentials: ServiceAccountCredentials) -> Self {
32 return Self { base: ServiceBase::new_with_credentials(service_account_credentials, vec![TRANSLATE_SERVICE_SCOPE]) }
33 }
34}
35
36enum TranslateServiceV2Type {
37 Translate,
38 Detect,
39 Languages
40}
41
42impl TranslateServiceV2Type {
43 fn path(&self) -> &str {
44 match *self {
45 TranslateServiceV2Type::Translate => "",
46 TranslateServiceV2Type::Detect => "detect",
47 TranslateServiceV2Type::Languages => "languages"
48 }
49 }
50}