From cafbfb06d4eac449b877b69eb1b16bddae808178 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Tue, 2 Aug 2022 13:57:07 -0300 Subject: [PATCH] Create a new type to represent a compressed resource that translates to Task --- Sources/MeiliSearch/Model/TaskInfo.swift | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Sources/MeiliSearch/Model/TaskInfo.swift diff --git a/Sources/MeiliSearch/Model/TaskInfo.swift b/Sources/MeiliSearch/Model/TaskInfo.swift new file mode 100644 index 00000000..919ea5bd --- /dev/null +++ b/Sources/MeiliSearch/Model/TaskInfo.swift @@ -0,0 +1,33 @@ +import Foundation + +/** + `TaskInfo` instances represent the current transaction status, use the `taskUid` value to + verify the status of your transaction. + */ +public struct TaskInfo: Codable, Equatable { + + // MARK: Properties + + /// Unique ID for the current `TaskInfo`. + public let uid: Int + + /// Unique ID for the current `TaskInfo`. + public let indexUid: String? + + /// Returns if the task has been successful or not. + public let status: Task.Status + + /// Type of the task. + public let type: String + + /// Date when the task has been enqueued. + public let enqueuedAt: String + + static func == (lhs: TaskInfo, rhs: Task) -> Bool { + lhs.uid == rhs.uid + } + + public enum CodingKeys: String, CodingKey { + case uid = "taskUid", indexUid, status, type, enqueuedAt + } +}