Search in sources :

Example 11 with BidResponse

use of com.xrtb.pojo.BidResponse in project XRTB by benmfaul.

the class Creative method createSample.

/**
	 * Creates a sample of the ADM field, useful for testing your ad markup to
	 * make sure it works.
	 * 
	 * @param camp
	 *            Campaign. The campaign to use with this creative.
	 * @return String. The ad markup HTML.
	 */
public String createSample(Campaign camp) {
    BidRequest request = new Nexage();
    String page = null;
    String str = null;
    File temp = null;
    Impression imp = new Impression();
    imp.w = 666;
    imp.h = 666;
    BidResponse br = null;
    try {
        if (this.isVideo()) {
            br = new BidResponse(request, imp, camp, this, "123", 1.0, null, 0);
            imp.video = new Video();
            imp.video.linearity = this.videoLinearity;
            imp.video.protocol.add(this.videoProtocol);
            imp.video.maxduration = this.videoDuration + 1;
            imp.video.minduration = this.videoDuration - 1;
            str = br.getAdmAsString();
            /**
				 * Read in the stubbed video page and patch the VAST into it
				 */
            page = new String(Files.readAllBytes(Paths.get("web/videostub.html")), StandardCharsets.UTF_8);
            page = page.replaceAll("___VIDEO___", "http://localhost:8080/vast/onion270.xml");
        } else if (this.isNative()) {
            // br = new BidResponse(request, camp, this,"123",0);
            // request.nativead = true;
            // request.nativePart = new NativePart();
            // str = br.getAdmAsString();
            page = "<html><title>Test Creative</title><body><img src='images/under-construction.gif'></img></body></html>";
        } else {
            br = new BidResponse(request, imp, camp, this, "123", 1.0, null, 0);
            str = br.getAdmAsString();
            page = "<html><title>Test Creative</title><body><xmp>" + str + "</xmp>" + str + "</body></html>";
        }
        page = page.replaceAll("\\{AUCTION_PRICE\\}", "0.2");
        page = page.replaceAll("\\$", "");
        temp = File.createTempFile("test", ".html", new File("www/temp"));
        temp.deleteOnExit();
        Files.write(Paths.get(temp.getAbsolutePath()), page.getBytes());
    } catch (Exception error) {
        error.printStackTrace();
    }
    return "temp/" + temp.getName();
}
Also used : Video(com.xrtb.pojo.Video) Impression(com.xrtb.pojo.Impression) BidResponse(com.xrtb.pojo.BidResponse) File(java.io.File) BidRequest(com.xrtb.pojo.BidRequest) Nexage(com.xrtb.exchanges.Nexage)

Example 12 with BidResponse

use of com.xrtb.pojo.BidResponse in project XRTB by benmfaul.

the class Appnexus method buildNewBidResponse.

@Override
public BidResponse buildNewBidResponse(Impression imp, List<SelectedCreative> multi, int xtime) throws Exception {
    for (int i = 0; i < multi.size(); i++) {
        SelectedCreative x = multi.get(i);
        Creative c = x.getCreative();
        if (c.extensions == null || c.extensions.size() == 0)
            throw new Exception(x.getCampaign().adId + "/" + c.impid + " is missing required extensions for Appnexus SSP");
        String adid = c.extensions.get("appnexus_crid");
        if (adid == null)
            adid = "invalid:unassigned";
        c.alternateAdId = adid;
    }
    BidResponse response = new BidResponse(this, imp, multi, xtime);
    StringBuilder sb = response.getResponseBuffer();
    return response;
}
Also used : Creative(com.xrtb.common.Creative) SelectedCreative(com.xrtb.bidder.SelectedCreative) SelectedCreative(com.xrtb.bidder.SelectedCreative) BidResponse(com.xrtb.pojo.BidResponse)

Example 13 with BidResponse

use of com.xrtb.pojo.BidResponse in project XRTB by benmfaul.

the class Record method getInstance.

public static synchronized Record getInstance(Object x) {
    long time = 0;
    long wins = 0;
    long bids = 0;
    long requests = 0;
    double bidPrice = 0;
    double winCost = 0;
    if (x instanceof Map) {
        Map r = (Map) x;
        r = (Map) r.get("ext");
        time = (long) r.get("timestamp");
        requests++;
    } else if (x instanceof BidResponse) {
        BidResponse r = (BidResponse) x;
        time = r.utc;
        bids++;
        bidPrice = r.cost;
    } else if (x instanceof WinObject) {
        WinObject r = (WinObject) x;
        time = r.utc;
        wins++;
        winCost = Double.parseDouble(r.price);
    }
    Date date = new Date(time);
    String key = format.format(date);
    Record r = records.get(key);
    if (r == null) {
        r = new Record(x);
        records.put(key, r);
    }
    r.bidPrice.add(bidPrice);
    r.winPrice.add(winCost);
    r.bids.add(bids);
    r.wins.add(wins);
    r.requests.add(requests);
    return r;
}
Also used : WinObject(com.xrtb.pojo.WinObject) BidResponse(com.xrtb.pojo.BidResponse) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Aggregations

BidResponse (com.xrtb.pojo.BidResponse)13 WinObject (com.xrtb.pojo.WinObject)4 Campaign (com.xrtb.common.Campaign)3 Creative (com.xrtb.common.Creative)3 BidRequest (com.xrtb.pojo.BidRequest)3 Impression (com.xrtb.pojo.Impression)3 SelectedCreative (com.xrtb.bidder.SelectedCreative)2 RTopic (com.xrtb.jmq.RTopic)2 NobidResponse (com.xrtb.pojo.NobidResponse)2 ArrayList (java.util.ArrayList)2 AerospikeHandler (com.aerospike.redisson.AerospikeHandler)1 ZPublisher (com.xrtb.bidder.ZPublisher)1 PixelClickConvertLog (com.xrtb.commands.PixelClickConvertLog)1 HttpPostGet (com.xrtb.common.HttpPostGet)1 Node (com.xrtb.common.Node)1 DataBaseObject (com.xrtb.db.DataBaseObject)1 Nexage (com.xrtb.exchanges.Nexage)1 Bid (com.xrtb.pojo.Bid)1 Video (com.xrtb.pojo.Video)1 File (java.io.File)1