Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UOE-5250 prebid-server upgrade to Prebid 0.116.0 #58

Merged
merged 125 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
148b1f1
adding yieldmo vendor id to usersync (#1166)
ym-winston Jan 15, 2020
7d9b1ec
Add SmartRTB adapter (#1071)
evanmsmrtb Jan 16, 2020
bd43afb
Added new adapter for CPMStar ad network banners and video (#1159)
JoshuaMGoldstein Jan 16, 2020
85022d1
Update the Conversant sync pixel (#1161)
johnwier Jan 23, 2020
31c2204
Add imp.ext.is_rewarded_inventory flag for rewarded video in Rubicon …
rpanchyk Jan 23, 2020
95200af
[currencies] fix GetInfo() null ref issue (#1169)
benjaminch Jan 23, 2020
84e2c26
Fix triplelift User Sync (#1173)
Kevin-P-Kerr Jan 24, 2020
94cc354
Enhance Message For Cache Errors (#1175)
SyntaxNode Jan 27, 2020
f75de92
Fix PubMatic Usersync URL (#1178)
PubMatic-OpenWrap Jan 28, 2020
5507b37
[Synacormedia] Add tagId bidder parameter (#1165)
coreykress Jan 31, 2020
b8871e9
Remove all non-secure calls from eplanning adapter (#1179)
sebaperez Jan 31, 2020
63e7e1d
Expose Cache HTTP Settings (#1184)
SyntaxNode Feb 5, 2020
4ff04cc
Adding bid rejection messages to debug response (#1181)
camrice Feb 6, 2020
fd9bc8f
Adds timeout notifications for Facebook (#1182)
hhhjort Feb 10, 2020
7762c0c
VIS.X: added app type support (#1194)
mk0x9 Feb 18, 2020
8e382e7
Add Adoppler bidder support. (#1186)
vchimishuk Feb 21, 2020
fd78c23
Adding support for deal prefixes (#1183)
camrice Feb 26, 2020
7be0a4d
updating default hard-coded list of certs (#1201)
PubMatic-OpenWrap Feb 27, 2020
6a26430
add admixer adapter (#1195)
DmitryStashkevich Feb 27, 2020
2e80651
Adding copying of gdpr consent string to openrtb bid request (#1189)
camrice Mar 3, 2020
c6919ee
fix conversant sync pixel (#1208)
johnwier Mar 4, 2020
f03dfa5
openx adapter: forward bid response currency in openx adapter if set …
SyntaxNode Mar 4, 2020
8686f03
add ucfunnel adapter (#1192)
guscarreon Mar 5, 2020
199d1dc
Update required params for TheMediaGrid adapter (#1188)
TheMediaGrid Mar 9, 2020
5a9da66
add zeroclickfraud adapter (#1207)
htang555 Mar 12, 2020
8668dfc
Fix Adform's parameters regex (#1214)
vstatkevich Mar 12, 2020
c515816
If Device.UA is not present in request body, init it with user-agent …
VeronikaSolovei9 Mar 12, 2020
f3787be
Queued request timeout (#1217)
VeronikaSolovei9 Mar 13, 2020
e94ca8b
docs: adding currency support section (#1199)
bretg Mar 16, 2020
2bad069
Add ValueImpression Adapter (#1204)
thuyhq Mar 16, 2020
95c269f
Kidoz adapter (#1210)
rhaksi-kidoz Mar 18, 2020
fb76895
Update auction.md (#1224)
ACannuniRP Mar 18, 2020
c3c8797
Update auction.md (#1225)
ACannuniRP Mar 18, 2020
dcc062a
Added logging to cache for video endpoint (#1220)
camrice Mar 18, 2020
c7ead07
added VISX vendor ID for usersyncing (#1229)
Aadeshp Mar 25, 2020
145c525
First pass at phase 1 TCF 2.0 support (#1228)
hhhjort Mar 25, 2020
163f331
Updated price granularity unmarshal to accept empty values and ranges…
camrice Mar 26, 2020
4699864
Update vendorID for TheMediaGrid s2s Bid Adapter (#1232)
TheMediaGrid Mar 26, 2020
7e706f4
treat 204 from FAN as a no bids response (#1233)
Aadeshp Mar 27, 2020
e05369b
AMP CCPA Fix (#1187)
SyntaxNode Mar 30, 2020
7c009ba
Update rubicon.md (#1234)
bretg Mar 30, 2020
4b1f3e7
adding schain interface (#1203)
bretg Apr 1, 2020
40f433b
added Rewarded Video section (#1200)
bretg Apr 1, 2020
3665275
nanointeractive adapter (#1213)
rade-popovic Apr 2, 2020
fb38619
Typos Fix (#1236)
SyntaxNode Apr 6, 2020
1af4a6a
Moved hb_pc_cat_dur modification to be before caching (#1250)
camrice Apr 9, 2020
733b40d
replacing info@prebid.org maintainer email addrs (#1256)
bretg Apr 13, 2020
2b334af
aligning maintainer info (#1258)
bretg Apr 14, 2020
fb59f73
Add kidoz bidder info (#1257)
bretg Apr 14, 2020
c027bac
Add Cropping of BAdv for Rubicon Adapter (#1254)
DGarbar Apr 14, 2020
d416035
Added metrics support to endpoint aspect (#1226)
VeronikaSolovei9 Apr 15, 2020
cc7a247
Prebid Server adapter for Telaria (#1231)
telariaEng Apr 15, 2020
f07b1c3
#615 Beachfront URLs from config (#1238)
kdesput Apr 15, 2020
76747ef
Add nil check errors when setting native asset types (#1260)
mansinahar Apr 16, 2020
79bb4dc
Bugfix: no bids from bidder handling (#1252)
VeronikaSolovei9 Apr 16, 2020
8657ae9
Add missing categories to AppNexus -> IAB mapping file. (#1264)
jmaynardxandr Apr 21, 2020
dc9335c
Yieldone s2s Bid Adapter (#1242)
hbanalytics Apr 22, 2020
b44980c
Fix: URL de sync (#1261)
Apr 22, 2020
99dc46b
populate the app ID in the FAN timeout notif url with the publisher I…
Aadeshp Apr 22, 2020
f4905e8
Added header User Agent decoding (#1268)
VeronikaSolovei9 Apr 22, 2020
62a1357
Ad Generation Adapter Integration. (#1253)
AdGeneration Apr 23, 2020
f5a4289
Fix Go 1.14 Error Message Changes (#1271)
SyntaxNode Apr 24, 2020
f1f2b09
NinthDecimal Adapter (#1249)
trchandraprakash Apr 24, 2020
210bce4
* Add PubMatic bidder doc file (#1255)
mike-chowla Apr 29, 2020
8710fe1
Appnexus adapter: Add category mapping for government. (#1278)
jmaynardxandr Apr 29, 2020
da1eaea
Update a Freewheel mapping to Gaming category. (#1280)
jmaynardxandr Apr 29, 2020
0714ef7
Add AJA adapter (#1269)
sambaiz Apr 30, 2020
9e7e1cf
OpenX adapter: Pass gdpr and gdpr_consent to user sync endpoint (#1282)
laurb9 Apr 30, 2020
1704e69
OpenX adapter: Enable video for app (#1281)
laurb9 May 1, 2020
57ac060
fix conversant sync pixel (#1284)
johnwier May 1, 2020
e4980fa
Add AdOcean adapter (#1273)
mmuras May 4, 2020
8db5479
LunaMedia Adapter (#1285)
trchandraprakash May 6, 2020
42d5281
[Sharethrough] Add CCPA support (#1263)
May 6, 2020
cd90991
Remove Outdated GDPR AMP Special Case (#1283)
SyntaxNode May 6, 2020
cc3d2da
Stricter Privacy Scrubbing (#1286)
SyntaxNode May 6, 2020
2481fea
Add Adapter Orbidder (#1275)
arneschulz1984 May 11, 2020
4257bf1
Added OpenX Bidder adapter documentation (#1291)
jimee02 May 12, 2020
93b8a0e
OpenX adapter: Pass rewarded video flag (#1290)
laurb9 May 13, 2020
c18a2d8
Bugfix for missing fields in imp.video (#1297)
VeronikaSolovei9 May 14, 2020
9f7ed20
Add cpmOverride (#1289)
DGarbar May 14, 2020
6e5d044
Add Beintoo adapter (#1274)
ddantuonobeintoo May 14, 2020
ce94bf4
Yeahmobi adapter (#1279)
zhaojp May 14, 2020
fe4f9f4
advangelists: Vendor id update (#1307)
trchandraprakash May 21, 2020
28671d1
Consumable: Support GDPR and US Privacy consent (#1300)
djcsdy May 21, 2020
3c5ecee
Restore the AMP privacy exception as an option. (#1311)
hhhjort May 21, 2020
e0ddbc7
consumable: Correct GDPR vendor ID to 591. (#1309)
djcsdy May 21, 2020
1f4ed61
VIS.X: fix bid.ID, bid.CrID and set default currency value (#1296)
mk0x9 May 21, 2020
0f6510a
Fix debug log error messages (#1270)
camrice May 26, 2020
b929c4e
MobileFuse Adapter (#1303)
dtbarne May 26, 2020
bb0f9d6
eplanning: Support for apps (#1306)
May 26, 2020
8a128ce
Introduce Adhese adapter (#1292)
sander-adhese May 28, 2020
88aaf63
privacy: Potential JSON injection (#1304)
djcsdy May 28, 2020
9683f50
Updating bidder params for Advangelists (#1316)
trchandraprakash May 28, 2020
6bc9c01
Change placement of cpmoverride for Rubicon (#1310)
DGarbar May 28, 2020
7d39a11
increasing the stale period to 2 months (#1305)
bretg May 29, 2020
4f97d5a
Add Go 1.14 Build Target (#1314)
SyntaxNode Jun 1, 2020
0f0b098
Privacy: Remove user.ext.eids (#1294)
SyntaxNode Jun 1, 2020
9f3a8c7
Removed some redundant methods (#1320)
telariaEng Jun 2, 2020
748e2d0
Beachfront: GDPR id (issue 1301) and documentation updates (#1321)
muncha Jun 2, 2020
d00ff3f
Add Yieldlab Adapter (#1287)
mirkorean Jun 2, 2020
d29a749
Update adtelligent ortb endpoint (#1318)
GeneGenie Jun 2, 2020
b5993cd
Change on eplanning endpoint (#1327)
sebaperez Jun 2, 2020
cd9116e
Enable full TCF2 support (#1302)
hhhjort Jun 3, 2020
23c684c
Change on eplanning endpoint (hostname) (#1328)
sebaperez Jun 3, 2020
3527845
Districtm Dmx: new adapter (#1209)
stevealliance Jun 3, 2020
b10b55c
Fix sync url for Yieldone s2s Bid Adapter (#1336)
hbanalytics Jun 4, 2020
75504be
Merge pull request #47 from PubMatic-OpenWrap/ci
PubMatic-OpenWrap Jun 5, 2020
dc9d246
CCPA Video Bug (#1333)
SyntaxNode Jun 8, 2020
47bed2a
Add Pubnative bidder documentation (#1340)
aleksanyan Jun 9, 2020
c628f1a
Timeout notification monitoring and debugging (#1322)
hhhjort Jun 9, 2020
4361bf6
Add Adtarget server adapter (#1319)
GeneGenie Jun 9, 2020
86fa52b
Update Auction OpenRTB Sample (#1342)
SyntaxNode Jun 9, 2020
24665e8
Triplelift: Add SRA Support (#1347)
Jun 11, 2020
eb77b17
Privacy: Limit Ad Tracking (#1334)
SyntaxNode Jun 15, 2020
dd05c38
Avoid overriding AMP request original size with mutli-size (#1352)
dlackty Jun 15, 2020
62fe413
Extra logging for timeout notifications (#1349)
hhhjort Jun 17, 2020
2d2ed0c
Consumable: Correct bid type, should always be "banner". (#1359)
djcsdy Jun 17, 2020
98417cb
Build With Go 1.14 (#1350)
SyntaxNode Jun 17, 2020
d1c8129
Category mapping changes from product team. (#1348)
jmaynardxandr Jun 17, 2020
6eed873
Adds Avocet adapter (#1354)
scritchley Jun 18, 2020
a8feeca
AdOcean adapter - Support for sizes defined in prebid configuration. …
mmuras Jun 18, 2020
9c79ee4
Log account id and all bidder names when recovering from OpenRTB auct…
bsardo Jun 18, 2020
e6c4153
Updating imports for prebid v0.116.0
pm-isha-bharti Jun 19, 2020
6006cab
Merge 'master' into branch 'prebid_0.116.0'
pm-isha-bharti Jun 24, 2020
1ce7918
prebid_0.116.0 : Fixing merging issue for
pm-isha-bharti Jun 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 7 additions & 5 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 7
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
pulls:
daysUntilStale: 7
daysUntilClose: 30
issues:
daysUntilStale: 30
daysUntilClose: 60
# Items with these labels will never be considered stale
exemptLabels:
- pinned
- security
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ debug
pbs.*
inventory_url.yaml

# generated log files during tests
analytics/config/testFiles/
analytics/filesystem/testFiles/

# autogenerated version file
# static/version.txt

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go

go:
- '1.12'
- '1.13'
- '1.14.2'

go_import_path: github.com/PubMatic-OpenWrap/prebid-server

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget
RUN cd /tmp && \
wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz && \
tar -xf go1.12.7.linux-amd64.tar.gz && \
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz && \
tar -xf go1.14.2.linux-amd64.tar.gz && \
mv go /usr/local
RUN mkdir -p /app/prebid-server/
WORKDIR /app/prebid-server/
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/PubMatic-OpenWrap/prebid-server.svg?branch=master)](https://travis-ci.org/PubMatic-OpenWrap/prebid-server)
[![Build Status](https://travis-ci.org/prebid/prebid-server.svg?branch=master)](https://travis-ci.org/prebid/prebid-server)
[![Go Report Card](https://goreportcard.com/badge/github.com/PubMatic-OpenWrap/prebid-server?style=flat-square)](https://goreportcard.com/report/github.com/PubMatic-OpenWrap/prebid-server)

# Prebid Server
Expand All @@ -18,9 +18,10 @@ For more information, see:

## Installation

First install [Go 1.12](https://golang.org/doc/install) latest version.
First install [Go](https://golang.org/doc/install) version 1.13 or newer.

Note that prebid-server is using [Go modules](https://blog.golang.org/using-go-modules).
If using Go version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.
We officially support the most recent two major versions of the Go runtime. However, if you'd like to use a version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.

Download and prepare Prebid Server:

Expand Down
4 changes: 2 additions & 2 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func diffErrorLists(t *testing.T, description string, actual []error, expected [
t.Helper()

if len(expected) != len(actual) {
t.Fatalf("%s had wrong error count. Expected %d, got %d", description, len(expected), len(actual))
t.Fatalf("%s had wrong error count. Expected %d, got %d (%v)", description, len(expected), len(actual), actual)
}
for i := 0; i < len(actual); i++ {
if expected[i].Comparison == "literal" {
Expand Down Expand Up @@ -301,7 +301,7 @@ func diffJson(t *testing.T, description string, actual []byte, expected []byte)
if diff.Modified() {
var left interface{}
if err := json.Unmarshal(actual, &left); err != nil {
t.Fatalf("%s json did not match, but unmarhsalling failed. %v", description, err)
t.Fatalf("%s json did not match, but unmarshalling failed. %v", description, err)
}
printer := formatter.NewAsciiFormatter(left, formatter.AsciiFormatterConfig{
ShowArrayIndex: true,
Expand Down
260 changes: 260 additions & 0 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
package adgeneration

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"

"github.com/PubMatic-OpenWrap/openrtb"
"github.com/PubMatic-OpenWrap/prebid-server/adapters"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
)

type AdgenerationAdapter struct {
endpoint string
version string
defaultCurrency string
}

// Server Responses
type adgServerResponse struct {
Locationid string `json:"locationid"`
Dealid string `json:"dealid"`
Ad string `json:"ad"`
Beacon string `json:"beacon"`
Beaconurl string `json:"beaconurl"`
Cpm float64 `jsons:"cpm"`
Creativeid string `json:"creativeid"`
H uint64 `json:"h"`
W uint64 `json:"w"`
Ttl uint64 `json:"ttl"`
Vastxml string `json:"vastxml,omitempty"`
LandingUrl string `json:"landing_url"`
Scheduleid string `json:"scheduleid"`
Results []interface{} `json:"results"`
}

func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
numRequests := len(request.Imp)
var errs []error

if numRequests == 0 {
errs = append(errs, &errortypes.BadInput{
Message: "No impression in the bid request",
})
return nil, errs
}

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")

bidRequestArray := make([]*adapters.RequestData, 0, numRequests)

for index := 0; index < numRequests; index++ {
bidRequestUri, err := adg.getRequestUri(request, index)
if err != nil {
errs = append(errs, err)
return nil, errs
}
bidRequest := &adapters.RequestData{
Method: "GET",
Uri: bidRequestUri,
Body: nil,
Headers: headers,
}
bidRequestArray = append(bidRequestArray, bidRequest)
}

return bidRequestArray, errs
}

func (adg *AdgenerationAdapter) getRequestUri(request *openrtb.BidRequest, index int) (string, error) {
imp := request.Imp[index]
adgExt, err := unmarshalExtImpAdgeneration(&imp)
if err != nil {
return "", &errortypes.BadInput{
Message: err.Error(),
}
}
uriObj, err := url.Parse(adg.endpoint)
if err != nil {
return "", &errortypes.BadInput{
Message: err.Error(),
}
}
v := adg.getRawQuery(adgExt.Id, request, &imp)
uriObj.RawQuery = v.Encode()
return uriObj.String(), err
}

func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidRequest, imp *openrtb.Imp) *url.Values {
v := url.Values{}
v.Set("posall", "SSPLOC")
v.Set("id", id)
v.Set("sdktype", "0")
v.Set("hb", "true")
v.Set("t", "json3")
v.Set("currency", adg.getCurrency(request))
v.Set("sdkname", "prebidserver")
v.Set("adapterver", adg.version)
adSize := getSizes(imp)
if adSize != "" {
v.Set("size", adSize)
}
if request.Site != nil && request.Site.Page != "" {
v.Set("tp", request.Site.Page)
}
return &v
}

func unmarshalExtImpAdgeneration(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdgeneration, error) {
var bidderExt adapters.ExtImpBidder
var adgExt openrtb_ext.ExtImpAdgeneration
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, err
}
if err := json.Unmarshal(bidderExt.Bidder, &adgExt); err != nil {
return nil, err
}
if adgExt.Id == "" {
return nil, errors.New("No Location ID in ExtImpAdgeneration.")
}
return &adgExt, nil
}

func getSizes(imp *openrtb.Imp) string {
if imp.Banner == nil || len(imp.Banner.Format) == 0 {
return ""
}
var sizeStr string
for _, v := range imp.Banner.Format {
sizeStr += strconv.FormatUint(v.W, 10) + "×" + strconv.FormatUint(v.H, 10) + ","
}
if len(sizeStr) > 0 && strings.LastIndex(sizeStr, ",") == len(sizeStr)-1 {
sizeStr = sizeStr[:len(sizeStr)-1]
}
return sizeStr
}

func (adg *AdgenerationAdapter) getCurrency(request *openrtb.BidRequest) string {
if len(request.Cur) <= 0 {
return adg.defaultCurrency
} else {
for _, c := range request.Cur {
if adg.defaultCurrency == c {
return c
}
}
return request.Cur[0]
}
}

func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if response.StatusCode == http.StatusNoContent {
return nil, nil
}
if response.StatusCode == http.StatusBadRequest {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}}
}
if response.StatusCode != http.StatusOK {
return nil, []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}}
}
var bidResp adgServerResponse
err := json.Unmarshal(response.Body, &bidResp)
if err != nil {
return nil, []error{err}
}
if len(bidResp.Results) <= 0 {
return nil, nil
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)
var impId string
var bitType openrtb_ext.BidType
var adm string
for _, v := range internalRequest.Imp {
adgExt, err := unmarshalExtImpAdgeneration(&v)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
}
if adgExt.Id == bidResp.Locationid {
impId = v.ID
bitType = openrtb_ext.BidTypeBanner
adm = createAd(&bidResp, impId)
bid := openrtb.Bid{
ID: bidResp.Locationid,
ImpID: impId,
AdM: adm,
Price: bidResp.Cpm,
W: bidResp.W,
H: bidResp.H,
CrID: bidResp.Creativeid,
DealID: bidResp.Dealid,
}

bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: bitType,
})
return bidResponse, nil
}
}
return nil, nil
}

func createAd(body *adgServerResponse, impId string) string {
ad := body.Ad
if body.Vastxml != "" {
ad = "<body><div id=\"apvad-" + impId + "\"></div><script type=\"text/javascript\" id=\"apv\" src=\"https://cdn.apvdr.com/js/VideoAd.min.js\"></script>" + insertVASTMethod(impId, body.Vastxml) + "</body>"
}
ad = appendChildToBody(ad, body.Beacon)
unwrappedAd := removeWrapper(ad)
if unwrappedAd != "" {
return unwrappedAd
}
return ad
}

func insertVASTMethod(bidId string, vastxml string) string {
rep := regexp.MustCompile(`/\r?\n/g`)
var replacedVastxml = rep.ReplaceAllString(vastxml, "")
return "<script type=\"text/javascript\"> (function(){ new APV.VideoAd({s:\"" + bidId + "\"}).load('" + replacedVastxml + "'); })(); </script>"
}

func appendChildToBody(ad string, data string) string {
rep := regexp.MustCompile(`<\/\s?body>`)
return rep.ReplaceAllString(ad, data+"</body>")
}

func removeWrapper(ad string) string {
bodyIndex := strings.Index(ad, "<body>")
lastBodyIndex := strings.LastIndex(ad, "</body>")
if bodyIndex == -1 || lastBodyIndex == -1 {
return ""
}

str := strings.TrimSpace(strings.Replace(strings.Replace(ad[bodyIndex:lastBodyIndex], "<body>", "", 1), "</body>", "", 1))
return str
}

func NewAdgenerationAdapter(endpoint string) *AdgenerationAdapter {
return &AdgenerationAdapter{
endpoint,
"1.0.0",
"JPY",
}
}
Loading