Skip to content

Commit

Permalink
Add #175: Optimisation on optin and optout call
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumthasir mohammed authored and georgepadayatti committed Jan 5, 2024
1 parent 52ac3ca commit 8cfa25c
Show file tree
Hide file tree
Showing 10 changed files with 288 additions and 211 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// DataAgreements.swift
// PrivacyDashboardiOS
//
// Created by Mumthasir mohammed on 04/01/24.
//

import Foundation
// MARK: - DataAgreements
struct DataAgreementsModel: Codable {
var dataAgreements: [DataAgreements]
let pagination: PaginationModel
}

// MARK: - DataAgreement
struct DataAgreements: Codable {
var active: Bool
let compatibleWithVersionID, controllerID, controllerName: String
let controllerURL: String
let dataAttributes: [DataAttributeModel]
let dpiaDate: String
let dpiaSummaryURL: String
let forgettable: Bool
let id, lawfulBasis, lifecycle, methodOfUse: String
let policy: PolicyModel
let purpose, purposeDescription: String
let signature: SignatureModel
let version: String

enum CodingKeys: String, CodingKey {
case active
case compatibleWithVersionID = "compatibleWithVersionId"
case controllerID = "controllerId"
case controllerName
case controllerURL = "controllerUrl"
case dataAttributes, dpiaDate
case dpiaSummaryURL = "dpiaSummaryUrl"
case forgettable, id, lawfulBasis, lifecycle, methodOfUse, policy, purpose, purposeDescription, signature, version
}
}

// MARK: - DataAttribute
struct DataAttributeModel: Codable {
let category, description, id, name: String
let sensitivity: Bool
}

// MARK: - Policy
struct PolicyModel: Codable {
let dataRetentionPeriodDays: Int
let geographicRestriction, id, industrySector, jurisdiction: String
let name, storageLocation: String
let thirdPartyDataSharing: Bool
let url: String
let version: String
}

// MARK: - Signature
struct SignatureModel: Codable {
let id, objectReference, objectType, payload: String
let signature: String
let signedWithoutObjectReference: Bool
let timestamp, verificationArtifact, verificationJwsHeader, verificationMethod: String
let verificationPayload, verificationPayloadHash, verificationSignedAs, verificationSignedBy: String
}

