node-appwrite
Version:
Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
170 lines (149 loc) • 4.52 kB
JavaScript
const Service = require('../service.js');
const AppwriteException = require('../exception.js');
const InputFile = require('../inputFile.js');
const client = require('../client.js');
const Stream = require('stream');
const { promisify } = require('util');
const fs = require('fs');
const { File } = require('undici');
const Query = require('../query.js');
class Locale extends Service {
constructor(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() {
const apiPath = '/locale';
let payload = {};
return await this.client.call('get', apiPath, {
'content-type': 'application/json',
}, payload);
}
/**
* List Locale Codes
*
* List of all locale codes in [ISO
* 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
*
* @throws {AppwriteException}
* @returns {Promise}
*/
async listCodes() {
const apiPath = '/locale/codes';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/continents';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/countries';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/countries/eu';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/countries/phones';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/currencies';
let payload = {};
return await this.client.call('get', apiPath, {
'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() {
const apiPath = '/locale/languages';
let payload = {};
return await this.client.call('get', apiPath, {
'content-type': 'application/json',
}, payload);
}
}
module.exports = Locale;