Skip to content

Commit

Permalink
Liftoff: Add site support and fill seat (prebid#3327)
Browse files Browse the repository at this point in the history
co-authored by @Vungle-GordonTian
  • Loading branch information
Vungle-GordonTian authored and SuprPhatAnon committed Dec 7, 2023
1 parent a97609f commit c15374c
Show file tree
Hide file tree
Showing 9 changed files with 372 additions and 7 deletions.
19 changes: 16 additions & 3 deletions adapters/liftoff/liftoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,22 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
imp.TagID = bidderImpExt.PlacementRefID
requestCopy.Imp = []openrtb2.Imp{imp}
// must make a shallow copy for pointers.
requestAppCopy := *request.App
requestAppCopy.ID = bidderImpExt.PubAppStoreID
requestCopy.App = &requestAppCopy
// If it is site object, need to construct an app with pub_store_id.
var requestAppCopy openrtb2.App
if request.App != nil {
requestAppCopy = *request.App
requestAppCopy.ID = bidderImpExt.PubAppStoreID
} else if request.Site != nil {
requestCopy.Site = nil
requestAppCopy = openrtb2.App{
ID: bidderImpExt.PubAppStoreID,
}
} else {
errs = append(errs, errors.New("failed constructing app, must have app or site object in bid request"))
continue
}

requestCopy.App = &requestAppCopy
requestJSON, err := json.Marshal(requestCopy)
if err != nil {
errs = append(errs, err)
Expand Down Expand Up @@ -126,6 +138,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
b := &adapters.TypedBid{
Bid: &seatBid.Bid[i],
BidType: openrtb_ext.BidTypeVideo,
Seat: openrtb_ext.BidderName(seatBid.Seat),
}

bidResponse.Bids = append(bidResponse.Bids, b)
Expand Down
3 changes: 2 additions & 1 deletion adapters/liftoff/liftofftest/exemplary/app_video_instl.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
"w": 300,
"h": 250
},
"type": "video"
"type": "video",
"seat": "seat-id"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"w": 300,
"h": 250
},
"type": "video"
"type": "video",
"seat": "seat-id"
}
]
}
Expand Down
152 changes: 152 additions & 0 deletions adapters/liftoff/liftofftest/exemplary/site_video_instl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"mockBidRequest": {
"id": "test-request-id",
"site": {
"name": "com.prebid"
},
"device": {
"ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab"
},
"imp": [
{
"id": "test-imp-id",
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576,
"ext": {
"foo": "bar"
}
},
"instl": 1,
"ext": {
"bidder": {
"app_store_id": "123",
"placement_reference_id": "123"
}
}
}
],
"user": {
"buyeruid": "123"
},
"ext": {
"prebid": {
"debug": true
}
}
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://liftoff.io/bit/t",
"headers": {
"Content-Type": ["application/json"],
"Accept": ["application/json"],
"X-OpenRTB-Version": ["2.5"]
},
"body": {
"id": "test-request-id",
"app": {
"id": "123"
},
"device": {
"ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab"
},
"imp": [
{
"id": "test-imp-id",
"tagid": "123",
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576,
"ext": {
"foo": "bar"
}
},
"instl": 1,
"ext": {
"prebid": null,
"bidder": {
"app_store_id": "123",
"placement_reference_id": "123"
},
"vungle": {
"bid_token": "123",
"app_store_id": "123",
"placement_reference_id": "123"
}
}
}
],
"user": {
"buyeruid": "123"
},
"ext": {
"prebid": {
"debug": true
}
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "seat-id",
"bid": [
{
"id": "1",
"impid": "test-imp-id",
"adid": "11110126",
"price": 0.500000,
"adm": "some-test-ad",
"crid": "test-crid",
"h": 250,
"w": 300
}
]
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "1",
"impid": "test-imp-id",
"adid": "11110126",
"price": 0.5,
"adm": "some-test-ad",
"crid": "test-crid",
"w": 300,
"h": 250
},
"type": "video",
"seat": "seat-id"
}
]
}
]
}
145 changes: 145 additions & 0 deletions adapters/liftoff/liftofftest/exemplary/site_video_rewarded.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"mockBidRequest": {
"id": "test-request-id",
"site": {
"name": "com.prebid"
},
"device": {
"ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab"
},
"imp": [
{
"id": "test-imp-id",
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576,
"ext": {
"foo": "bar"
}
},
"ext": {
"prebid": {
"is_rewarded_inventory": 1
},
"bidder": {
"app_store_id": "123",
"placement_reference_id": "123"
}
}
}
],
"user": {
"buyeruid": "123"
}
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://liftoff.io/bit/t",
"headers": {
"Content-Type": ["application/json"],
"Accept": ["application/json"],
"X-OpenRTB-Version": ["2.5"]
},
"body": {
"id": "test-request-id",
"app": {
"id": "123"
},
"device": {
"ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab"
},
"imp": [
{
"id": "test-imp-id",
"tagid": "123",
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576,
"ext": {
"foo": "bar"
}
},
"ext": {
"prebid": {
"is_rewarded_inventory": 1
},
"bidder": {
"app_store_id": "123",
"placement_reference_id": "123"
},
"vungle": {
"bid_token": "123",
"app_store_id": "123",
"placement_reference_id": "123"
}
}
}
],
"user": {
"buyeruid": "123"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "seat-id",
"bid": [
{
"id": "1",
"impid": "test-imp-id",
"adid": "11110126",
"price": 0.500000,
"adm": "some-test-ad",
"crid": "test-crid",
"h": 250,
"w": 300
}
]
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "1",
"impid": "test-imp-id",
"adid": "11110126",
"price": 0.5,
"adm": "some-test-ad",
"crid": "test-crid",
"w": 300,
"h": 250
},
"type": "video",
"seat": "seat-id"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"w": 300,
"h": 250
},
"type": "video"
"type": "video",
"seat": "seat-id"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
"h": 250,
"w": 300
},
"type": "video"
"type": "video",
"seat": "seat-id"
}
]
}
Expand Down
Loading

0 comments on commit c15374c

Please sign in to comment.