-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Collecting Arbitrary ORTB Parameters #941
Changes from all commits
5c27578
0897cc5
e3b7521
dad6d27
c85bf65
c3c62be
65fa06b
8ec26b3
2f3f6ba
a642064
86cc5df
e52f234
79fde02
b029432
d7ab955
473684e
5579256
452b4e6
8a87df7
c44632a
036bdbb
27747b5
491bca5
0280711
e8c17c0
428e9a5
a9d03e4
88cf61d
8b7b66e
7034d23
be74795
46f53b7
faacf22
843ad3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,58 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { | |
ext[@"prebid"] = [[self.extPrebid toJsonDictionary] nullIfEmpty]; | ||
ret[@"ext"] = [[ext pbmCopyWithoutEmptyVals] nullIfEmpty]; | ||
|
||
//remove "protected" fields from ortbObject then do a merge but merge ret into the ortbObject (addEntriesFromDictionary) | ||
NSMutableDictionary *o = [self.arbitraryJsonConfig mutableCopy]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should avoid such names for variables. |
||
if (o[@"regs"]) { | ||
o[@"regs"] = nil; | ||
} | ||
if (o[@"device"]) { | ||
o[@"device"] = nil; | ||
} | ||
if (o[@"geo"]) { | ||
o[@"geo"] = nil; | ||
} | ||
//merge with config from API/JSON | ||
ret = [self mergeDictionaries: ret joiningArgument2: o joiningArgument3: false]; | ||
|
||
NSMutableDictionary *o2 = [self.ortbObject mutableCopy]; | ||
|
||
if (o2[@"regs"]) { | ||
o2[@"regs"] = nil; | ||
} | ||
if (o2[@"device"]) { | ||
o2[@"device"] = nil; | ||
} | ||
if (o2[@"geo"]) { | ||
o[@"geo"] = nil; | ||
} | ||
//merge with ortbConfig from SDK | ||
ret = [self mergeDictionaries: ret joiningArgument2: o2 joiningArgument3: true]; | ||
|
||
ret = [ret pbmCopyWithoutEmptyVals]; | ||
|
||
return ret; | ||
} | ||
|
||
- (nonnull PBMMutableJsonDictionary *)mergeDictionaries:(NSMutableDictionary*)dictionary1 joiningArgument2:(NSMutableDictionary*)dictionary2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, we can merge dictionaries. This path is faster to implement. However, it makes the solution restricted to such things as
It is not critical, but I would still merge serialized objects. It is a more reliable approach from the support perspective. |
||
joiningArgument3:(Boolean)firstHasPriority{ | ||
PBMMutableJsonDictionary *ret = dictionary1; | ||
|
||
for (id key in dictionary2) | ||
if ([ret objectForKey: key]){ | ||
if ([[ret objectForKey: key] isKindOfClass: [NSDictionary class]]) { | ||
//if is dictionary, need to call this method recursively for ret object for key and dictionary2 for key | ||
[ret setObject:[self mergeDictionaries:[ret objectForKey: key] joiningArgument2: [dictionary2 objectForKey: key] joiningArgument3:firstHasPriority] forKey: key]; | ||
} else { | ||
if (!firstHasPriority) { | ||
[ret setObject:[dictionary2 objectForKey: key] forKey:key]; | ||
} | ||
} | ||
//not sure what to do if array of objects | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this comment. Does it mean that the algorithm doesn't merge part of the data? |
||
} else { | ||
[ret setObject:[dictionary2 objectForKey:key] forKey: key]; | ||
} | ||
|
||
ret = [ret pbmCopyWithoutEmptyVals]; | ||
|
||
return ret; | ||
|
@@ -98,6 +150,8 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona | |
|
||
_extPrebid = [[PBMORTBBidRequestExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"ext"][@"prebid"] ?: @{}]; | ||
|
||
_arbitraryJsonConfig = jsonDictionary; | ||
|
||
return self; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom request should be set as a String.
Publishers should just put the JSON string as a configuration option and not a dictionary.