Protótipo Vilacorp
This commit is contained in:
+50
-58
@@ -6,52 +6,49 @@ import 'dart:io';
|
||||
|
||||
import 'default_response_api.dart';
|
||||
|
||||
class FuncoesGerais{
|
||||
|
||||
class FuncoesGerais {
|
||||
//static const String urlLexLiteApi = "https://apis.lexstation.com/api/v1/";
|
||||
static const String tokenPadrao = "6JN4NNEP6IDEK7I2BCXTA7D1DPJR78";
|
||||
static const String tokenPadrao = "GA9P876KYL2XNHHKMU0VSHEEYEL37D";
|
||||
static const String urlBaseNewCore = "https://newcore.services/newcore/";
|
||||
static const int appMobileCodigo = 18;
|
||||
static const String nomeApp = "Decpisos";
|
||||
static const String nomeApp = "Vilacorp";
|
||||
static const int versaoAtual = 100;
|
||||
static const int usuCodPadrao = 36718;
|
||||
static const String youtubeApiKey = "AIzaSyAmqjP0MxgASbt98Px1_hqaIvcsqeHO15k";//"AIzaSyA8jo3qsr-JJRm40iSHfkrzaMZXdMjo9v4";
|
||||
static const String channelId = "UCJ_EUoswNTvRGotJ-ROxaKw";
|
||||
static const String homeURL = "https://www.decpisos.com.br/produtos-listar";
|
||||
static const String dominioPermitido = "https://www.decpisos.com.br";
|
||||
static const String urlPDF = "http://app-cards.com/files/card-decpisos.pdf";
|
||||
static const int usuCodPadrao = 70435;
|
||||
static const String youtubeApiKey =
|
||||
"AIzaSyAmqjP0MxgASbt98Px1_hqaIvcsqeHO15k"; //"AIzaSyA8jo3qsr-JJRm40iSHfkrzaMZXdMjo9v4";
|
||||
static const String channelId = "UCJ_EUoswNTvRGotJ-ROxaKw";
|
||||
static const String homeURL = "https://vilacorp.com.br/";
|
||||
static const String dominioPermitido = "https://vilacorp.com.br/";
|
||||
static const String urlPDF = "http://app-cards.com/files/vilacorp.pdf";
|
||||
|
||||
|
||||
static Future<bool> checkInternetConnection() async{
|
||||
static Future<bool> checkInternetConnection() async {
|
||||
bool retorno = true;
|
||||
try {
|
||||
final result = await InternetAddress.lookup('google.com').timeout(Duration(seconds: 5));
|
||||
final result = await InternetAddress.lookup('google.com')
|
||||
.timeout(Duration(seconds: 5));
|
||||
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
|
||||
retorno = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
retorno = false;
|
||||
}
|
||||
} on SocketException catch (_) {
|
||||
retorno = false;
|
||||
}
|
||||
catch(err){
|
||||
} catch (err) {
|
||||
retorno = false;
|
||||
}
|
||||
}
|
||||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
static Future<String> getUsuToken()async{
|
||||
static Future<String> getUsuToken() async {
|
||||
return Future<String>.value(tokenPadrao);
|
||||
}
|
||||
|
||||
static Future<void> registraDevice(String? token) async{
|
||||
|
||||
if(await FuncoesGerais.checkInternetConnection()){
|
||||
if(token != null && token.isNotEmpty){
|
||||
|
||||
String url = FuncoesGerais.urlBaseNewCore+ "api/v1/user/${FuncoesGerais.tokenPadrao}/registra_device";
|
||||
static Future<void> registraDevice(String? token) async {
|
||||
if (await FuncoesGerais.checkInternetConnection()) {
|
||||
if (token != null && token.isNotEmpty) {
|
||||
String url = FuncoesGerais.urlBaseNewCore +
|
||||
"api/v1/user/${FuncoesGerais.tokenPadrao}/registra_device";
|
||||
Map<String, String> heads = Map();
|
||||
heads["Content-type"] = "application/json; charset=utf-8";
|
||||
heads["auth-key"] = token;
|
||||
@@ -66,8 +63,8 @@ class FuncoesGerais{
|
||||
platformCoddigo = 1;
|
||||
var info = await deviceInfo.iosInfo;
|
||||
model = info.utsname.machine;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var objPost = new RegistraDeviceRequest(
|
||||
aPPMOBILECODIGO: appMobileCodigo,
|
||||
dEVICETOKEN: token,
|
||||
@@ -79,7 +76,7 @@ class FuncoesGerais{
|
||||
try {
|
||||
var body = json.encode(objPost);
|
||||
//var response = await http.post(url, body: body,headers: heads);
|
||||
await http.post(Uri.parse(url), body: body,headers: heads);
|
||||
await http.post(Uri.parse(url), body: body, headers: heads);
|
||||
//var r = await http.post(url, body: body,headers: heads);
|
||||
//print(r);
|
||||
// if (response != null) {
|
||||
@@ -88,32 +85,30 @@ class FuncoesGerais{
|
||||
// retorno = LoginResponse.fromJson(data);
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
// else{
|
||||
// print('Nada');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
static Future<VersaoMinimaResponse> checkVersaoMinimaOk() async{
|
||||
static Future<VersaoMinimaResponse> checkVersaoMinimaOk() async {
|
||||
VersaoMinimaResponse objRetorno = VersaoMinimaResponse(
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
linkLoja: '',
|
||||
nome: '',
|
||||
versaoMinima: 0,
|
||||
vOk: true
|
||||
);
|
||||
if(await FuncoesGerais.checkInternetConnection()){
|
||||
String url = FuncoesGerais.urlBaseNewCore + "api/v1/appmobile/${FuncoesGerais.tokenPadrao}/versaominima/$appMobileCodigo";
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
linkLoja: '',
|
||||
nome: '',
|
||||
versaoMinima: 0,
|
||||
vOk: true);
|
||||
if (await FuncoesGerais.checkInternetConnection()) {
|
||||
String url = FuncoesGerais.urlBaseNewCore +
|
||||
"api/v1/appmobile/${FuncoesGerais.tokenPadrao}/versaominima/$appMobileCodigo";
|
||||
Map<String, String> heads = Map();
|
||||
heads["Content-type"] = "application/json; charset=utf-8";
|
||||
|
||||
try {
|
||||
http.Response response = await http.get(Uri.parse(url),headers: heads);
|
||||
http.Response response = await http.get(Uri.parse(url), headers: heads);
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
@@ -122,30 +117,27 @@ class FuncoesGerais{
|
||||
// var v = packageInfo.version.split('.');
|
||||
// int versaoAtual = 0;
|
||||
//if(v.length > 0)versaoAtual = v[0] != null && v[0].isNotEmpty ? int.parse(v[0]) : 0;
|
||||
if(objRetorno.versaoMinima! > FuncoesGerais.versaoAtual){
|
||||
if (objRetorno.versaoMinima! > FuncoesGerais.versaoAtual) {
|
||||
objRetorno.vOk = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
objRetorno.errorCode = 4;
|
||||
objRetorno.errorMessage = 'Falha na comunição com a API error:${response.statusCode}.';
|
||||
objRetorno.errorMessage =
|
||||
'Falha na comunição com a API error:${response.statusCode}.';
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
objRetorno.errorCode = 3;
|
||||
objRetorno.errorMessage = 'Falha na comunição com o server.';
|
||||
objRetorno.errorMessage = 'Falha na comunição com o server.';
|
||||
}
|
||||
} catch (e) {
|
||||
objRetorno.errorCode = 2;
|
||||
objRetorno.errorMessage = 'Falha na comunição com o server.';
|
||||
}
|
||||
}
|
||||
else{
|
||||
}
|
||||
} else {
|
||||
objRetorno.errorCode = 1;
|
||||
objRetorno.errorMessage = 'Sem Conexão com a internet.';
|
||||
}
|
||||
|
||||
return objRetorno;
|
||||
}
|
||||
|
||||
}
|
||||
return objRetorno;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user