import 'package:dio/dio.dart'; import 'package:nekoya_flutter/api/config.dart'; Future getProducts() async { var req = await Dio().get('$host/getproducts'); var res = req.data; return res; } Future getProduct(id) async { var req = await Dio().get('$host/getproduct', queryParameters: {'id': id}); var res = req.data; return res; } Future registerPost(data) async { Response req = await Dio().post( ('$host/register'), data: data, options: Options( contentType: Headers.formUrlEncodedContentType, validateStatus: (status) { return status! < 500; }, ), ); return req.statusCode; } Future loginPost({email, password}) async { Response req = await Dio().post( ('$host/login'), data: { 'email': email, 'password': password, }, options: Options( contentType: Headers.formUrlEncodedContentType, validateStatus: (status) { return status! < 400; }, ), ); return req.statusCode; } Future getSessions() async { String tempKey = 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; var req = await Dio() .post('$host/sessions', queryParameters: {'key': tempKey}); 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'; Response req = await Dio().post( ('$host/checkout'), queryParameters: {'key': tempKey}, data: data, options: Options( contentType: Headers.formUrlEncodedContentType, validateStatus: (status) { return status! < 500; }, ), ); return req.statusCode; }