Skip to content

Commit

Permalink
swift wrapper added
Browse files Browse the repository at this point in the history
  • Loading branch information
nahidfgh committed Nov 27, 2024
1 parent c12b796 commit bb5b255
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions wrappers/swift/Headers/ObjCModule-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "../../obj-c/ODWLogConfiguration.h"
#import "../../obj-c/ODWLogger.h"
#import "../../obj-c/ODWLogManager.h"
#import "../../obj-c/ODWPrivacyConcernMetadataProvider.h"
#import "../../obj-c/ODWPrivacyGuard.h"
#import "../../obj-c/ODWPrivacyGuardInitConfig.h"
#import "../../obj-c/ODWSemanticContext.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//

import ObjCModule

/// Wrapper over ODWPrivacyConcernMetadataProvider class.
public final class PrivacyConcernMetadataProvider {

/// ObjC variable which is wrapped by Swift.
var odwPrivacyConcernMetadataProvider: ODWPrivacyConcernMetadataProvider

/// Constructor initialized with ObjC wrapped object.
init(odwPrivacyConcernMetadataProvider: ODWPrivacyConcernMetadataProvider) {
self.odwPrivacyConcernMetadataProvider = odwPrivacyConcernMetadataProvider
}

/// Default constructor.
public init() {
odwPrivacyConcernMetadataProvider = ODWPrivacyConcernMetadataProvider()
}

/// Get the database name for the provided record.
public func getDatabaseName(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getDatabaseNameForRecord(record)
}

/// Get the server name for the provided record.
public func getServerName(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getServerNameForRecord(record)
}

/// Get the event locator name for the provided record.
public func getEventLocatorName(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getEventLocatorNameForRecord(record)
}

/// Get the event locator value for the provided record.
public func getEventLocatorValue(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getEventLocatorValueForRecord(record)
}

/// Get the override for the privacy guard event time for the provided record.
public func getPrivacyGuardEventTimeOverride(for record: Any) -> Int64 {
return odwPrivacyConcernMetadataProvider.getPrivacyGuardEventTimeOverrideForRecord(record)
}

/// Check if the record should be ignored.
public func getShouldIgnoreOverride(for record: Any) -> Bool {
return odwPrivacyConcernMetadataProvider.getShouldIgnoreOverrideForRecord(record)
}

/// Get the associated tenant for the provided record.
public func getAssociatedTenant(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getAssociatedTenantForRecord(record)
}

/// Get the environment for the provided record.
public func getEnvironment(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getEnvironmentForRecord(record)
}

/// Get the metadata for the provided record.
public func getMetadata(for record: Any) -> String {
return odwPrivacyConcernMetadataProvider.getMetadataForRecord(record)
}
}
15 changes: 14 additions & 1 deletion wrappers/swift/Sources/OneDSSwift/PrivacyGuardInitConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ObjCModule
public final class PrivacyGuardInitConfig {
let odwPrivacyGuardInitConfig: ODWPrivacyGuardInitConfig
private var commonDataContext: CommonDataContext

private var privacyConcernMetadataProvider: PrivacyConcernMetadataProvider
/// Data Context to use with the Privacy Guard.
public var dataContext: CommonDataContext {
get {
Expand All @@ -20,6 +20,17 @@ public final class PrivacyGuardInitConfig {
}
}

/// Metadata provider to use with Privacy Guard.
public var metadataProvider: PrivacyConcernMetadataProvider {
get {
return metadataProvider
}
set {
metadataProvider = newValue
odwPrivacyGuardInitConfig.metadataProvider = privacyConcernMetadataProvider.odwPrivacyConcernMetadataProvider
}
}

/// (OPTIONAL) Custom event name to use when logging privacy concerns. Default value is `PrivacyConcern`.
public var notificationEventName: String {
get {
Expand Down Expand Up @@ -84,6 +95,8 @@ public final class PrivacyGuardInitConfig {
public init() {
odwPrivacyGuardInitConfig = ODWPrivacyGuardInitConfig()
odwPrivacyGuardInitConfig.dataContext = ODWCommonDataContext()
odwPrivacyGuardInitConfig.metadataProvider = ODWPrivacyConcernMetadataProvider()
metadataProvider = PrivacyConcernMetadataProvider(odwPrivacyConcernMetadataProvider: odwPrivacyGuardInitConfig.metadataProvider)
commonDataContext = CommonDataContext(odwCommonDataContext: odwPrivacyGuardInitConfig.dataContext)
}

Expand Down

0 comments on commit bb5b255

Please sign in to comment.