Java源码示例:com.google.openrtb.OpenRtb.BidRequest.App

示例1
/**
 * Configures a JSON factory with support for the {@link AdxExt} extensions.
 */
public static OpenRtbJsonFactory registerAdxExt(OpenRtbJsonFactory factory) {
  return factory
      .register(new BidRequestExtReader(), BidRequest.Builder.class)
      .register(new BidRequestExtWriter(), BidRequestExt.class, BidRequest.class)
      .register(new ImpExtReader(), Imp.Builder.class)
      .register(new ImpExtWriter(), ImpExt.class, Imp.class)
      .register(new BidExtReader(), Bid.Builder.class)
      .register(new BidExtWriter(), BidExt.class, Bid.class)
      .register(new BidResponseExtReader(), BidResponse.Builder.class)
      .register(new BidResponseExtWriter(), BidResponseExt.class, BidResponse.class)
      .register(new SiteExtReader(), Site.Builder.class)
      .register(new SiteExtWriter(), SiteExt.class, Site.class)
      .register(new AppExtReader(), App.Builder.class)
      .register(new AppExtWriter(), AppExt.class, App.class)
      .register(new NativeRequestExtReader(), NativeRequest.Builder.class)
      .register(new NativeRequestExtWriter(), NativeRequestExt.class, NativeRequest.class)
      .register(new UserExtReader(), User.Builder.class)
      .register(new UserExtWriter(), UserExt.class, User.class)
      .register(new RegsExtReader(), Regs.Builder.class)
      .register(new RegsExtWriter(), RegsExt.class, Regs.class)
      .register(new EventTrackerExtReader(), EventTracker.Builder.class)
      .register(new EventTrackerExtWriter(), EventTrackerExt.class, EventTracker.class)
      .register(new DealExtReader(), Deal.Builder.class)
      .register(new DealExtWriter(), DealExt.class, Deal.class);
}
 
示例2
static App.Builder newApp() {
  return App.newBuilder()
      .setId("PewDiePie")
      .setName("CNN App")
      .setDomain("cnn.com")
      .addCat("IAB1")
      .addSectioncat("IAB1-1")
      .addPagecat("IAB1-2")
      .setVer("1.0")
      .setBundle("com.cnn.app")
      .setPrivacypolicy(true)
      .setPaid(false)
      .setPublisher(Publisher.newBuilder().setId("pub9"))
      .setContent(Content.newBuilder().setId("cont9"))
      .setKeywords("news,politics")
      .setStoreurl("http://appstore.com/cnn")
      .setExtension(TestExt.testApp, test1);
}
 
示例3
public final App.Builder readApp(JsonParser par) throws IOException {
  App.Builder app = App.newBuilder();
  for (startObject(par); endObject(par); par.nextToken()) {
    String name = getCurrentName(par);
    if (par.nextToken() != JsonToken.VALUE_NULL) {
      readAppField(par, app, name);
    }
  }
  return app;
}
 
示例4
protected void writeAppFields(App app, JsonGenerator gen) throws IOException {
  if (app.hasId()) {
    gen.writeStringField("id", app.getId());
  }
  if (app.hasName()) {
    gen.writeStringField("name", app.getName());
  }
  if (app.hasBundle()) {
    gen.writeStringField("bundle", app.getBundle());
  }
  if (app.hasDomain()) {
    gen.writeStringField("domain", app.getDomain());
  }
  if (app.hasStoreurl()) {
    gen.writeStringField("storeurl", app.getStoreurl());
  }
  writeContentCategories("cat", app.getCatList(), gen);
  writeContentCategories("sectioncat", app.getSectioncatList(), gen);
  writeContentCategories("pagecat", app.getPagecatList(), gen);
  if (app.hasVer()) {
    gen.writeStringField("ver", app.getVer());
  }
  if (app.hasPrivacypolicy()) {
    writeIntBoolField("privacypolicy", app.getPrivacypolicy(), gen);
  }
  if (app.hasPaid()) {
    writeIntBoolField("paid", app.getPaid(), gen);
  }
  if (app.hasPublisher()) {
    gen.writeFieldName("publisher");
    writePublisher(app.getPublisher(), gen);
  }
  if (app.hasContent()) {
    gen.writeFieldName("content");
    writeContent(app.getContent(), gen);
  }
  if (app.hasKeywords()) {
    gen.writeStringField("keywords", app.getKeywords());
  }
}
 
