1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00
appwrite/public/sdk-console/services/locale.ts
2022-09-20 14:07:51 +05:30

151 lines
4.9 KiB
TypeScript

import { Service } from '../service';
import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
export class Locale extends Service {
constructor(client: Client)
{
super(client);
}
/**
* 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))
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async get(): Promise<Models.Locale> {
let path = '/locale';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* List Continents
*
* List of all continents. You can use the locale header to get the data in a
* supported language.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listContinents(): Promise<Models.ContinentList> {
let path = '/locale/continents';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* List Countries
*
* List of all countries. You can use the locale header to get the data in a
* supported language.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listCountries(): Promise<Models.CountryList> {
let path = '/locale/countries';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* 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.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listCountriesEU(): Promise<Models.CountryList> {
let path = '/locale/countries/eu';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* List Countries Phone Codes
*
* List of all countries phone codes. You can use the locale header to get the
* data in a supported language.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listCountriesPhones(): Promise<Models.PhoneList> {
let path = '/locale/countries/phones';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* 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.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listCurrencies(): Promise<Models.CurrencyList> {
let path = '/locale/currencies';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
/**
* List Languages
*
* List of all languages classified by ISO 639-1 including 2-letter code, name
* in English, and name in the respective language.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listLanguages(): Promise<Models.LanguageList> {
let path = '/locale/languages';
let payload: Payload = {};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}
};