feat: customer
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerResponseModel {
|
||||
final bool? success;
|
||||
final CustomerData? data;
|
||||
final dynamic errors;
|
||||
|
||||
CustomerResponseModel({
|
||||
this.success,
|
||||
this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
factory CustomerResponseModel.fromJson(String str) =>
|
||||
CustomerResponseModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
CustomerResponseModel(
|
||||
success: json["success"],
|
||||
data: json["data"] == null ? null : CustomerData.fromMap(json["data"]),
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"success": success,
|
||||
"data": data?.toMap(),
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
|
||||
class CustomerData {
|
||||
final List<Customer>? customers;
|
||||
final int? totalCount;
|
||||
final int? page;
|
||||
final int? limit;
|
||||
final int? totalPages;
|
||||
|
||||
CustomerData({
|
||||
this.customers,
|
||||
this.totalCount,
|
||||
this.page,
|
||||
this.limit,
|
||||
this.totalPages,
|
||||
});
|
||||
|
||||
factory CustomerData.fromMap(Map<String, dynamic> json) => CustomerData(
|
||||
customers: json["data"] == null
|
||||
? []
|
||||
: List<Customer>.from(json["data"].map((x) => Customer.fromMap(x))),
|
||||
totalCount: json["total_count"],
|
||||
page: json["page"],
|
||||
limit: json["limit"],
|
||||
totalPages: json["total_pages"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"data": customers == null
|
||||
? []
|
||||
: List<dynamic>.from(customers!.map((x) => x.toMap())),
|
||||
"total_count": totalCount,
|
||||
"page": page,
|
||||
"limit": limit,
|
||||
"total_pages": totalPages,
|
||||
};
|
||||
}
|
||||
|
||||
class Customer {
|
||||
final String? id;
|
||||
final String? organizationId;
|
||||
final String? name;
|
||||
final bool? isDefault;
|
||||
final bool? isActive;
|
||||
final Map<String, dynamic>? metadata;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
Customer({
|
||||
this.id,
|
||||
this.organizationId,
|
||||
this.name,
|
||||
this.isDefault,
|
||||
this.isActive,
|
||||
this.metadata,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory Customer.fromMap(Map<String, dynamic> json) => Customer(
|
||||
id: json["id"],
|
||||
organizationId: json["organization_id"],
|
||||
name: json["name"],
|
||||
isDefault: json["is_default"],
|
||||
isActive: json["is_active"],
|
||||
metadata: json["metadata"] ?? {},
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"organization_id": organizationId,
|
||||
"name": name,
|
||||
"is_default": isDefault,
|
||||
"is_active": isActive,
|
||||
"metadata": metadata,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user