2022-04-22 22:08:59 +02:00
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:nekoya_flutter/api/config.dart';
|
|
|
|
|
|
|
|
Future<dynamic> getProducts() async {
|
2022-05-12 05:27:19 +02:00
|
|
|
var req = await Dio().get('$host/getproducts');
|
2022-04-22 22:08:59 +02:00
|
|
|
var res = req.data;
|
|
|
|
return res;
|
2022-04-25 08:48:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<dynamic> getProduct(id) async {
|
2022-05-12 05:27:19 +02:00
|
|
|
var req = await Dio().get('$host/getproduct', queryParameters: {'id': id});
|
2022-04-25 08:48:14 +02:00
|
|
|
var res = req.data;
|
|
|
|
return res;
|
2022-04-25 15:24:26 +02:00
|
|
|
}
|
|
|
|
|
2022-04-26 20:13:53 +02:00
|
|
|
Future<dynamic> registerPost(data) async {
|
2022-04-25 15:24:26 +02:00
|
|
|
Response req = await Dio().post(
|
2022-05-12 05:27:19 +02:00
|
|
|
('$host/register'),
|
2022-04-26 20:13:53 +02:00
|
|
|
data: data,
|
2022-04-25 15:24:26 +02:00
|
|
|
options: Options(
|
|
|
|
contentType: Headers.formUrlEncodedContentType,
|
|
|
|
validateStatus: (status) {
|
|
|
|
return status! < 500;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return req.statusCode;
|
|
|
|
}
|
2022-04-26 08:11:54 +02:00
|
|
|
|
|
|
|
Future<dynamic> loginPost({email, password}) async {
|
|
|
|
Response req = await Dio().post(
|
2022-05-12 05:27:19 +02:00
|
|
|
('$host/login'),
|
2022-04-26 08:11:54 +02:00
|
|
|
data: {
|
|
|
|
'email': email,
|
|
|
|
'password': password,
|
|
|
|
},
|
|
|
|
options: Options(
|
|
|
|
contentType: Headers.formUrlEncodedContentType,
|
|
|
|
validateStatus: (status) {
|
|
|
|
return status! < 400;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return req.statusCode;
|
|
|
|
}
|
2022-04-27 08:20:01 +02:00
|
|
|
|
2022-04-30 18:47:48 +02:00
|
|
|
Future<dynamic> getSessions() async {
|
|
|
|
String tempKey =
|
|
|
|
'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
|
|
|
|
var req = await Dio()
|
2022-05-12 05:27:19 +02:00
|
|
|
.post('$host/sessions', queryParameters: {'key': tempKey});
|
2022-04-30 18:47:48 +02:00
|
|
|
var res = req.data;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-04-27 08:20:01 +02:00
|
|
|
Future<dynamic> getTransactions() async {
|
2022-04-28 06:27:37 +02:00
|
|
|
String tempKey =
|
|
|
|
'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
|
|
|
|
var req = await Dio()
|
2022-05-12 05:27:19 +02:00
|
|
|
.post('$host/transaction', queryParameters: {'key': tempKey});
|
2022-04-27 08:20:01 +02:00
|
|
|
var res = req.data;
|
|
|
|
return res;
|
2022-04-28 06:27:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<dynamic> checkoutPost(data) async {
|
|
|
|
String tempKey =
|
|
|
|
'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
|
|
|
|
Response req = await Dio().post(
|
2022-05-12 05:27:19 +02:00
|
|
|
('$host/checkout'),
|
2022-04-28 06:27:37 +02:00
|
|
|
queryParameters: {'key': tempKey},
|
|
|
|
data: data,
|
|
|
|
options: Options(
|
|
|
|
contentType: Headers.formUrlEncodedContentType,
|
|
|
|
validateStatus: (status) {
|
|
|
|
return status! < 500;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return req.statusCode;
|
|
|
|
}
|