-
Notifications
You must be signed in to change notification settings - Fork 49
/
ODWSemanticContext.mm
105 lines (89 loc) · 3.14 KB
/
ODWSemanticContext.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#import <Foundation/Foundation.h>
#import "ODWSemanticContext.h"
#import "ODWSemanticContext_private.h"
#include "ISemanticContext.hpp"
using namespace MAT;
@implementation ODWSemanticContext
{
ISemanticContext* _wrappedSemanticContext;
}
-(instancetype)initWithISemanticContext:(ISemanticContext*)context
{
self = [super init];
if(self){
_wrappedSemanticContext = context;
}
return self;
}
-(void)setAppId:(nonnull NSString *)appId
{
std::string strAppId = std::string([appId UTF8String]);
_wrappedSemanticContext->SetAppId(strAppId);
}
-(void) setAppVersion:(nonnull NSString*)appVersion
{
std::string strAppVersion = std::string([appVersion UTF8String]);
_wrappedSemanticContext->SetAppVersion(strAppVersion);
}
-(void) setAppLanguage:(nonnull NSString*)appLanguage
{
std::string strAppLanguage = std::string([appLanguage UTF8String]);
_wrappedSemanticContext->SetAppLanguage(strAppLanguage);
}
-(void)setUserId:(nonnull NSString *)userId
{
[self setUserId:userId piiKind:ODWPiiKindIdentity];
}
-(void) setUserId:(nonnull NSString*)userId
piiKind:(enum ODWPiiKind)pii
{
if (pii == ODWPiiKindNone || pii == ODWPiiKindIdentity) {
PiiKind piiValue = PiiKind(pii);
std::string strUserId = std::string([userId UTF8String]);
_wrappedSemanticContext->SetUserId(strUserId, piiValue);
} else {
[NSException raise:@"1DSSDKException" format:@"Invalid Pii type is passed. Expected ODWPiiKindNone or ODWPiiKindIdentity only."];
}
}
-(void) setDeviceId:(nonnull NSString*)deviceId
{
std::string strDeviceId = std::string([deviceId UTF8String]);
_wrappedSemanticContext->SetDeviceId(strDeviceId);
}
-(void) setUserTimeZone:(nonnull NSString*)userTimeZone
{
std::string strUserTimeZone = std::string([userTimeZone UTF8String]);
_wrappedSemanticContext->SetUserTimeZone(strUserTimeZone);
}
-(void)setUserAdvertisingId:(nonnull NSString *)userAdvertisingId
{
std::string strUserAdvertisingId = std::string([userAdvertisingId UTF8String]);
_wrappedSemanticContext->SetUserAdvertisingId(strUserAdvertisingId);
}
-(void)setAppExperimentIds:(nonnull NSString*)experimentIds
{
std::string strAppExperimentIds = std::string([experimentIds UTF8String]);
_wrappedSemanticContext->SetAppExperimentIds(strAppExperimentIds);
}
-(void)setAppExperimentIds:(nonnull NSString*)experimentIds
forEvent:(nonnull NSString*)eventName
{
std::string strAppExperimentIds = std::string([experimentIds UTF8String]);
std::string stEventName = std::string([eventName UTF8String]);
_wrappedSemanticContext->SetEventExperimentIds(stEventName, strAppExperimentIds);
}
-(void)setAppExperimentETag:(nonnull NSString *)eTag
{
std::string strETag = std::string([eTag UTF8String]);
_wrappedSemanticContext->SetAppExperimentETag(strETag);
}
-(void)setAppExperimentImpressionId:(nonnull NSString*)impressionId
{
std::string strImpressionId = std::string([impressionId UTF8String]);
_wrappedSemanticContext->SetAppExperimentImpressionId(strImpressionId);
}
@end