@@ -181,7 +181,7 @@ - (RoktFrameworkType)mapMPWrapperSdkToRoktFrameworkType:(MPWrapperSdk)wrapperSdk
181181 if (filteredUser == nil && roktKit != nil ) {
182182 filteredUser = [[[MPKitAPI alloc ] init ] getCurrentUserWithKit: roktKit];
183183 }
184- NSDictionary <NSString *, NSString *> *mpAttributes = [filteredUser.userAttributes transformValuesToString ];
184+ NSDictionary <NSString *, NSString *> *mpAttributes = [self transformValuesToString: filteredUser.userAttributes];
185185 if (performMapping) {
186186 mpAttributes = [self mapAttributes: attributes filteredUser: filteredUser];
187187 }
@@ -209,6 +209,42 @@ - (RoktFrameworkType)mapMPWrapperSdkToRoktFrameworkType:(MPWrapperSdk)wrapperSdk
209209 return [self confirmSandboxAttribute: finalAtt];
210210}
211211
212+ + (NSDictionary <NSString *, NSString *> *)transformValuesToString : (NSDictionary <NSString *, id> * _Nullable)originalDictionary {
213+ __block NSMutableDictionary <NSString *, NSString *> *transformedDictionary = [[NSMutableDictionary alloc ] initWithCapacity: originalDictionary.count];
214+ Class NSStringClass = [NSString class ];
215+ Class NSNumberClass = [NSNumber class ];
216+
217+ [originalDictionary enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
218+ if ([obj isKindOfClass: NSStringClass]) {
219+ transformedDictionary[key] = obj;
220+ } else if ([obj isKindOfClass: NSNumberClass]) {
221+ NSNumber *numberAttribute = (NSNumber *)obj;
222+
223+ if (numberAttribute == (void *)kCFBooleanFalse || numberAttribute == (void *)kCFBooleanTrue ) {
224+ transformedDictionary[key] = [numberAttribute boolValue ] ? @" true" : @" false" ;
225+ } else {
226+ transformedDictionary[key] = [numberAttribute stringValue ];
227+ }
228+ } else if ([obj isKindOfClass: [NSDate class ]]) {
229+ transformedDictionary[key] = [MPDateFormatter stringFromDateRFC3339: obj];
230+ } else if ([obj isKindOfClass: [NSData class ]] && [(NSData *)obj length ] > 0 ) {
231+ transformedDictionary[key] = [[NSString alloc ] initWithData: obj encoding: NSUTF8StringEncoding];
232+ } else if ([obj isKindOfClass: [NSDictionary class ]]) {
233+ transformedDictionary[key] = [obj description ];
234+ } else if ([obj isKindOfClass: [NSMutableDictionary class ]]) {
235+ transformedDictionary[key] = [obj description ];
236+ } else if ([obj isKindOfClass: [NSArray class ]]) {
237+ transformedDictionary[key] = [obj description ];
238+ } else if ([obj isKindOfClass: [NSMutableArray class ]]) {
239+ transformedDictionary[key] = [obj description ];
240+ } else if ([obj isKindOfClass: [NSNull class ]]) {
241+ transformedDictionary[key] = @" null" ;
242+ }
243+ }];
244+
245+ return transformedDictionary;
246+ }
247+
212248+ (NSDictionary <NSString *, NSString *> *)mapAttributes : (NSDictionary <NSString *, NSString *> * _Nullable)attributes filteredUser : (FilteredMParticleUser * _Nonnull)filteredUser {
213249 NSArray <NSDictionary <NSString *, NSString *> *> *attributeMap = nil ;
214250
@@ -276,7 +312,7 @@ - (RoktFrameworkType)mapMPWrapperSdkToRoktFrameworkType:(MPWrapperSdk)wrapperSdk
276312 }
277313 }
278314
279- return [mappedAttributes transformValuesToString ];
315+ return [self transformValuesToString: mappedAttributes ];
280316 } else {
281317 return attributes;
282318 }
0 commit comments