Skip to content

Commit

Permalink
Merge pull request #127 from decentralised-dataexchange/feature/123-M…
Browse files Browse the repository at this point in the history
…ake-PrivacyDashboard-sdk-exposed-variables-aligned

Feature/123 make privacy dashboard sdk exposed variables aligned
  • Loading branch information
georgepadayatti authored Nov 7, 2023
2 parents 7b4cdd2 + 415de17 commit f9697b4
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import Foundation

public class BBConsentPrivacyDashboardiOS: UIViewController {

public static var shared = BBConsentPrivacyDashboardiOS()
class BBConsentPrivacyDashboardiOS: UIViewController {
static var shared = BBConsentPrivacyDashboardiOS()
public var turnOnUserRequests = false
public var turnOnAskMeSection = false
public var turnOnAttributeDetailScreen = false
Expand All @@ -20,11 +19,11 @@ public class BBConsentPrivacyDashboardiOS: UIViewController {
var userId: String?
var hideBackButton = false

public func log() {
func log() {
debugPrint("### Log from PrivacyDashboardiOS SDK.")
}

public func show(organisationId: String, apiKey: String, userId: String, animate: Bool = true) {
func show(organisationId: String, apiKey: String, userId: String, animate: Bool = true) {
if #available(iOS 13.0, *) {
let appearance = UIView.appearance()
appearance.overrideUserInterfaceStyle = .light
Expand Down
79 changes: 79 additions & 0 deletions PrivacyDashboardiOS/Classes/PrivacyDashboard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// PrivacyDashboard.swift
// PrivacyDashboardiOS
//
// Created by Mumthasir mohammed on 06/11/23.
//

import Foundation

public class PrivacyDashboard {
// MARK: - Invoking 'PrivacyDashboard' iOS SDK
public static func showPrivacyDashboard(withApiKey: String, withUserId: String, withOrgId: String, withBaseUrl: String, turnOnAske: Bool, turnOnUserRequest: Bool, turnOnAttributeDetail: Bool) {
BBConsentPrivacyDashboardiOS.shared.turnOnUserRequests = turnOnUserRequest
BBConsentPrivacyDashboardiOS.shared.turnOnAskMeSection = turnOnAske
BBConsentPrivacyDashboardiOS.shared.turnOnAttributeDetailScreen = turnOnAttributeDetail
BBConsentPrivacyDashboardiOS.shared.baseUrl = withBaseUrl
BBConsentPrivacyDashboardiOS.shared.show(organisationId: withOrgId, apiKey: withApiKey, userId: withUserId)
}

// MARK: - 'Individual' related api calls
public static func createAnIndividual(id:String?, externalId:String?, externalIdType: String?, identityProviderId: String?, name: String, iamId: String?, email: String, phone:String, completionBlock:@escaping (_ success: Bool, _ resultVal: [String: Any]) -> Void) {
let individual = Individual(id: id, externalID: externalId, externalIDType: externalId, identityProviderID: identityProviderId, name: name, iamID: iamId, email: email, phone: phone)
let record = IndividualRecord(individual: individual)
let data = try! JSONEncoder.init().encode(record)
let dictionary = try! JSONSerialization.jsonObject(with: data) as! [String: Any]

BBConsentBaseWebService.shared.makeAPICall(urlString: Constant.URLStrings.createIndividual, parameters: dictionary, method: .post) { success, resultVal in
if success {
debugPrint(resultVal)
completionBlock(true, resultVal)

} else {
debugPrint(resultVal)
completionBlock(false, resultVal)
}
}
}

public static func readAnIndividual(individualId: String, completionBlock:@escaping (_ success: Bool, _ resultVal: [String: Any]) -> Void) {
BBConsentBaseWebService.shared.makeAPICall(urlString: Constant.URLStrings.readIndividual + individualId, parameters: [:], method: .get) { success, resultVal in
if success {
debugPrint(resultVal)
completionBlock(true, resultVal)
} else {
debugPrint(resultVal)
completionBlock(false, resultVal)
}
}
}

public static func updateAnIndividual(individualId: String, externalId:String?, externalIdType: String?, identityProviderId: String?, name: String, iamId: String?, email: String, phone:String, completionBlock:@escaping (_ success: Bool, _ resultVal: [String: Any]) -> Void) {
let individual = Individual(id: individualId, externalID: externalId, externalIDType: externalId, identityProviderID: identityProviderId, name: name, iamID: iamId, email: email, phone: phone)
let record = IndividualRecord(individual: individual)
let data = try! JSONEncoder.init().encode(record)
let dictionary = try! JSONSerialization.jsonObject(with: data) as! [String: Any]

BBConsentBaseWebService.shared.makeAPICall(urlString: Constant.URLStrings.readIndividual + individualId, parameters: dictionary ,method: .put) { success, resultVal in
if success {
debugPrint(resultVal)
completionBlock(true, resultVal)
} else {
debugPrint(resultVal)
completionBlock(false, resultVal)
}
}
}

public static func fetchAllIndividuals(completionBlock:@escaping (_ success: Bool, _ resultVal: [String: Any]) -> Void) {
BBConsentBaseWebService.shared.makeAPICall(urlString: Constant.URLStrings.fetchAllIndividuals, parameters: [:] ,method: .get) { success, resultVal in
if success {
debugPrint(resultVal)
completionBlock(true, resultVal)
} else {
debugPrint(resultVal)
completionBlock(false, resultVal)
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

}

override func viewDidAppear(_ animated: Bool) {
// Invoking 'BBConsentPrivacyDashboardiOS' SDK
BBConsentPrivacyDashboardiOS.shared.turnOnUserRequests = false
BBConsentPrivacyDashboardiOS.shared.turnOnAskMeSection = false
BBConsentPrivacyDashboardiOS.shared.turnOnAttributeDetailScreen = false
BBConsentPrivacyDashboardiOS.shared.baseUrl = "https://staging-consent-bb-api.igrant.io/v2"
BBConsentPrivacyDashboardiOS.shared.show(organisationId: "64f09f778e5f3800014a879a", apiKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY1MjY1Nzk2OTM4MGYzNWZhMWMzMDI0NSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTI2NTc5NjkzODBmMzVmYTFjMzAyNDMiLCJleHAiOjE3MDA3MjkxOTF9.2rkHNiLDjQi8WOy4CWn96sMBx8KkvFCUMU0Xe6oXNbY", userId: "65378403b3f442eb9381b38d")
PrivacyDashboard.showPrivacyDashboard(withApiKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTY29wZXMiOlsic2VydmljZSJdLCJPcmdhbmlzYXRpb25JZCI6IjY1MjY1Nzk2OTM4MGYzNWZhMWMzMDI0NSIsIk9yZ2FuaXNhdGlvbkFkbWluSWQiOiI2NTI2NTc5NjkzODBmMzVmYTFjMzAyNDMiLCJleHAiOjE3MDA3MjkxOTF9.2rkHNiLDjQi8WOy4CWn96sMBx8KkvFCUMU0Xe6oXNbY", withUserId: "65378403b3f442eb9381b38d", withOrgId: "64f09f778e5f3800014a879a", withBaseUrl: "https://staging-consent-bb-api.igrant.io/v2", turnOnAske: false, turnOnUserRequest: false, turnOnAttributeDetail: false)
}

override func didReceiveMemoryWarning() {
Expand Down
2 changes: 1 addition & 1 deletion PrivacyDashboardiOS/PrivacyDashboardiOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PrivacyDashboardiOS'
s.version = '2023.11.3'
s.version = '2023.11.4'
s.summary = 'Govstack PrivacyDashboard SDKs – Effortlessly embed a comprehensive privacy dashboard into any mobile application out of the box, ensuring adherence to Govstacks consent management framework. Prioritise user trust and transparency with this seamless integration tool.'

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit f9697b4

Please sign in to comment.