From 410737b42a7f32db68b294aef8d9cce642f4c240 Mon Sep 17 00:00:00 2001 From: Moe Date: Thu, 12 May 2022 21:46:13 +0700 Subject: [PATCH] Update API with authentication --- lib/api/api.dart | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/api/api.dart b/lib/api/api.dart index 03e6710..c80521e 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -41,30 +41,23 @@ Future loginPost(data) async { return {'statusCode': req.statusCode, 'data': req.data}; } -Future getSessions() async { - String tempKey = - 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; +Future getSessions(session) async { var req = await Dio() - .post('$host/sessions', queryParameters: {'key': tempKey}); + .post('$host/sessions', queryParameters: {'session_token': session}); + return {'statusCode': req.statusCode, 'data': req.data}; +} + +Future getTransactions(session) async { + var req = await Dio() + .post('$host/transaction', queryParameters: {'session_token': session}); var res = req.data; return res; } -Future getTransactions() async { - String tempKey = - 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; - var req = await Dio() - .post('$host/transaction', queryParameters: {'key': tempKey}); - var res = req.data; - return res; -} - -Future checkoutPost(data) async { - String tempKey = - 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; +Future checkoutPost(session, data) async { Response req = await Dio().post( ('$host/checkout'), - queryParameters: {'key': tempKey}, + queryParameters: {'session_token': session}, data: data, options: Options( contentType: Headers.formUrlEncodedContentType,