Offers And Discounts Apis
parent
369a566006
commit
b02831834f
@ -0,0 +1,30 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class OfferPurchaseRequestModel {
|
||||||
|
String identificationType;
|
||||||
|
String idValue;
|
||||||
|
String mobileNumber;
|
||||||
|
|
||||||
|
OfferPurchaseRequestModel({
|
||||||
|
required this.identificationType,
|
||||||
|
required this.idValue,
|
||||||
|
required this.mobileNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OfferPurchaseRequestModel.fromRawJson(String str) => OfferPurchaseRequestModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory OfferPurchaseRequestModel.fromJson(Map<String, dynamic> json) => OfferPurchaseRequestModel(
|
||||||
|
identificationType: json["identification_type"],
|
||||||
|
idValue: json["id_value"],
|
||||||
|
mobileNumber: json["mobile_number"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"identification_type": identificationType,
|
||||||
|
"id_value": idValue,
|
||||||
|
"mobile_number": mobileNumber,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class OfferPurchaseResponseModel {
|
||||||
|
int orderId;
|
||||||
|
String orderRef;
|
||||||
|
String amount;
|
||||||
|
String currency;
|
||||||
|
bool paymentRequired;
|
||||||
|
dynamic paymentUrl;
|
||||||
|
|
||||||
|
OfferPurchaseResponseModel({
|
||||||
|
required this.orderId,
|
||||||
|
required this.orderRef,
|
||||||
|
required this.amount,
|
||||||
|
required this.currency,
|
||||||
|
required this.paymentRequired,
|
||||||
|
required this.paymentUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OfferPurchaseResponseModel.fromRawJson(String str) => OfferPurchaseResponseModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory OfferPurchaseResponseModel.fromJson(Map<String, dynamic> json) => OfferPurchaseResponseModel(
|
||||||
|
orderId: json["order_id"],
|
||||||
|
orderRef: json["order_ref"],
|
||||||
|
amount: json["amount"],
|
||||||
|
currency: json["currency"],
|
||||||
|
paymentRequired: json["payment_required"],
|
||||||
|
paymentUrl: json["payment_url"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"order_id": orderId,
|
||||||
|
"order_ref": orderRef,
|
||||||
|
"amount": amount,
|
||||||
|
"currency": currency,
|
||||||
|
"payment_required": paymentRequired,
|
||||||
|
"payment_url": paymentUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,229 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class OfferPurchaseHistoryResponseModel {
|
||||||
|
List<Datum> data;
|
||||||
|
Meta meta;
|
||||||
|
|
||||||
|
OfferPurchaseHistoryResponseModel({
|
||||||
|
required this.data,
|
||||||
|
required this.meta,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OfferPurchaseHistoryResponseModel.fromRawJson(String str) => OfferPurchaseHistoryResponseModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory OfferPurchaseHistoryResponseModel.fromJson(Map<String, dynamic> json) => OfferPurchaseHistoryResponseModel(
|
||||||
|
data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
|
||||||
|
meta: Meta.fromJson(json["meta"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
||||||
|
"meta": meta.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Datum {
|
||||||
|
String voucherCode;
|
||||||
|
String state;
|
||||||
|
DateTime purchaseDate;
|
||||||
|
dynamic redemptionDate;
|
||||||
|
String qrCode;
|
||||||
|
String qrCodeUrl;
|
||||||
|
String pdfUrl;
|
||||||
|
DateTime validTo;
|
||||||
|
UsageValidity usageValidity;
|
||||||
|
Offer offer;
|
||||||
|
String branchApplicability;
|
||||||
|
List<Branch> branches;
|
||||||
|
|
||||||
|
Datum({
|
||||||
|
required this.voucherCode,
|
||||||
|
required this.state,
|
||||||
|
required this.purchaseDate,
|
||||||
|
required this.redemptionDate,
|
||||||
|
required this.qrCode,
|
||||||
|
required this.qrCodeUrl,
|
||||||
|
required this.pdfUrl,
|
||||||
|
required this.validTo,
|
||||||
|
required this.usageValidity,
|
||||||
|
required this.offer,
|
||||||
|
required this.branchApplicability,
|
||||||
|
required this.branches,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Datum.fromRawJson(String str) => Datum.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Datum.fromJson(Map<String, dynamic> json) => Datum(
|
||||||
|
voucherCode: json["voucher_code"],
|
||||||
|
state: json["state"],
|
||||||
|
purchaseDate: DateTime.parse(json["purchase_date"]),
|
||||||
|
redemptionDate: json["redemption_date"],
|
||||||
|
qrCode: json["qr_code"],
|
||||||
|
qrCodeUrl: json["qr_code_url"],
|
||||||
|
pdfUrl: json["pdf_url"],
|
||||||
|
validTo: DateTime.parse(json["valid_to"]),
|
||||||
|
usageValidity: UsageValidity.fromJson(json["usage_validity"]),
|
||||||
|
offer: Offer.fromJson(json["offer"]),
|
||||||
|
branchApplicability: json["branch_applicability"],
|
||||||
|
branches: List<Branch>.from(json["branches"].map((x) => Branch.fromJson(x))),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"voucher_code": voucherCode,
|
||||||
|
"state": state,
|
||||||
|
"purchase_date": purchaseDate.toIso8601String(),
|
||||||
|
"redemption_date": redemptionDate,
|
||||||
|
"qr_code": qrCode,
|
||||||
|
"qr_code_url": qrCodeUrl,
|
||||||
|
"pdf_url": pdfUrl,
|
||||||
|
"valid_to": "${validTo.year.toString().padLeft(4, '0')}-${validTo.month.toString().padLeft(2, '0')}-${validTo.day.toString().padLeft(2, '0')}",
|
||||||
|
"usage_validity": usageValidity.toJson(),
|
||||||
|
"offer": offer.toJson(),
|
||||||
|
"branch_applicability": branchApplicability,
|
||||||
|
"branches": List<dynamic>.from(branches.map((x) => x.toJson())),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Branch {
|
||||||
|
String code;
|
||||||
|
String name;
|
||||||
|
String nameAr;
|
||||||
|
|
||||||
|
Branch({
|
||||||
|
required this.code,
|
||||||
|
required this.name,
|
||||||
|
required this.nameAr,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Branch.fromRawJson(String str) => Branch.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Branch.fromJson(Map<String, dynamic> json) => Branch(
|
||||||
|
code: json["code"],
|
||||||
|
name: json["name"],
|
||||||
|
nameAr: json["name_ar"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"name": name,
|
||||||
|
"name_ar": nameAr,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Offer {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
String nameAr;
|
||||||
|
String branchApplicability;
|
||||||
|
DateTime validTo;
|
||||||
|
UsageValidity usageValidity;
|
||||||
|
|
||||||
|
Offer({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.nameAr,
|
||||||
|
required this.branchApplicability,
|
||||||
|
required this.validTo,
|
||||||
|
required this.usageValidity,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Offer.fromRawJson(String str) => Offer.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Offer.fromJson(Map<String, dynamic> json) => Offer(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
nameAr: json["name_ar"],
|
||||||
|
branchApplicability: json["branch_applicability"],
|
||||||
|
validTo: DateTime.parse(json["valid_to"]),
|
||||||
|
usageValidity: UsageValidity.fromJson(json["usage_validity"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"name_ar": nameAr,
|
||||||
|
"branch_applicability": branchApplicability,
|
||||||
|
"valid_to": "${validTo.year.toString().padLeft(4, '0')}-${validTo.month.toString().padLeft(2, '0')}-${validTo.day.toString().padLeft(2, '0')}",
|
||||||
|
"usage_validity": usageValidity.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsageValidity {
|
||||||
|
String type;
|
||||||
|
dynamic days;
|
||||||
|
String rule;
|
||||||
|
String ruleAr;
|
||||||
|
DateTime redeemBy;
|
||||||
|
String redeemByDisplay;
|
||||||
|
|
||||||
|
UsageValidity({
|
||||||
|
required this.type,
|
||||||
|
required this.days,
|
||||||
|
required this.rule,
|
||||||
|
required this.ruleAr,
|
||||||
|
required this.redeemBy,
|
||||||
|
required this.redeemByDisplay,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory UsageValidity.fromRawJson(String str) => UsageValidity.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory UsageValidity.fromJson(Map<String, dynamic> json) => UsageValidity(
|
||||||
|
type: json["type"],
|
||||||
|
days: json["days"],
|
||||||
|
rule: json["rule"],
|
||||||
|
ruleAr: json["rule_ar"],
|
||||||
|
redeemBy: DateTime.parse(json["redeem_by"]),
|
||||||
|
redeemByDisplay: json["redeem_by_display"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"type": type,
|
||||||
|
"days": days,
|
||||||
|
"rule": rule,
|
||||||
|
"rule_ar": ruleAr,
|
||||||
|
"redeem_by": "${redeemBy.year.toString().padLeft(4, '0')}-${redeemBy.month.toString().padLeft(2, '0')}-${redeemBy.day.toString().padLeft(2, '0')}",
|
||||||
|
"redeem_by_display": redeemByDisplay,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta {
|
||||||
|
int total;
|
||||||
|
int page;
|
||||||
|
int perPage;
|
||||||
|
int pages;
|
||||||
|
|
||||||
|
Meta({
|
||||||
|
required this.total,
|
||||||
|
required this.page,
|
||||||
|
required this.perPage,
|
||||||
|
required this.pages,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Meta.fromRawJson(String str) => Meta.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Meta.fromJson(Map<String, dynamic> json) => Meta(
|
||||||
|
total: json["total"],
|
||||||
|
page: json["page"],
|
||||||
|
perPage: json["per_page"],
|
||||||
|
pages: json["pages"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"total": total,
|
||||||
|
"page": page,
|
||||||
|
"per_page": perPage,
|
||||||
|
"pages": pages,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,229 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class OfferPurchaseHistoryResponseModel {
|
||||||
|
List<Datum> data;
|
||||||
|
Meta meta;
|
||||||
|
|
||||||
|
OfferPurchaseHistoryResponseModel({
|
||||||
|
required this.data,
|
||||||
|
required this.meta,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OfferPurchaseHistoryResponseModel.fromRawJson(String str) => OfferPurchaseHistoryResponseModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory OfferPurchaseHistoryResponseModel.fromJson(Map<String, dynamic> json) => OfferPurchaseHistoryResponseModel(
|
||||||
|
data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
|
||||||
|
meta: Meta.fromJson(json["meta"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
||||||
|
"meta": meta.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Datum {
|
||||||
|
String voucherCode;
|
||||||
|
String state;
|
||||||
|
DateTime purchaseDate;
|
||||||
|
dynamic redemptionDate;
|
||||||
|
String qrCode;
|
||||||
|
String qrCodeUrl;
|
||||||
|
String pdfUrl;
|
||||||
|
DateTime validTo;
|
||||||
|
UsageValidity usageValidity;
|
||||||
|
Offer offer;
|
||||||
|
String branchApplicability;
|
||||||
|
List<Branch> branches;
|
||||||
|
|
||||||
|
Datum({
|
||||||
|
required this.voucherCode,
|
||||||
|
required this.state,
|
||||||
|
required this.purchaseDate,
|
||||||
|
required this.redemptionDate,
|
||||||
|
required this.qrCode,
|
||||||
|
required this.qrCodeUrl,
|
||||||
|
required this.pdfUrl,
|
||||||
|
required this.validTo,
|
||||||
|
required this.usageValidity,
|
||||||
|
required this.offer,
|
||||||
|
required this.branchApplicability,
|
||||||
|
required this.branches,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Datum.fromRawJson(String str) => Datum.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Datum.fromJson(Map<String, dynamic> json) => Datum(
|
||||||
|
voucherCode: json["voucher_code"],
|
||||||
|
state: json["state"],
|
||||||
|
purchaseDate: DateTime.parse(json["purchase_date"]),
|
||||||
|
redemptionDate: json["redemption_date"],
|
||||||
|
qrCode: json["qr_code"],
|
||||||
|
qrCodeUrl: json["qr_code_url"],
|
||||||
|
pdfUrl: json["pdf_url"],
|
||||||
|
validTo: DateTime.parse(json["valid_to"]),
|
||||||
|
usageValidity: UsageValidity.fromJson(json["usage_validity"]),
|
||||||
|
offer: Offer.fromJson(json["offer"]),
|
||||||
|
branchApplicability: json["branch_applicability"],
|
||||||
|
branches: List<Branch>.from(json["branches"].map((x) => Branch.fromJson(x))),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"voucher_code": voucherCode,
|
||||||
|
"state": state,
|
||||||
|
"purchase_date": purchaseDate.toIso8601String(),
|
||||||
|
"redemption_date": redemptionDate,
|
||||||
|
"qr_code": qrCode,
|
||||||
|
"qr_code_url": qrCodeUrl,
|
||||||
|
"pdf_url": pdfUrl,
|
||||||
|
"valid_to": "${validTo.year.toString().padLeft(4, '0')}-${validTo.month.toString().padLeft(2, '0')}-${validTo.day.toString().padLeft(2, '0')}",
|
||||||
|
"usage_validity": usageValidity.toJson(),
|
||||||
|
"offer": offer.toJson(),
|
||||||
|
"branch_applicability": branchApplicability,
|
||||||
|
"branches": List<dynamic>.from(branches.map((x) => x.toJson())),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Branch {
|
||||||
|
String code;
|
||||||
|
String name;
|
||||||
|
String nameAr;
|
||||||
|
|
||||||
|
Branch({
|
||||||
|
required this.code,
|
||||||
|
required this.name,
|
||||||
|
required this.nameAr,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Branch.fromRawJson(String str) => Branch.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Branch.fromJson(Map<String, dynamic> json) => Branch(
|
||||||
|
code: json["code"],
|
||||||
|
name: json["name"],
|
||||||
|
nameAr: json["name_ar"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"name": name,
|
||||||
|
"name_ar": nameAr,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Offer {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
String nameAr;
|
||||||
|
String branchApplicability;
|
||||||
|
DateTime validTo;
|
||||||
|
UsageValidity usageValidity;
|
||||||
|
|
||||||
|
Offer({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.nameAr,
|
||||||
|
required this.branchApplicability,
|
||||||
|
required this.validTo,
|
||||||
|
required this.usageValidity,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Offer.fromRawJson(String str) => Offer.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Offer.fromJson(Map<String, dynamic> json) => Offer(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
nameAr: json["name_ar"],
|
||||||
|
branchApplicability: json["branch_applicability"],
|
||||||
|
validTo: DateTime.parse(json["valid_to"]),
|
||||||
|
usageValidity: UsageValidity.fromJson(json["usage_validity"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"name_ar": nameAr,
|
||||||
|
"branch_applicability": branchApplicability,
|
||||||
|
"valid_to": "${validTo.year.toString().padLeft(4, '0')}-${validTo.month.toString().padLeft(2, '0')}-${validTo.day.toString().padLeft(2, '0')}",
|
||||||
|
"usage_validity": usageValidity.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsageValidity {
|
||||||
|
String type;
|
||||||
|
dynamic days;
|
||||||
|
String rule;
|
||||||
|
String ruleAr;
|
||||||
|
DateTime redeemBy;
|
||||||
|
String redeemByDisplay;
|
||||||
|
|
||||||
|
UsageValidity({
|
||||||
|
required this.type,
|
||||||
|
required this.days,
|
||||||
|
required this.rule,
|
||||||
|
required this.ruleAr,
|
||||||
|
required this.redeemBy,
|
||||||
|
required this.redeemByDisplay,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory UsageValidity.fromRawJson(String str) => UsageValidity.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory UsageValidity.fromJson(Map<String, dynamic> json) => UsageValidity(
|
||||||
|
type: json["type"],
|
||||||
|
days: json["days"],
|
||||||
|
rule: json["rule"],
|
||||||
|
ruleAr: json["rule_ar"],
|
||||||
|
redeemBy: DateTime.parse(json["redeem_by"]),
|
||||||
|
redeemByDisplay: json["redeem_by_display"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"type": type,
|
||||||
|
"days": days,
|
||||||
|
"rule": rule,
|
||||||
|
"rule_ar": ruleAr,
|
||||||
|
"redeem_by": "${redeemBy.year.toString().padLeft(4, '0')}-${redeemBy.month.toString().padLeft(2, '0')}-${redeemBy.day.toString().padLeft(2, '0')}",
|
||||||
|
"redeem_by_display": redeemByDisplay,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta {
|
||||||
|
int total;
|
||||||
|
int page;
|
||||||
|
int perPage;
|
||||||
|
int pages;
|
||||||
|
|
||||||
|
Meta({
|
||||||
|
required this.total,
|
||||||
|
required this.page,
|
||||||
|
required this.perPage,
|
||||||
|
required this.pages,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Meta.fromRawJson(String str) => Meta.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Meta.fromJson(Map<String, dynamic> json) => Meta(
|
||||||
|
total: json["total"],
|
||||||
|
page: json["page"],
|
||||||
|
perPage: json["per_page"],
|
||||||
|
pages: json["pages"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"total": total,
|
||||||
|
"page": page,
|
||||||
|
"per_page": perPage,
|
||||||
|
"pages": pages,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class PaymentResultRequestModel {
|
||||||
|
String status;
|
||||||
|
String paymentRef;
|
||||||
|
String amount;
|
||||||
|
String currency;
|
||||||
|
|
||||||
|
PaymentResultRequestModel({
|
||||||
|
required this.status,
|
||||||
|
required this.paymentRef,
|
||||||
|
required this.amount,
|
||||||
|
required this.currency,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory PaymentResultRequestModel.fromRawJson(String str) => PaymentResultRequestModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory PaymentResultRequestModel.fromJson(Map<String, dynamic> json) => PaymentResultRequestModel(
|
||||||
|
status: json["status"],
|
||||||
|
paymentRef: json["payment_ref"],
|
||||||
|
amount: json["amount"],
|
||||||
|
currency: json["currency"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"status": status,
|
||||||
|
"payment_ref": paymentRef,
|
||||||
|
"amount": amount,
|
||||||
|
"currency": currency,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class PaymentResultResponseModel {
|
||||||
|
String status;
|
||||||
|
|
||||||
|
PaymentResultResponseModel({
|
||||||
|
required this.status,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory PaymentResultResponseModel.fromRawJson(String str) => PaymentResultResponseModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory PaymentResultResponseModel.fromJson(Map<String, dynamic> json) => PaymentResultResponseModel(
|
||||||
|
status: json["status"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"status": status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,92 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class PomsAuthTokenModel {
|
||||||
|
String token;
|
||||||
|
DateTime expiresAt;
|
||||||
|
Partner partner;
|
||||||
|
PortalAccount portalAccount;
|
||||||
|
|
||||||
|
PomsAuthTokenModel({
|
||||||
|
required this.token,
|
||||||
|
required this.expiresAt,
|
||||||
|
required this.partner,
|
||||||
|
required this.portalAccount,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory PomsAuthTokenModel.fromRawJson(String str) => PomsAuthTokenModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory PomsAuthTokenModel.fromJson(Map<String, dynamic> json) => PomsAuthTokenModel(
|
||||||
|
token: json["token"],
|
||||||
|
expiresAt: DateTime.parse(json["expires_at"]),
|
||||||
|
partner: Partner.fromJson(json["partner"]),
|
||||||
|
portalAccount: PortalAccount.fromJson(json["portal_account"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"token": token,
|
||||||
|
"expires_at": expiresAt.toIso8601String(),
|
||||||
|
"partner": partner.toJson(),
|
||||||
|
"portal_account": portalAccount.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper method to check if token is expired
|
||||||
|
bool isExpired() {
|
||||||
|
return DateTime.now().isAfter(expiresAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to check if token is valid
|
||||||
|
bool isValid() {
|
||||||
|
return !isExpired() && token.isNotEmpty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Partner {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
Partner({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Partner.fromRawJson(String str) => Partner.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory Partner.fromJson(Map<String, dynamic> json) => Partner(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class PortalAccount {
|
||||||
|
bool created;
|
||||||
|
String login;
|
||||||
|
|
||||||
|
PortalAccount({
|
||||||
|
required this.created,
|
||||||
|
required this.login,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory PortalAccount.fromRawJson(String str) => PortalAccount.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
|
factory PortalAccount.fromJson(Map<String, dynamic> json) => PortalAccount(
|
||||||
|
created: json["created"],
|
||||||
|
login: json["login"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"created": created,
|
||||||
|
"login": login,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,290 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/offers_and_discounts/models/offers_purchases_history_response_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||||
|
|
||||||
|
class OffersAndDiscountsSuccessQrPage extends StatefulWidget {
|
||||||
|
final Datum purchaseData;
|
||||||
|
|
||||||
|
const OffersAndDiscountsSuccessQrPage({super.key, required this.purchaseData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<OffersAndDiscountsSuccessQrPage> createState() => _OffersAndDiscountsSuccessQrPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OffersAndDiscountsSuccessQrPageState extends State<OffersAndDiscountsSuccessQrPage> {
|
||||||
|
late AppState appState;
|
||||||
|
|
||||||
|
String _formatDate(DateTime date) {
|
||||||
|
try {
|
||||||
|
return DateFormat('dd MMM yyyy, hh:mm a').format(date);
|
||||||
|
} catch (e) {
|
||||||
|
return date.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color _getStatusColor(String status) {
|
||||||
|
switch (status.toLowerCase()) {
|
||||||
|
case 'active':
|
||||||
|
case 'valid':
|
||||||
|
return AppColors.successColor;
|
||||||
|
case 'redeemed':
|
||||||
|
case 'used':
|
||||||
|
return AppColors.warningColor;
|
||||||
|
case 'expired':
|
||||||
|
return AppColors.errorColor;
|
||||||
|
default:
|
||||||
|
return AppColors.greyTextColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getStatusText(String status) {
|
||||||
|
switch (status.toLowerCase()) {
|
||||||
|
case 'active':
|
||||||
|
case 'valid':
|
||||||
|
return LocaleKeys.active.tr(context: context);
|
||||||
|
case 'redeemed':
|
||||||
|
case 'used':
|
||||||
|
return "Redeemed";
|
||||||
|
case 'expired':
|
||||||
|
return LocaleKeys.expired.tr(context: context);
|
||||||
|
default:
|
||||||
|
return status.toUpperCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _copyVoucherCode() {
|
||||||
|
Clipboard.setData(ClipboardData(text: widget.purchaseData.voucherCode));
|
||||||
|
Utils.showToast("Voucher code copied to clipboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
appState = getIt.get<AppState>();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.bgScaffoldColor,
|
||||||
|
body: CollapsingListView(
|
||||||
|
title: LocaleKeys.paymentSuccessful.tr(context: context),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(height: 24.h),
|
||||||
|
|
||||||
|
// Success Icon
|
||||||
|
Container(
|
||||||
|
width: 80.h,
|
||||||
|
height: 80.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.successColor.withValues(alpha: 0.1),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.check_circle,
|
||||||
|
size: 48.h,
|
||||||
|
color: AppColors.successColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
|
||||||
|
LocaleKeys.paymentSuccessful.tr(context: context).toText24(isBold: true, fontWeight: FontWeight.w700),
|
||||||
|
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
|
||||||
|
"Your offer has been purchased successfully!".toText14(color: AppColors.greyTextColor),
|
||||||
|
|
||||||
|
SizedBox(height: 32.h),
|
||||||
|
|
||||||
|
// Order Reference Card (QR Code placeholder)
|
||||||
|
Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 20.h,
|
||||||
|
hasShadow: false,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.orderNumber.tr(context: context).toText18(isBold: true, weight: FontWeight.w700),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(24.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: BorderRadius.circular(12.h),
|
||||||
|
border: Border.all(color: AppColors.greyColor.withValues(alpha: 0.3)),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// QR Code Placeholder (can be replaced with actual QR code widget later)
|
||||||
|
Container(
|
||||||
|
width: 200.h,
|
||||||
|
height: 200.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.bgScaffoldColor,
|
||||||
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.qr_code,
|
||||||
|
size: 80.h,
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
"QR Code".toText12(color: AppColors.greyTextColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
widget.purchaseData.voucherCode.toText20(isBold: true, weight: FontWeight.w700),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _copyVoucherCode,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.copy, size: 16.h, color: AppColors.primaryRedColor),
|
||||||
|
SizedBox(width: 4.w),
|
||||||
|
"Copy".toText12(color: AppColors.primaryRedColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
"Show this at the facility to redeem your offer".toText12(color: AppColors.greyTextColor),
|
||||||
|
],
|
||||||
|
).paddingSymmetrical(24.h, 24.h),
|
||||||
|
).paddingSymmetrical(24.h, 0.h),
|
||||||
|
|
||||||
|
SizedBox(height: 24.h),
|
||||||
|
|
||||||
|
// Order Details Card
|
||||||
|
Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 20.h,
|
||||||
|
hasShadow: false,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.orderDetails.tr(context: context).toText18(isBold: true, weight: FontWeight.w700),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 6.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _getStatusColor(widget.purchaseData.state).withValues(alpha: 0.1),
|
||||||
|
borderRadius: BorderRadius.circular(12.h),
|
||||||
|
),
|
||||||
|
child: _getStatusText(widget.purchaseData.state).toText12(
|
||||||
|
isBold: true,
|
||||||
|
color: _getStatusColor(widget.purchaseData.state),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 20.h),
|
||||||
|
|
||||||
|
// Purchase Date
|
||||||
|
_buildDetailRow(
|
||||||
|
LocaleKeys.date.tr(context: context),
|
||||||
|
_formatDate(widget.purchaseData.purchaseDate),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
|
||||||
|
// Valid Until
|
||||||
|
_buildDetailRow(
|
||||||
|
"Valid Until",
|
||||||
|
_formatDate(widget.purchaseData.validTo),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
|
||||||
|
// Offer Name
|
||||||
|
_buildDetailRow(
|
||||||
|
"Offer Name",
|
||||||
|
appState.getLanguageID() == 1 ? widget.purchaseData.offer.nameAr : widget.purchaseData.offer.name,
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
|
||||||
|
Divider(color: AppColors.greyColor.withValues(alpha: 0.3)),
|
||||||
|
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
|
||||||
|
// Show offer description if available (note: Datum's Offer doesn't have description)
|
||||||
|
if (widget.purchaseData.usageValidity.rule.isNotEmpty) ...[
|
||||||
|
LocaleKeys.description.tr(context: context).toText16(isBold: true, weight: FontWeight.w700),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
(appState.getLanguageID() == 1 ? widget.purchaseData.usageValidity.ruleAr : widget.purchaseData.usageValidity.rule).toText14(color: AppColors.greyTextColor),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
).paddingSymmetrical(24.h, 24.h),
|
||||||
|
).paddingSymmetrical(24.h, 0.h),
|
||||||
|
|
||||||
|
SizedBox(height: 32.h),
|
||||||
|
|
||||||
|
// Back to Home Button
|
||||||
|
CustomButton(
|
||||||
|
text: LocaleKeys.done.tr(context: context),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||||
|
},
|
||||||
|
backgroundColor: AppColors.primaryRedColor,
|
||||||
|
borderColor: AppColors.primaryRedColor,
|
||||||
|
textColor: AppColors.whiteColor,
|
||||||
|
fontSize: 16.f,
|
||||||
|
isBold: true,
|
||||||
|
borderRadius: 12.r,
|
||||||
|
height: 56.h,
|
||||||
|
).paddingSymmetrical(24.h, 0.h),
|
||||||
|
|
||||||
|
SizedBox(height: 24.h),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDetailRow(String label, String value) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: label.toText14(color: AppColors.greyTextColor),
|
||||||
|
),
|
||||||
|
SizedBox(width: 16.w),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: value.toText14(isBold: true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue