Skip to content

Commit 5c5e7b2

Browse files
Vidazoo tagId (#99)
* Vidazoo tagId * Simplify
1 parent c6b72cc commit 5c5e7b2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

adapters/vidazoo/vidazoo.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
3636
for _, imp := range request.Imp {
3737
requestCopy.Imp = []openrtb2.Imp{imp}
3838

39+
// NewsBreak Custom Prebid Code Starts
40+
tagId, err := extractTagId(&imp)
41+
if err != nil {
42+
errors = append(errors, fmt.Errorf("extract tagId: %w", err))
43+
continue
44+
}
45+
for i, _ := range requestCopy.Imp {
46+
requestCopy.Imp[i].TagID = tagId
47+
}
48+
// NewsBreak Custom Prebid Code Ends
49+
3950
requestJSON, err := json.Marshal(&requestCopy)
4051
if err != nil {
4152
errors = append(errors, fmt.Errorf("marshal bidRequest: %w", err))
@@ -132,3 +143,16 @@ func extractCid(imp *openrtb2.Imp) (string, error) {
132143
}
133144
return strings.TrimSpace(impExt.ConnectionId), nil
134145
}
146+
147+
func extractTagId(imp *openrtb2.Imp) (string, error) {
148+
var bidderExt adapters.ExtImpBidder
149+
if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil {
150+
return "", fmt.Errorf("unmarshal bidderExt: %w", err)
151+
}
152+
153+
var impExt openrtb_ext.ImpExtVidazoo
154+
if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil {
155+
return "", fmt.Errorf("unmarshal ImpExtVidazoo: %w", err)
156+
}
157+
return strings.TrimSpace(impExt.TagId), nil
158+
}

0 commit comments

Comments
 (0)