Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created August 16, 2021 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/b893abd6debd7f1a8253877a576fd72c to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/b893abd6debd7f1a8253877a576fd72c to your computer and use it in GitHub Desktop.
class ClienteModel {
String id;
String nextUrl;
String previousUrl;
bool enabled;
bool deleted;
DateTime? createdOn;
DateTime? updatedOn;
int djangoUser;
String cpf;
String nome;
String email;
String telefone;
String token;
String firebase;
String accessToken;
String idToken;
double latitude;
double longitude;
String endereco;
int usuarioPtr;
String enderecoRes;
String enderecoCom;
ClienteModel({
this.id = '',
this.nextUrl = '',
this.previousUrl = '',
this.enabled = true,
this.deleted = false,
DateTime? createdOn,
DateTime? updatedOn,
this.djangoUser = 0,
this.cpf = '',
this.nome = '',
this.email = '',
this.telefone = '',
this.token = '',
this.firebase = '',
this.accessToken = '',
this.idToken = '',
this.latitude = 0.0,
this.longitude = 0.0,
this.endereco = '',
this.usuarioPtr = 0,
this.enderecoRes = '',
this.enderecoCom = '',
});
ClienteModel.fromMap(Map<String, dynamic> json)
: id = '',
djangoUser = 0,
nome = '',
cpf = '',
longitude = 0.0,
latitude = 0.0,
usuarioPtr = 0,
endereco = '',
enderecoCom = '',
enderecoRes = '',
nextUrl = '',
previousUrl = '',
email = '',
telefone = '',
token = '',
firebase = '',
accessToken = '',
idToken = '',
enabled = true,
deleted = false {
try {
id = json.containsKey('id') ? json['id'] ?? "" : "";
nextUrl = json.containsKey('nextUrl') ? json['nextUrl'] ?? "" : "";
previousUrl = json.containsKey('previousUrl') ? json['previousUrl'] ?? "" : "";
enabled = json.containsKey('enabled') ? json['enabled'] ?? true : true;
deleted = json.containsKey('deleted') ? json['deleted'] ?? false : false;
djangoUser = json.containsKey('django_user') ? json['django_user'] ?? "" : "";
cpf = json.containsKey('cpf') ? json['cpf'] ?? "" : "";
nome = json.containsKey('nome') ? json['nome'] ?? "" : "";
email = json.containsKey('email') ? json['email'] ?? "" : "";
telefone = json.containsKey('telefone') ? json['telefone'] ?? "" : "";
token = json.containsKey('token') ? json['token'] ?? "" : "";
firebase = json.containsKey('firebase') ? json['firebase'] ?? "" : "";
accessToken = json.containsKey('access_token') ? json['access_token'] ?? "" : "";
idToken = json.containsKey('id_token') ? json['id_token'] ?? "" : "";
latitude = json.containsKey('latitude') ? json['latitude'] ?? 0.0 : 0.0;
longitude = json.containsKey('longitude') ? json['longitude'] ?? 0.0 : 0.0;
endereco = json.containsKey('endereco') ? json['endereco'] ?? "" : "";
usuarioPtr = json.containsKey('usuario_ptr') ? json['usuario_ptr'] ?? "" : "";
enderecoRes = json.containsKey('endereco_res') ? json['endereco_res'] ?? "" : "";
enderecoCom = json.containsKey('endereco_com') ? json['endereco_com'] ?? "" : "";
} catch (error) {
ExceptionCustom.general("Ocorreu um erro no método fromMap do ClienteModel", error.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment