1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
53
54
55
56
57
58
59
60
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
use std::collections::HashMap;
///!Locale
///!
///! The Locale service allows you to customize your app based on your users'
///! location.
use crate::{
app_json_header,
client::Client,
enumm::HttpMethod,
error::Error,
models::{
continent_list::ContinentList, country_list::CountryList, currency_list::CurrencyList,
language_list::LanguageList, locale::Locale as MLocale, locale_code::LocaleCode,
phone_list::PhoneList,
},
};
pub struct Locale;
impl Locale {
/// Get user locale
///
/// Get the current user location based on IP. Returns an object with user
/// country code, country name, continent name, continent code, ip address and
/// suggested currency. You can use the locale header to get the data in a
/// supported language.
///
/// ([IP Geolocation by DB-IP](https://db-ip.com))
pub async fn get(client: &Client) -> Result<MLocale, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List Locale Codes
///
/// List of all locale codes in [ISO
/// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
pub async fn list_codes(client: &Client) -> Result<LocaleCode, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/codes";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List continents
///
/// List of all continents. You can use the locale header to get the data in a
/// supported language.
pub async fn list_continents(client: &Client) -> Result<ContinentList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/continents";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List countries
///
/// List of all countries. You can use the locale header to get the data in a
/// supported language.
pub async fn list_countries(client: &Client) -> Result<CountryList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/countries";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List EU countries
///
/// List of all countries that are currently members of the EU. You can use the
/// locale header to get the data in a supported language.
pub async fn list_countries_eu(client: &Client) -> Result<CountryList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/countries/eu";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List countries phone codes
///
/// List of all countries phone codes. You can use the locale header to get the
/// data in a supported language.
pub async fn list_countries_phones(client: &Client) -> Result<PhoneList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/countries/phones";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List currencies
///
/// List of all currencies, including currency symbol, name, plural, and
/// decimal digits for all major and minor currencies. You can use the locale
/// header to get the data in a supported language.
pub async fn list_currencies(client: &Client) -> Result<CurrencyList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/currencies";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
/// List languages
///
/// List of all languages classified by ISO 639-1 including 2-letter code, name
/// in English, and name in the respective language.
pub async fn list_languages(client: &Client) -> Result<LanguageList, Error> {
//const API_PATH: &str = "/functions";
let api_path = "/locale/languages";
let args = HashMap::new();
let api_headers = app_json_header!();
let res = client
.call(HttpMethod::GET, api_path, api_headers, &args, None)
.await?;
Ok(res.json().await?)
}
}