From d2ebc85de85a2b9367a11eb475e29b9d5d68ece8 Mon Sep 17 00:00:00 2001 From: Mumthasir mohammed <> Date: Mon, 23 Oct 2023 10:50:34 +0530 Subject: [PATCH] Add #69: Get consent history for an individual Repository creation --- .../Model/ConsentHistory/ConsentHistory.swift | 23 +++++++++++-------- .../ConsentHistory/ConsentHistoryData.swift | 16 ++++++++----- .../BBConsentHistoryViewController.swift | 3 +-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistory.swift b/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistory.swift index 8cd69f7..0bb6c3e 100644 --- a/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistory.swift +++ b/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistory.swift @@ -5,14 +5,12 @@ import Foundation import SwiftyJSON -class ConsentHistory{ - - var iD : String! - var log : String! - var orgID : String! - var purposeID : String! - var timeStamp : String! - +class ConsentHistory: ConsentHistoryWrapper { + var iD : String? + var log : String? + var orgID : String? + var purposeID : String? + var timeStamp : String? /** * Instantiate the instance using the passed json values to set the properties values @@ -27,5 +25,12 @@ class ConsentHistory{ purposeID = json["PurposeID"].stringValue timeStamp = json["TimeStamp"].stringValue } +} -} \ No newline at end of file +protocol ConsentHistoryWrapper { + var iD : String? { get } + var log : String? { get } + var orgID : String? { get } + var purposeID : String? { get } + var timeStamp : String? { get } +} diff --git a/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistoryData.swift b/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistoryData.swift index 1495a0f..f7389ae 100644 --- a/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistoryData.swift +++ b/PrivacyDashboardiOS/Classes/Model/ConsentHistory/ConsentHistoryData.swift @@ -5,11 +5,10 @@ import Foundation import SwiftyJSON -class ConsentHistoryData{ - - var consentHistory : [ConsentHistory]! - var links : Link! - var unReadCount : Int! +class ConsentHistoryData { + var consentHistory : [ConsentHistory]? + var links : Link? + var unReadCount : Int? /** * Instantiate the instance using the passed json values to set the properties values @@ -22,7 +21,7 @@ class ConsentHistoryData{ let consentHistoryArray = json["ConsentHistory"].arrayValue for consentHistoryJson in consentHistoryArray{ let value = ConsentHistory(fromJson: consentHistoryJson) - consentHistory.append(value) + consentHistory?.append(value) } unReadCount = json["UnReadCount"].intValue let linksJson = json["Links"] @@ -31,5 +30,10 @@ class ConsentHistoryData{ links = Link(fromJson: linksJson) } } +} +protocol ConsentHistoryDataWrapper { + var consentHistory : [ConsentHistoryWrapper]? { get } + var links : Link? { get } + var unReadCount : Int? { get } } diff --git a/PrivacyDashboardiOS/Classes/ViewControllers/ConsentHistory/BBConsentHistoryViewController.swift b/PrivacyDashboardiOS/Classes/ViewControllers/ConsentHistory/BBConsentHistoryViewController.swift index 307a793..2a3fc9e 100644 --- a/PrivacyDashboardiOS/Classes/ViewControllers/ConsentHistory/BBConsentHistoryViewController.swift +++ b/PrivacyDashboardiOS/Classes/ViewControllers/ConsentHistory/BBConsentHistoryViewController.swift @@ -67,8 +67,7 @@ extension BBConsentHistoryViewController: WebServiceTaskManagerProtocol { self.histories = [ConsentHistory]() } if serviceManager.isLoadMore { - self.histories?.append(contentsOf: data.consentHistory) - + self.histories?.append(contentsOf: data.consentHistory ?? []) } else { self.histories = data.consentHistory if (self.histories?.count ?? 0) < 1 {