generateTransaction method

Future<ResponseModel> generateTransaction(
  1. PixTransactionModel model
)

Implementation

Future<ResponseModel> generateTransaction(PixTransactionModel model) async {
  assert(inDebugMode = true);
  final response = await http.post(
    inDebugMode ? Uri.parse(APIUrls.baseDevUrl) : Uri.parse(APIUrls.baseUrl),
    headers: {
      'Authorization': 'Bearer ${FlutterPixPagstar.authorization}',
      'Content-Type': 'application/json'
    },
    body: jsonEncode(model.toJson()),
  );
  developer.log(response.body);
  if (response.statusCode == 200) {
    return ResponseModel.fromJson(jsonDecode(response.body));
  } else {
    throw Exception('Failed to load transaction');
  }
}