90 lines
2.5 KiB
Dart
90 lines
2.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:SEFER/constant/api_key.dart';
|
|
import 'package:SEFER/constant/box_name.dart';
|
|
import 'package:SEFER/constant/info.dart';
|
|
import 'package:SEFER/constant/links.dart';
|
|
import 'package:SEFER/main.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class SmsEgyptController extends GetxController {
|
|
var headers = {'Content-Type': 'application/json'};
|
|
|
|
Future<dynamic> sendSmsEgypt(String phone, otp) async {
|
|
var body = jsonEncode({
|
|
"username": AppInformation.appName,
|
|
"password": 'E)Pu=an/@Z', // AK.smsPasswordEgypt,
|
|
"message": "${AppInformation.appName} app code is $otp\ncopy it to app",
|
|
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
|
"sender": "Kazumi", // todo add sefer sender name
|
|
"receiver": "2$phone"
|
|
});
|
|
|
|
var res = await http.post(
|
|
Uri.parse(AppLink.sendSms),
|
|
body: body,
|
|
headers: headers,
|
|
);
|
|
|
|
print(res.reasonPhrase);
|
|
print(res.request);
|
|
print(res.body);
|
|
print(body);
|
|
if (res.statusCode == 200) {
|
|
Get.defaultDialog(
|
|
title: 'You will recieve code in sms message'.tr,
|
|
middleText: '',
|
|
confirm: MyElevatedButton(
|
|
title: 'OK'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
}));
|
|
}
|
|
}
|
|
|
|
Future checkCredit(String phone, otp) async {
|
|
var res = await http.post(
|
|
Uri.parse(AppLink.checkCredit),
|
|
body: {
|
|
"username": AppInformation.appName,
|
|
"password": AK.smsPasswordEgypt,
|
|
},
|
|
headers: headers,
|
|
);
|
|
print(res);
|
|
}
|
|
|
|
Future sendSmsWithValidaty(String phone, otp) async {
|
|
var res = await http.post(
|
|
Uri.parse(AppLink.checkCredit),
|
|
body: {
|
|
"username": AppInformation.appName,
|
|
"password": AK.smsPasswordEgypt,
|
|
"message": "This is an example SMS message.",
|
|
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
|
"sender": "Kazumi", // todo add sefer sender name
|
|
"receiver": "2$phone",
|
|
"validity": "10",
|
|
"StartTime": DateTime.now().toString() // "1/1/2024 10:00:00"
|
|
},
|
|
headers: headers,
|
|
);
|
|
print(res);
|
|
}
|
|
|
|
Future sendSmsStatus(String smsid) async {
|
|
var res = await http.post(
|
|
Uri.parse(AppLink.checkCredit),
|
|
body: {
|
|
"username": AppInformation.appName,
|
|
"password": AK.smsPasswordEgypt,
|
|
"smsid": smsid //"00b77dfc-5b8f-474d-9def-9f0158b70f98"
|
|
},
|
|
headers: headers,
|
|
);
|
|
print(res);
|
|
}
|
|
}
|