feat: sync payment methods
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class PaymentMethodsResponseModel {
|
||||
final String? status;
|
||||
final List<PaymentMethod>? data;
|
||||
final bool? success;
|
||||
final PaymentMethodsData? data;
|
||||
final dynamic errors;
|
||||
|
||||
PaymentMethodsResponseModel({
|
||||
this.status,
|
||||
this.success,
|
||||
this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
factory PaymentMethodsResponseModel.fromJson(String str) =>
|
||||
@@ -16,51 +18,83 @@ class PaymentMethodsResponseModel {
|
||||
|
||||
factory PaymentMethodsResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
PaymentMethodsResponseModel(
|
||||
status: json["status"],
|
||||
success: json["success"],
|
||||
data: json["data"] == null
|
||||
? []
|
||||
: List<PaymentMethod>.from(
|
||||
json["data"]!.map((x) => PaymentMethod.fromMap(x))),
|
||||
? null
|
||||
: PaymentMethodsData.fromMap(json["data"]),
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"status": status,
|
||||
"data": data == null
|
||||
"success": success,
|
||||
"data": data?.toMap(),
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
|
||||
class PaymentMethodsData {
|
||||
final List<PaymentMethod>? paymentMethods;
|
||||
final int? totalCount;
|
||||
final int? page;
|
||||
final int? limit;
|
||||
final int? totalPages;
|
||||
|
||||
PaymentMethodsData({
|
||||
this.paymentMethods,
|
||||
this.totalCount,
|
||||
this.page,
|
||||
this.limit,
|
||||
this.totalPages,
|
||||
});
|
||||
|
||||
factory PaymentMethodsData.fromMap(Map<String, dynamic> json) =>
|
||||
PaymentMethodsData(
|
||||
paymentMethods: json["payment_methods"] == null
|
||||
? []
|
||||
: List<dynamic>.from(data!.map((x) => x.toMap())),
|
||||
: List<PaymentMethod>.from(
|
||||
json["payment_methods"].map((x) => PaymentMethod.fromMap(x))),
|
||||
totalCount: json["total_count"],
|
||||
page: json["page"],
|
||||
limit: json["limit"],
|
||||
totalPages: json["total_pages"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"payment_methods": paymentMethods == null
|
||||
? []
|
||||
: List<dynamic>.from(paymentMethods!.map((x) => x.toMap())),
|
||||
"total_count": totalCount,
|
||||
"page": page,
|
||||
"limit": limit,
|
||||
"total_pages": totalPages,
|
||||
};
|
||||
}
|
||||
|
||||
class PaymentMethod {
|
||||
final int? id;
|
||||
final String? id;
|
||||
final String? organizationId;
|
||||
final String? name;
|
||||
final String? description;
|
||||
final String? type;
|
||||
final bool? isActive;
|
||||
final int? sortOrder;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
PaymentMethod({
|
||||
this.id,
|
||||
this.organizationId,
|
||||
this.name,
|
||||
this.description,
|
||||
this.type,
|
||||
this.isActive,
|
||||
this.sortOrder,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory PaymentMethod.fromJson(String str) =>
|
||||
PaymentMethod.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory PaymentMethod.fromMap(Map<String, dynamic> json) => PaymentMethod(
|
||||
id: json["id"],
|
||||
organizationId: json["organization_id"],
|
||||
name: json["name"],
|
||||
description: json["description"],
|
||||
type: json["type"],
|
||||
isActive: json["is_active"],
|
||||
sortOrder: json["sort_order"],
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
@@ -71,11 +105,11 @@ class PaymentMethod {
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"organization_id": organizationId,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"type": type,
|
||||
"is_active": isActive,
|
||||
"sort_order": sortOrder,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user