示例5
@SuppressWarnings("deprecation")
@Test
public void testRequest_emptyMessages() throws IOException {
  OpenRtbJsonFactory jsonFactory = newJsonFactory();
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0").build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0"))
      .setDevice(Device.newBuilder())
      .setApp(App.newBuilder())
      .setUser(User.newBuilder())
      .setRegs(Regs.newBuilder())
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder())
          .setPmp(Pmp.newBuilder()))
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder()
              .addFormat(Banner.Format.newBuilder())))
      .setDevice(Device.newBuilder().setGeo(Geo.newBuilder()))
      .setSite(Site.newBuilder())
      .setUser(User.newBuilder().addData(Data.newBuilder()))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder())
          .setAudio(Audio.newBuilder())
          .setPmp(Pmp.newBuilder().addDeals(Pmp.Deal.newBuilder().setId("0"))))
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder().setCompanionad21(Video.CompanionAd.newBuilder())))
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder())
          .setPublisher(Publisher.newBuilder()))
          .setUser(User.newBuilder().addData(Data.newBuilder().addSegment(Segment.newBuilder())))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder().setProducer(Producer.newBuilder())))
      .build());
}
 
示例6
@Test
public void testRequest() throws IOException {
  testRequest(BidRequest.newBuilder()
      .setId("0")
      .addImp(Imp.newBuilder()
          .setId("1")
          .setNative(Native.newBuilder()
              .setRequestNative(NativeRequest.newBuilder()
                    .setExtension(AdxExt.nativeExt, NativeRequestExt.newBuilder()
                        .setStyleId(12)
                        .setStyleWidth(200)
                        .setStyleHeight(100)
                        .setStyleLayoutType(LayoutType.PIXEL)
                        .build())))
          .setPmp(Pmp.newBuilder()
              .addDeals(Deal.newBuilder()
                  .setId("deal")
                  .setExtension(AdxExt.deal, DealExt.newBuilder()
                      .setDealType(DealType.PREFERRED_DEAL)
                      .setMustBid(true)
                      .setPublisherBlocksOverridden(true)
                      .build())))
          .setExtension(AdxExt.imp, ImpExt.newBuilder()
              .addAllBillingId(asList(100L, 101L, 999999999999999999L))
              .addAllPublisherSettingsListId(asList(200L, 201L, 8888888888888888888L))
              .addAllAllowedVendorType(asList(300, 301, 302))
              .addAllPublisherParameter(asList("a", "b", "c"))
              .setDfpAdUnitCode("abc")
              .setIsRewardedInventory(true)
              .setAmpad(AmpAdRequirementType.AMP_AD_REQUIRED)
              .addBuyerGeneratedRequestData(BuyerGeneratedRequestData.newBuilder()
                  .setSourceApp(SourceApp.newBuilder().setId("bgr-sa"))
                  .setData("bgr-data"))
              .addAllExcludedCreatives(asList(
                  ExcludedCreative.newBuilder().setBuyerCreativeId("cr1").build(),
                  ExcludedCreative.newBuilder().setBuyerCreativeId("cr2").build()))
              .setOpenBidding(OpenBidding.newBuilder().setIsOpenBidding(true))
              .addAllAllowedRestrictedCategory(asList(401, 402, 403))
              .build()))
      .setSite(Site.newBuilder()
          .setDomain("mysite.com")
          .setExtension(AdxExt.site, SiteExt.newBuilder()
              .setAmp(SiteExt.AmpPage.DIALECT_HTML_AMP)
              .build()))
      .setApp(App.newBuilder()
          .setExtension(AdxExt.app, AppExt.newBuilder()
              .addInstalledSdk(InstalledSdk.newBuilder()
                  .setId("sdk1")
                  .setSdkVersion(Version.newBuilder().setMajor(1).setMinor(2).setMicro(3))
                  .setAdapterVersion(Version.newBuilder().setMajor(1).setMinor(2)))
              .build()))
      .setUser(User.newBuilder()
          .setExtension(AdxExt.user, UserExt.newBuilder()
              .setConsentedProvidersSettings(ConsentedProvidersSettings.newBuilder()
                  .addAllConsentedProviders(asList(100L, 101L)))
              .build()))
      .setRegs(Regs.newBuilder()
          .setExtension(AdxExt.regs, RegsExt.newBuilder().setGdpr(true).build()))
      .setExtension(AdxExt.bidRequest, BidRequestExt.newBuilder()
          .addBidFeedback(BidFeedback.newBuilder()
              .setBuyerCreativeId("cr1")
              .setCreativeStatusCode(99)
              .setPrice(1.2)
              .setMinimumBidToWin(1.0)
              .setRequestId("req1")
              .setEventNotificationToken(
                  BidFeedback.EventNotificationToken.newBuilder().setPayload("data"))
              .setSampledMediationCpmAheadOfAuctionWinner(2.3))
          .setGoogleQueryId("gq1")
          .build())
      .build());
}
 
