fetchPlayerAccountHistory function
Implementation
Future<TransactionsResponse> fetchPlayerAccountHistory(String playerUid,
PlayMode playMode, int offset, int limit, Config config) async {
final response =
await http.post(Uri.parse('${config.server}/api/wallet/get-transactions'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, dynamic>{
"operator_id": config.operatorId,
"client_secret": config.clientSecret,
"client_id": config.clientId,
"player_uid": playerUid,
"offset": offset,
"limit": limit,
"mode": playMode.toString()
}));
if (response.statusCode == 200) {
// If the server did return a 200 OK response,
// then parse the JSON.
var rb = response.body;
// store json data into list
var walletResponse = json.decode(rb) as Map<String, dynamic>;
TransactionsResponse transactionsResponse = TransactionsResponse.fromJson(
walletResponse); // list.map((i)=>Game.fromJson(i)).toList();
return transactionsResponse;
} else {
// If the server did not return a 200 OK response,
// then throw an exception.
throw Exception('Failed to account history for the player.');
}
}