//
/* NOTICE: All information contained herein is, and remains the property of Brightinsight Inc. or its customer.
The intellectual and technical concepts contained herein are proprietary to Brightinsight Inc. or its customer and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Brightinsight Inc. or its customer. Access to the source code contained herein is hereby forbidden to anyone except current Brightinsight Inc. employees, managers or contractors who have executed
Confidentiality and Non-disclosure agreements explicitly covering such access.
*/
/**
* System Name : BISDKCore
* Component ID : BISDKUploaderRecord
* Description :
* Author: Arnold Dominguez
* Copyright © : Brightinsight, Inc.
* -----------------------
* Revision Change
* -----------------------
* Author                        Date             Version            Change-Description
 Arnold Dominguez       08/18/21            1.0                 Creation
*========================================================================================================
*/

import Foundation

/**
    This class represent a single record stored in database.
 */

public class BISDKUploaderRecord {
    /// The record identifier.
    public var id: UUID
    /// The information sent to endpoint.
    public var payload: String
    /// Date of the event
    public var eventDate: Date
    /// Type of the record.
    public var recordType: BISDKUploaderRecordType
    /// Date of the last attempt to upload.
    public var lastAttempt: Date?
    /// Date scheduled to be retried to uplooad.
    public var nextRetry: Date?
    /// Number of retries. This is cleaned after the app restarts.
    public var uploadRetries: Int
    /// The number of times this record tried to upload.
    public var totalUploadRetries: Int
    
    init(payload: String, type: BISDKUploaderRecordType) {
        id = UUID()
        self.payload = payload
        eventDate = Date()
        recordType = type
        lastAttempt = nil
        nextRetry = nil
        uploadRetries = 0
        totalUploadRetries = 0
    }
    
    init(id: UUID, payload: String, eventDate: Date, type: BISDKUploaderRecordType, lastAttempt: Date?, nextRetry: Date?, uploadRetries: Int, uploadSuspended: Int, totalUploadRetries: Int) {
        self.id = id
        self.payload = payload
        self.eventDate = eventDate
        self.recordType = type
        self.lastAttempt = lastAttempt
        self.nextRetry = nextRetry
        self.uploadRetries = uploadRetries
        self.totalUploadRetries = totalUploadRetries
    }
}
