@nativestudios/creace-core
Advanced tools
Comparing version 0.0.14 to 0.0.15
import DeviceInfo from 'react-native-device-info'; | ||
import * as RNLocalize from 'react-native-localize'; | ||
import { CreaceConfig } from '../Config'; | ||
import { Api } from './Api'; | ||
const DEFAULT_DATA = { | ||
id: DeviceInfo.getUniqueID(), | ||
manufacturer: DeviceInfo.getManufacturer(), | ||
model: DeviceInfo.getModel(), | ||
system_name: DeviceInfo.getSystemName(), | ||
system_version: DeviceInfo.getSystemVersion(), | ||
bundleId: DeviceInfo.getBundleId(), | ||
version: DeviceInfo.getReadableVersion(), | ||
locale: DeviceInfo.getDeviceLocale().toLowerCase(), | ||
country: DeviceInfo.getDeviceCountry().toUpperCase(), | ||
push_token: null | ||
}; | ||
class _DeviceApi extends Api { | ||
async getDefaultData() { | ||
const locales = RNLocalize.getLocales(); | ||
const locale = !locales.length ? 'en' : locales[0].languageCode; | ||
return { | ||
id: await DeviceInfo.getUniqueId(), | ||
manufacturer: await DeviceInfo.getManufacturer(), | ||
model: await DeviceInfo.getModel(), | ||
system_name: await DeviceInfo.getSystemName(), | ||
system_version: await DeviceInfo.getSystemVersion(), | ||
bundle_id: await DeviceInfo.getSystemVersion(), | ||
version: await DeviceInfo.getReadableVersion(), | ||
locale: locale, | ||
country: RNLocalize.getCountry().toUpperCase() | ||
}; | ||
} | ||
async register(data = {}) { | ||
const device = Object.assign({}, DEFAULT_DATA, data); | ||
const defaultData = await this.getDefaultData(); | ||
const device = Object.assign({}, defaultData, data); | ||
device.locale = device.locale.split('-')[0]; | ||
@@ -27,3 +33,3 @@ const body = { | ||
system_version: device.system_version, | ||
bundle_id: device.bundleId, | ||
bundle_id: device.bundle_id, | ||
version: device.version, | ||
@@ -30,0 +36,0 @@ locale: device.locale, |
{ | ||
"name": "@nativestudios/creace-core", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Creace Core", | ||
@@ -31,3 +31,4 @@ "keywords": [ | ||
"react-native": "*", | ||
"react-native-device-info": "*", | ||
"react-native-device-info": "^3.0.0", | ||
"react-native-localize": "^1.2.0", | ||
"rn-fetch-blob": "*" | ||
@@ -40,3 +41,3 @@ }, | ||
}, | ||
"gitHead": "8a3cc43ddca626e818896306ff000a97f5063078" | ||
"gitHead": "deddd5f825a636e5d1190470dfa2e3233ff36443" | ||
} |
@@ -8,3 +8,3 @@ // @flow | ||
system_version: string; | ||
bundleId: string; | ||
bundle_id: string; | ||
version: string; | ||
@@ -11,0 +11,0 @@ locale: string; |
29035
1099
5