diff --git a/PrebidMobile.xcodeproj/project.pbxproj b/PrebidMobile.xcodeproj/project.pbxproj index 77276798b..4d8ba8158 100644 --- a/PrebidMobile.xcodeproj/project.pbxproj +++ b/PrebidMobile.xcodeproj/project.pbxproj @@ -529,6 +529,7 @@ 606FAC5222022932008EAE5E /* AdUnitSwizzleHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606FAC5122022932008EAE5E /* AdUnitSwizzleHelper.swift */; }; 60C0381F2204AF5D0082B32C /* DispatcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979177962201AF5F00E624CE /* DispatcherTests.swift */; }; 60C038242204AF5D0082B32C /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97826AA621FB4F1B001E2C05 /* Constants.swift */; }; + 799109FB28F99C2B004837B4 /* PBMORTBAppExt.m in Sources */ = {isa = PBXBuildFile; fileRef = 799109FA28F99C2B004837B4 /* PBMORTBAppExt.m */; }; 92028EA627F0D89E00783470 /* NativeAdConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92028EA527F0D89E00783470 /* NativeAdConfiguration.swift */; }; 920E8D6D28084BF200E6313B /* VideoControlsConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 920E8D6C28084BF200E6313B /* VideoControlsConfigTests.swift */; }; 922AFC61273491F000732C53 /* PBMLocationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5BC376BC271F1CFE00444D5E /* PBMLocationManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1365,6 +1366,8 @@ 60C0382B2204BB190082B32C /* PrebidMobileTest-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PrebidMobileTest-Bridging-Header.h"; sourceTree = ""; }; 60D792FB217E229B0080F428 /* PrebidMobileTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PrebidMobileTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60D79302217E229B0080F428 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 799109FA28F99C2B004837B4 /* PBMORTBAppExt.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PBMORTBAppExt.m; sourceTree = ""; }; + 799109FC28F99C7D004837B4 /* PBMORTBAppExt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PBMORTBAppExt.h; sourceTree = ""; }; 92028EA527F0D89E00783470 /* NativeAdConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeAdConfiguration.swift; sourceTree = ""; }; 920E8D6C28084BF200E6313B /* VideoControlsConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoControlsConfigTests.swift; sourceTree = ""; }; 922AFC8727352B0100732C53 /* MockUserAgentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockUserAgentService.swift; sourceTree = ""; }; @@ -1960,6 +1963,8 @@ 5BC37678271F1CFD00444D5E /* PBMORTBUser.m */, 5BC3768B271F1CFD00444D5E /* PBMORTBVideo.h */, 5BC376A4271F1CFD00444D5E /* PBMORTBVideo.m */, + 799109FA28F99C2B004837B4 /* PBMORTBAppExt.m */, + 799109FC28F99C7D004837B4 /* PBMORTBAppExt.h */, ); path = ORTB; sourceTree = ""; @@ -4083,6 +4088,7 @@ 5BC37A90271F1D0000444D5E /* InterstitialAdUnitDelegate.swift in Sources */, 5BC37A88271F1D0000444D5E /* RewardedAdUnitDelegate.swift in Sources */, 5BC378DB271F1CFF00444D5E /* PBMORTBDeal.m in Sources */, + 799109FB28F99C2B004837B4 /* PBMORTBAppExt.m in Sources */, 925A641627317A39009E72F9 /* HiddenWebViewManager.swift in Sources */, 5BC3796C271F1D0000444D5E /* PBMVastCreativeLinear.m in Sources */, 928E5A7027F0F743000ADA1A /* ContextSubType.swift in Sources */, diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.h index 4cb252f5b..0245769fb 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.h @@ -16,7 +16,7 @@ #import "PBMORTBAbstract.h" @class PBMORTBPublisher; -@class PBMORTBAppExtPrebid; +@class PBMORTBAppExt; @class PBMORTBAppContent; NS_ASSUME_NONNULL_BEGIN @@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN //Placeholder for exchange-specific extensions to OpenRTB. //Note: ext is not supported. -@property (nonatomic, strong) PBMORTBAppExtPrebid *extPrebid; +@property (nonatomic, strong) PBMORTBAppExt *ext; - (instancetype )init; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.m index 505cb48e0..c928ef260 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBApp.m @@ -17,7 +17,7 @@ #import "PBMORTBAbstract+Protected.h" #import "PBMORTBPublisher.h" -#import "PBMORTBAppExtPrebid.h" +#import "PBMORTBAppExt.h" #import "PBMORTBAppContent.h" @implementation PBMORTBApp @@ -30,7 +30,7 @@ - (nonnull instancetype )init { _sectioncat = @[]; _pagecat = @[]; _publisher = [[PBMORTBPublisher alloc] init]; - _extPrebid = [[PBMORTBAppExtPrebid alloc] init]; + _ext = [[PBMORTBAppExt alloc] init]; _content = [[PBMORTBAppContent alloc] init]; return self; @@ -62,11 +62,7 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { ret[@"keywords"] = self.keywords; ret[@"publisher"] = [[self.publisher toJsonDictionary] nullIfEmpty]; ret[@"content"] = [[self.content toJsonDictionary] nullIfEmpty]; - - PBMJsonDictionary * const extPrebidDic = [self.extPrebid toJsonDictionary]; - if (extPrebidDic.count) { - ret[@"ext"] = @{@"prebid": extPrebidDic}; - } + ret[@"ext"] = [[self.ext toJsonDictionary] nullIfEmpty]; [ret pbmRemoveEmptyVals]; @@ -90,7 +86,7 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona _paid = jsonDictionary[@"paid"]; _publisher = [[PBMORTBPublisher alloc] initWithJsonDictionary:jsonDictionary[@"publisher"]]; _keywords = jsonDictionary[@"keywords"]; - _extPrebid = [[PBMORTBAppExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"ext"][@"prebid"]]; + _ext = [[PBMORTBAppExt alloc] initWithJsonDictionary:jsonDictionary[@"ext"]]; _content = [[PBMORTBAppContent alloc] initWithJsonDictionary:jsonDictionary[@"content"]]; return self; diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.h new file mode 100644 index 000000000..0230eede8 --- /dev/null +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.h @@ -0,0 +1,35 @@ +/*   Copyright 2018-2021 Prebid.org, Inc. + +  Licensed under the Apache License, Version 2.0 (the "License"); +  you may not use this file except in compliance with the License. +  You may obtain a copy of the License at + +  http://www.apache.org/licenses/LICENSE-2.0 + +  Unless required by applicable law or agreed to in writing, software +  distributed under the License is distributed on an "AS IS" BASIS, +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +  See the License for the specific language governing permissions and +  limitations under the License. +  */ + +#import "PBMORTBAbstract.h" + +@class PBMORTBAppExtPrebid; + + +NS_ASSUME_NONNULL_BEGIN + +@interface PBMORTBAppExt : PBMORTBAbstract + +@property (nonatomic, strong) PBMORTBAppExtPrebid *prebid; +@property (nonatomic, strong, nullable) NSDictionary *> *data; + +- (instancetype )init; + + + + +@end + +NS_ASSUME_NONNULL_END diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.m new file mode 100644 index 000000000..b614fdcda --- /dev/null +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExt.m @@ -0,0 +1,53 @@ +/*   Copyright 2018-2021 Prebid.org, Inc. + +  Licensed under the Apache License, Version 2.0 (the "License"); +  you may not use this file except in compliance with the License. +  You may obtain a copy of the License at + +  http://www.apache.org/licenses/LICENSE-2.0 + +  Unless required by applicable law or agreed to in writing, software +  distributed under the License is distributed on an "AS IS" BASIS, +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +  See the License for the specific language governing permissions and +  limitations under the License. +  */ + +#import "PBMORTBAppExtPrebid.h" +#import "PBMORTBAppExt.h" +#import "PBMORTBAbstract+Protected.h" + +@implementation PBMORTBAppExt + +- (nonnull instancetype )init { + if (!(self = [super init])) { + return nil; + } + + _prebid = [[PBMORTBAppExtPrebid alloc] init]; + + return self; +} + +- (nonnull PBMJsonDictionary *)toJsonDictionary { + PBMMutableJsonDictionary *ret = [PBMMutableJsonDictionary new]; + PBMJsonDictionary * const extPrebidDic = [self.prebid toJsonDictionary]; + if (extPrebidDic.count) { + ret[@"prebid"] = extPrebidDic; + } + + ret[@"data"] = self.data; + return ret; +} + +- (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictionary { + if (!(self = [self init])) { + return nil; + } + _data = jsonDictionary[@"data"]; + _prebid = [[PBMORTBAppExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"prebid"]]; + return self; +} + + +@end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.h b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.h index f6f2ee761..ef4685c7e 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.h +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.h @@ -21,7 +21,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, nullable) NSString *source; @property (nonatomic, copy, nullable) NSString *version; -@property (nonatomic, strong, nullable) NSDictionary *> *data; @end diff --git a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.m b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.m index 7f322968b..0f7766dd3 100644 --- a/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.m +++ b/PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBAppExtPrebid.m @@ -22,7 +22,6 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary { PBMMutableJsonDictionary *ret = [PBMMutableJsonDictionary new]; ret[@"source"] = self.source; ret[@"version"] = self.version; - ret[@"data"] = self.data; return ret; } @@ -32,7 +31,6 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona } _source = jsonDictionary[@"source"]; _version = jsonDictionary[@"version"]; - _data = jsonDictionary[@"data"]; return self; } diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m index 4ee33dde6..22afb2426 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/PBMPrebidParameterBuilder.m @@ -25,6 +25,7 @@ #import "PBMWinNotifierBlock.h" #import "PBMORTBAppContent.h" +#import "PBMORTBAppExt.h" #import "PrebidMobileSwiftHeaders.h" #import @@ -132,8 +133,9 @@ - (void)buildBidRequest:(nonnull PBMORTBBidRequest *)bidRequest { bidRequest.user.data = userData; } - PBMORTBAppExtPrebid * const appExtPrebid = bidRequest.app.extPrebid; - appExtPrebid.data = self.targeting.contextDataDictionary; + PBMORTBAppExt * const appExt = bidRequest.app.ext; + PBMORTBAppExtPrebid * const appExtPrebid = appExt.prebid; + appExt.data = self.targeting.contextDataDictionary; for (PBMORTBImp *nextImp in bidRequest.imp) { nextImp.impID = [NSUUID UUID].UUIDString; diff --git a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift index 8e292d072..a74b7b020 100644 --- a/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/PBMORTBAbstractTest.swift @@ -424,17 +424,17 @@ class PBMORTBAbstractTest : XCTestCase { func testAppExtPrebidToJsonString() { let pbmORTBApp = PBMORTBApp() - let appExtPrebid = pbmORTBApp.extPrebid + let appExtPrebid = pbmORTBApp.ext.prebid codeAndDecode(abstract: appExtPrebid, expectedString: "{}") appExtPrebid.source = "openx" appExtPrebid.version = sdkVersion - appExtPrebid.data = ["app_categories": ["news", "movies"]] + pbmORTBApp.ext.data = ["app_categories": ["news", "movies"]] - codeAndDecode(abstract: appExtPrebid, expectedString: "{\"data\":{\"app_categories\":[\"news\",\"movies\"]},\"source\":\"openx\",\"version\":\"\(sdkVersion)\"}") + codeAndDecode(abstract: appExtPrebid, expectedString: "{\"source\":\"openx\",\"version\":\"\(sdkVersion)\"}") - codeAndDecode(abstract: pbmORTBApp, expectedString: "{\"ext\":{\"prebid\":{\"data\":{\"app_categories\":[\"news\",\"movies\"]},\"source\":\"openx\",\"version\":\"\(sdkVersion)\"}}}") + codeAndDecode(abstract: pbmORTBApp, expectedString: "{\"ext\":{\"data\":{\"app_categories\":[\"news\",\"movies\"]},\"prebid\":{\"source\":\"openx\",\"version\":\"\(sdkVersion)\"}}}") } func testDeviceWithIfaToJsonString() { diff --git a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift index cc9ce94e2..78a66dd5f 100644 --- a/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift +++ b/PrebidMobileTests/RenderingTests/Tests/ParameterBuilderTests/PrebidParameterBuilderTest.swift @@ -179,7 +179,7 @@ class PrebidParameterBuilderTest: XCTestCase { XCTAssertEqual(2, objects.count) XCTAssertEqual(objects.first, userDataObject1) - let extData = bidRequest.app.extPrebid.data! + let extData = bidRequest.app.ext.data! XCTAssertTrue(extData.keys.count == 1) let extValues = extData["last_search_keywords"]!.sorted() XCTAssertEqual(extValues, ["pet", "wolf"])