示例7
public final void writeApp(App app, JsonGenerator gen) throws IOException {
  gen.writeStartObject();
  writeAppFields(app, gen);
  writeExtensions(app, gen);
  gen.writeEndObject();
}
 
示例8
static OpenRtbJsonFactory registerBidRequestExt(OpenRtbJsonFactory factory) {
  return factory
      // Readers
      .register(new Test1Reader<>(TestExt.testRequest1), BidRequest.Builder.class)
      .register(new Test2Reader<>(TestExt.testRequest2, "test2ext"), BidRequest.Builder.class)
      .register(new Test1Reader<>(TestExt.testApp), App.Builder.class)
      .register(new Test1Reader<>(TestExt.testContent), Content.Builder.class)
      .register(new Test1Reader<>(TestExt.testProducer), Producer.Builder.class)
      .register(new Test1Reader<>(TestExt.testPublisher), Publisher.Builder.class)
      .register(new Test1Reader<>(TestExt.testDevice), Device.Builder.class)
      .register(new Test1Reader<>(TestExt.testGeo), Geo.Builder.class)
      .register(new Test1Reader<>(TestExt.testImp), Imp.Builder.class)
      .register(new Test1Reader<>(TestExt.testMetric), Imp.Metric.Builder.class)
      .register(new Test1Reader<>(TestExt.testBanner), Banner.Builder.class)
      .register(new Test1Reader<>(TestExt.testFormat), Banner.Format.Builder.class)
      .register(new Test1Reader<>(TestExt.testNative), Native.Builder.class)
      .register(new Test1Reader<>(TestExt.testPmp), Pmp.Builder.class)
      .register(new Test1Reader<>(TestExt.testDeal), Pmp.Deal.Builder.class)
      .register(new Test1Reader<>(TestExt.testVideo), Video.Builder.class)
      .register(new Test1Reader<>(TestExt.testCompanionAd), Video.CompanionAd.Builder.class)
      .register(new Test1Reader<>(TestExt.testAudio), Audio.Builder.class)
      .register(new Test1Reader<>(TestExt.testRegs), Regs.Builder.class)
      .register(new Test1Reader<>(TestExt.testSite), Site.Builder.class)
      .register(new Test1Reader<>(TestExt.testSource), Source.Builder.class)
      .register(new Test1Reader<>(TestExt.testUser), User.Builder.class)
      .register(new Test1Reader<>(TestExt.testData), Data.Builder.class)
      .register(new Test1Reader<>(TestExt.testSegment), Data.Segment.Builder.class)
      // Writers
      .register(new Test1Writer(), Test.Test1.class, BidRequest.class)
      .register(new Test2Writer("test2ext"), Test.Test2.class, BidRequest.class)
      .register(new Test1Writer(), Test.Test1.class, App.class)
      .register(new Test1Writer(), Test.Test1.class, Device.class)
      .register(new Test1Writer(), Test.Test1.class, Site.class)
      .register(new Test1Writer(), Test.Test1.class, User.class)
      .register(new Test1Writer(), Test.Test1.class, Geo.class)
      .register(new Test1Writer(), Test.Test1.class, Data.class)
      .register(new Test1Writer(), Test.Test1.class, Data.Segment.class)
      .register(new Test1Writer(), Test.Test1.class, Publisher.class)
      .register(new Test1Writer(), Test.Test1.class, Content.class)
      .register(new Test1Writer(), Test.Test1.class, Producer.class)
      .register(new Test1Writer(), Test.Test1.class, Imp.class)
      .register(new Test1Writer(), Test.Test1.class, Imp.Metric.class)
      .register(new Test1Writer(), Test.Test1.class, Banner.class)
      .register(new Test1Writer(), Test.Test1.class, Banner.Format.class)
      .register(new Test1Writer(), Test.Test1.class, Video.class)
      .register(new Test1Writer(), Test.Test1.class, Video.CompanionAd.class)
      .register(new Test1Writer(), Test.Test1.class, Audio.class)
      .register(new Test1Writer(), Test.Test1.class, Native.class)
      .register(new Test1Writer(), Test.Test1.class, Pmp.class)
      .register(new Test1Writer(), Test.Test1.class, Pmp.Deal.class)
      .register(new Test1Writer(), Test.Test1.class, Regs.class)
      .register(new Test1Writer(), Test.Test1.class, Source.class);
}