// MARK: - Pagination
struct PaginationModel: Codable {
let currentPage, totalItems, totalPages, limit: Int
let hasPrevious, hasNext: Bool
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// OrganisationModel.swift
// PrivacyDashboardiOS
//
// Created by Mumthasir mohammed on 05/01/24.
//

import Foundation

// MARK: - Organisation
struct OrganisationModel: Codable {
let organisation: OrganisationClass
}

// MARK: - OrganisationClass
struct OrganisationClass: Codable {
let id, name, description, sector: String
let location: String
let policyURL: String
let coverImageID: String
let coverImageURL: String
let logoImageID: String
let logoImageURL: String

enum CodingKeys: String, CodingKey {
case id, name, description, sector, location
case policyURL = "policyUrl"
case coverImageID = "coverImageId"
case coverImageURL = "coverImageUrl"
case logoImageID = "logoImageId"
case logoImageURL = "logoImageUrl"
}
}
38 changes: 38 additions & 0 deletions PrivacyDashboardiOS/Classes/Model/Organisation/RecordsModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// RecordsModel.swift
// PrivacyDashboardiOS
//
// Created by Mumthasir mohammed on 05/01/24.
//

import Foundation

// MARK: - Records
class RecordsModel: Codable {
let consentRecords: [ConsentRecordModel]
let pagination: RecordsPagination
}

// MARK: - ConsentRecord
class ConsentRecordModel: Codable {
let id, dataAgreementID, dataAgreementRevisionID, dataAgreementRevisionHash: String
let individualID: String
var optIn: Bool
let state, signatureID: String

enum CodingKeys: String, CodingKey {
case id
case dataAgreementID = "dataAgreementId"
case dataAgreementRevisionID = "dataAgreementRevisionId"
case dataAgreementRevisionHash
case individualID = "individualId"
case optIn, state
case signatureID = "signatureId"
}
}

// MARK: - Pagination
class RecordsPagination: Codable {
let currentPage, totalItems, totalPages, limit: Int
let hasPrevious, hasNext: Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class BBConsentAttributesViewController: BBConsentBaseViewController {
@IBOutlet var disAllowAllBtnHeightCostrint: NSLayoutConstraint!

var overViewCollpased = true
var organisaionDeatils : OrganisationDetails?
var organization : Organization?
var purposeInfo : PurposeConsentWrapperV2?
var dataAgreementsModel : DataAgreementsModel?
var organization : OrganisationModel?
var purposeInfo : DataAgreements?
var consentslist : [ConsentDetails]?
var consentslistInfo : ConsentListingResponse?
var dataAttributes: [DataAttribute]?
Expand Down Expand Up @@ -45,7 +45,7 @@ class BBConsentAttributesViewController: BBConsentBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = false
self.title = purposeInfo?.name?.unCamelCased
self.title = purposeInfo?.purpose.unCamelCased
if isNeedToRefresh == true {
isNeedToRefresh = false
callConsentListApi()
Expand Down Expand Up @@ -91,7 +91,7 @@ class BBConsentAttributesViewController: BBConsentBaseViewController {
}

@IBAction func policyBtnClicked() {
if let url = organisaionDeatils?.purposeConsents?[0].policyURL {
if let url = dataAgreementsModel?.dataAgreements[0].policy.url {
if url.isValidString{
let webviewVC = self.storyboard?.instantiateViewController(withIdentifier: Constant.ViewControllerID.webViewVC) as! BBConsentWebViewViewController
webviewVC.urlString = url
Expand All @@ -110,7 +110,7 @@ class BBConsentAttributesViewController: BBConsentBaseViewController {
self.addLoadingIndicator()
let serviceManager = OrganisationWebServiceManager()
serviceManager.managerDelegate = self
serviceManager.consentList(dataAgreementId: purposeInfo?.iD ?? "")
serviceManager.consentList(dataAgreementId: purposeInfo?.id ?? "")
}

func showConfirmationAlert() {
Expand Down Expand Up @@ -214,15 +214,15 @@ extension BBConsentAttributesViewController : UITableViewDelegate,UITableViewDa
// orgOverViewCell.overViewLbl.numberOfLines = 0
}
orgOverViewCell.overViewLbl.textReplacementType = .word
if purposeInfo?.descriptionField != nil {
let desc = purposeInfo?.descriptionField
if purposeInfo?.purposeDescription != nil {
let desc = purposeInfo?.purposeDescription
orgOverViewCell.overViewLbl.text = desc
}
return orgOverViewCell
default:
let consentHeaderCell = tableView.dequeueReusableCell(withIdentifier: Constant.CustomTabelCell.consentHeaderTableViewCell,for: indexPath) as! BBConsentAttributesHeaderCell

if let url = organisaionDeatils?.purposeConsents?[0].policyURL {
if let url = dataAgreementsModel?.dataAgreements[0].policy.url {
if url.isValidString{
consentHeaderCell.policyButton.isHidden = false
}else{
Expand Down Expand Up @@ -259,7 +259,7 @@ extension BBConsentAttributesViewController : UITableViewDelegate,UITableViewDa
consentVC.consent = consentslist?[indexPath.row]
consentVC.orgID = self.consentslistInfo?.orgID
consentVC.purposeDetails = self.consentslistInfo
consentVC.purposeName = self.purposeInfo?.name ?? ""
consentVC.purposeName = self.purposeInfo?.controllerName ?? ""
self.navigationController?.pushViewController(consentVC, animated: true)
}
}
Expand Down
Loading

0 comments on commit 8cfa25c

Please sign in to comment.