75 lines
1.5 KiB
Swift
75 lines
1.5 KiB
Swift
//
|
|
// APIResponse.swift
|
|
// AppClientBaseSwift
|
|
//
|
|
// API response wrapper models
|
|
// Các model wrapper cho API response
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// MARK: - API Response Wrapper
|
|
// Wrapper Response API
|
|
|
|
/// Generic API response wrapper
|
|
/// Wrapper response API chung
|
|
struct APIResponse<T: Decodable>: Decodable {
|
|
/// Success status
|
|
/// Trạng thái thành công
|
|
let success: Bool
|
|
|
|
/// Response data
|
|
/// Dữ liệu response
|
|
let data: T?
|
|
|
|
/// Error message if any
|
|
/// Thông báo lỗi nếu có
|
|
let error: String?
|
|
|
|
/// Pagination info if any
|
|
/// Thông tin phân trang nếu có
|
|
let pagination: Pagination?
|
|
}
|
|
|
|
// MARK: - Pagination
|
|
// Phân trang
|
|
|
|
/// Pagination information
|
|
/// Thông tin phân trang
|
|
struct Pagination: Decodable {
|
|
let currentPage: Int?
|
|
let pageSize: Int?
|
|
let totalPages: Int?
|
|
let totalItems: Int?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case currentPage
|
|
case pageSize
|
|
case totalPages
|
|
case totalItems
|
|
}
|
|
}
|
|
|
|
// MARK: - Simple Response
|
|
// Response đơn giản
|
|
|
|
/// Simple success/error response
|
|
/// Response thành công/lỗi đơn giản
|
|
struct SimpleResponse: Decodable {
|
|
let success: Bool
|
|
let message: String?
|
|
let error: String?
|
|
}
|
|
|
|
// MARK: - List Response
|
|
// Response danh sách
|
|
|
|
/// Generic list response wrapper
|
|
/// Wrapper response danh sách
|
|
struct ListResponse<T: Decodable>: Decodable {
|
|
let success: Bool
|
|
let data: [T]?
|
|
let error: String?
|
|
let pagination: Pagination?
|
|
}
|