Skip to content

Commit

Permalink
Add user id to bid request (#880)
Browse files Browse the repository at this point in the history
* add userr id to bid request

* change text and add unit test

* fix unit test wonr g name

* change text string to pass unit test
  • Loading branch information
huanzhiNB committed Aug 4, 2023
1 parent 718a2b6 commit 2e9c1ed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ + (nonnull PBMORTBBidRequest *)createORTBBidRequestWithTargeting:(nonnull Target
bidRequest.user.gender = targeting.userGenderDescription;
bidRequest.user.buyeruid = targeting.buyerUID;
bidRequest.user.customdata = targeting.userCustomData;
bidRequest.user.userid = targeting.userID;

if (targeting.userExt) {
bidRequest.user.ext = [targeting.userExt mutableCopy];
Expand Down
3 changes: 3 additions & 0 deletions PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ NS_ASSUME_NONNULL_BEGIN
// Placeholder for exchange-specific extensions to OpenRTB.
@property (nonatomic, strong, nullable) NSMutableDictionary<NSString *, NSObject *> *ext;

//Exchange-specific ID for the user.
@property (nonatomic, copy, nullable) NSString *userid;

- (instancetype)init;

- (void)appendEids:(NSArray<NSDictionary<NSString *, id> *> *)eids;
Expand Down
2 changes: 2 additions & 0 deletions PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary {
ret[@"buyeruid"] = self.buyeruid;
ret[@"keywords"] = self.keywords;
ret[@"customdata"] = self.customdata;
ret[@"id"] = self.userid;

if (self.geo.lat && self.geo.lon) {
ret[@"geo"] = [self.geo toJsonDictionary];
Expand Down Expand Up @@ -72,6 +73,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona
_keywords = jsonDictionary[@"keywords"];
_customdata = jsonDictionary[@"customdata"];
_ext = jsonDictionary[@"ext"];
_userid = jsonDictionary[@"id"];

_geo = [[PBMORTBGeo alloc] initWithJsonDictionary:jsonDictionary[@"geo"]];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,9 @@ class PBMORTBAbstractTest : XCTestCase {
pbmORTBUser.geo.lat = 34.1477849
pbmORTBUser.geo.lon = -118.1445155
pbmORTBUser.ext!["data"] = ["registration_date": "31.02.2021"]
pbmORTBUser.userid = "userid"

codeAndDecode(abstract:pbmORTBUser, expectedString:"{\"ext\":{\"data\":{\"registration_date\":\"31.02.2021\"}},\"gender\":\"M\",\"geo\":{\"lat\":34.1477849,\"lon\":-118.1445155},\"keywords\":\"key1,key2,key3\",\"yob\":1981}")
codeAndDecode(abstract:pbmORTBUser, expectedString:"{\"ext\":{\"data\":{\"registration_date\":\"31.02.2021\"}},\"gender\":\"M\",\"geo\":{\"lat\":34.1477849,\"lon\":-118.1445155},\"id\":\"userid\",\"keywords\":\"key1,key2,key3\",\"yob\":1981}")
}

func testUserEidsToJsonString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ParameterBuilderServiceTest : XCTestCase {
targeting.publisherName = publisherName
targeting.addUserKeyword("keyword1,keyword2")
targeting.addAppKeyword("appKeyword1,appKeyword2")
targeting.userID = "userID"

let sdkConfiguration = Prebid.mock

Expand Down Expand Up @@ -153,7 +154,7 @@ class ParameterBuilderServiceTest : XCTestCase {
}

let expectedOrtb = """
{\"app\":{\"bundle\":\"Mock.Bundle.Identifier\",\"keywords\":\"appKeyword1,appKeyword2\",\"name\":\"MockBundleDisplayName\",\"publisher\":{\"name\":\"Publisher\"},\"storeurl\":\"https:\\/\\/openx.com\"},\"device\":{\(carrier)\"connectiontype\":2,\(deviceExt)\"geo\":{\"lat\":34.149335,\"lon\":-118.1328249,\"type\":1},\"h\":200,\"ifa\":\"abc123\",\"language\":\"ml\",\"lmt\":0,\"make\":\"MockMake\",\(mccmnc)\"model\":\"MockModel\",\"os\":\"MockOS\",\"osv\":\"1.2.3\",\"w\":100},\"imp\":[{\"clickbrowser\":1,\"displaymanager\":\"prebid-mobile\",\"displaymanagerver\":\"MOCK_SDK_VERSION\",\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":1}],\"regs\":{\"coppa\":1,\"ext\":{\"gdpr\":0}},\"user\":{\"buyeruid\":\"buyerUID\",\"customdata\":\"customDataString\",\"ext\":{\"consent\":\"consentstring\"},\"gender\":\"M\",\"keywords\":\"keyword1,keyword2\"}}
{\"app\":{\"bundle\":\"Mock.Bundle.Identifier\",\"keywords\":\"appKeyword1,appKeyword2\",\"name\":\"MockBundleDisplayName\",\"publisher\":{\"name\":\"Publisher\"},\"storeurl\":\"https:\\/\\/openx.com\"},\"device\":{\(carrier)\"connectiontype\":2,\(deviceExt)\"geo\":{\"lat\":34.149335,\"lon\":-118.1328249,\"type\":1},\"h\":200,\"ifa\":\"abc123\",\"language\":\"ml\",\"lmt\":0,\"make\":\"MockMake\",\(mccmnc)\"model\":\"MockModel\",\"os\":\"MockOS\",\"osv\":\"1.2.3\",\"w\":100},\"imp\":[{\"clickbrowser\":1,\"displaymanager\":\"prebid-mobile\",\"displaymanagerver\":\"MOCK_SDK_VERSION\",\"ext\":{\"dlp\":1},\"instl\":0,\"secure\":1}],\"regs\":{\"coppa\":1,\"ext\":{\"gdpr\":0}},\"user\":{\"buyeruid\":\"buyerUID\",\"customdata\":\"customDataString\",\"ext\":{\"consent\":\"consentstring\"},\"gender\":\"M\",\"id\":\"userID\",\"keywords\":\"keyword1,keyword2\"}}
"""
PBMAssertEq(strORTB, expectedOrtb)
}
Expand Down

0 comments on commit 2e9c1ed

Please sign in to comment.