1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Can sign in user

This commit is contained in:
2019-04-22 19:16:26 +02:00
parent b315b5ad77
commit 23f25e7704
14 changed files with 407 additions and 26 deletions

View File

@ -0,0 +1,27 @@
import 'package:meta/meta.dart';
/// API Request model
///
/// Contains all the information associated to an API request
///
/// @author Pierre HUBERT
class APIRequest {
final String uri;
final bool needLogin;
Map<String, String> args;
APIRequest({
@required this.uri,
this.needLogin = false,
}) : assert(uri != null),
assert(needLogin != null),
args = Map();
void addString(String name, String value) => args[name] = value;
void addInt(String name, int value) => args[name] = value.toString();
void addBool(String name, bool value) =>
args[name] = value ? "true" : "false";
}

View File

@ -0,0 +1,16 @@
import 'dart:convert';
/// API response
///
/// @author Pierre HUBERT
class APIResponse {
final int code;
final String content;
const APIResponse(this.code, this.content) : assert(code != null);
List<dynamic> getArray() => jsonDecode(this.content);
Map<String, dynamic> getObject() => jsonDecode(this.content);
}

View File

@ -0,0 +1,14 @@
import 'package:meta/meta.dart';
/// Authentication details
///
/// @author Pierre HUBERT
class AuthenticationDetails {
final String email;
final String password;
const AuthenticationDetails({@required this.email, @required this.password})
: assert(email != null),
assert(password != null);
}

42
lib/models/config.dart Normal file
View File

@ -0,0 +1,42 @@
import 'package:meta/meta.dart';
/// Application configuration model
///
/// @author Pierre HUBERT
/// Configuration class
class Config {
final String apiServerName;
final String apiServerUri;
final bool apiServerSecure;
final String serviceName;
final String serviceToken;
const Config(
{@required this.apiServerName,
@required this.apiServerUri,
@required this.apiServerSecure,
@required this.serviceName,
@required this.serviceToken})
: assert(apiServerName != null),
assert(apiServerUri != null),
assert(apiServerSecure != null),
assert(serviceName != null),
assert(serviceToken != null);
/// Get and set static configuration
static Config _config;
static Config get() {
return _config;
}
static void set(Config conf) {
_config = conf;
}
}
/// Get the current configuration of the application
Config config() {
return Config.get();
}

View File

@ -0,0 +1,23 @@
import 'dart:convert';
/// Login tokens model
///
/// @author Pierre HUBERT
class LoginTokens {
final String tokenOne;
final String tokenTwo;
const LoginTokens(this.tokenOne, this.tokenTwo)
: assert(tokenOne != null),
assert(tokenTwo != null);
LoginTokens.fromJSON(Map<String, dynamic> json)
: tokenOne = json["token_one"],
tokenTwo = json["token_two"];
@override
String toString() {
return jsonEncode({"token_one": tokenOne, "token_two": tokenTwo});
}
}