More work with redux and load/persist data

This commit is contained in:
vjrj 2018-06-27 20:58:10 +02:00
parent 2dfa745c6a
commit 69428c5d96
7 changed files with 82 additions and 49 deletions

View file

@ -12,18 +12,18 @@ class FiresApi {
resty.globalClient = new ht.IOClient();
}
Future<String> createUser(AppState state, String token, String lang) async {
Future<String> createUser(AppState state, String mobileToken, String lang) async {
assert(state.firesApiUrl != null);
assert(state.firesApiKey != null);
assert(token != null);
assert(mobileToken != null);
assert(lang != null);
final params = {
"token": state.firesApiKey,
"mobileToken": token,
"mobileToken": mobileToken,
"lang": lang
};
final url = '${state.firesApiUrl}mobile/users';
final String url = '${state.firesApiUrl}mobile/users';
/* print(url);
print(params); */
String resp = await resty.post(url).json(params).go().then((response) {
@ -35,5 +35,16 @@ class FiresApi {
return resp;
}
Future<List<YourLocation>> fetchYourLocations() async {}
Future<List<YourLocation>> fetchYourLocations(AppState state) async {
final apiKey = state.firesApiKey;
final mobileToken = state.user.token;
final String url = '${state.firesApiUrl}mobile/subscriptions/all/$apiKey/$mobileToken';
List<YourLocation> resp = await resty.get(url).go().then((response) {
if (response.statusCode == 200) {
// print(response.body);
print(json.decode(response.body)['data']['subscriptions']); return [];
}
});
return resp;
}
}