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

FIX: makeBidRequestの不備 #5

Merged
1 commit merged into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInf
headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
if request.Device != nil && len(request.Device.UA) > 0 {
headers.Add("User-Agent", request.Device.UA)
}

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

Expand Down Expand Up @@ -106,11 +109,14 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidReque
v.Set("adapterver", adg.version)
adSize := getSizes(imp)
if adSize != "" {
v.Set("size", adSize)
v.Set("sizes", adSize)
}
if request.Site != nil && request.Site.Page != "" {
v.Set("tp", request.Site.Page)
}
if request.Source != nil && request.Source.TID != "" {
v.Set("transactionid", request.Source.TID)
}
return &v
}

Expand All @@ -135,7 +141,7 @@ func getSizes(imp *openrtb.Imp) string {
}
var sizeStr string
for _, v := range imp.Banner.Format {
sizeStr += strconv.FormatUint(v.W, 10) + "×" + strconv.FormatUint(v.H, 10) + ","
sizeStr += strconv.FormatUint(v.W, 10) + "x" + strconv.FormatUint(v.H, 10) + ","
}
if len(sizeStr) > 0 && strings.LastIndex(sizeStr, ",") == len(sizeStr)-1 {
sizeStr = sizeStr[:len(sizeStr)-1]
Expand Down Expand Up @@ -255,7 +261,7 @@ func removeWrapper(ad string) string {
func NewAdgenerationAdapter(endpoint string) *AdgenerationAdapter {
return &AdgenerationAdapter{
endpoint,
"1.0.1",
"1.0.2",
"JPY",
}
}
2 changes: 1 addition & 1 deletion adapters/adgeneration/adgeneration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestGetSizes(t *testing.T) {

request = &openrtb.Imp{Banner: multiFormatBanner}
size = getSizes(request)
if size != "300×250,320×50" {
if size != "300x250,320x50" {
t.Errorf("%v does not match size.", multiFormatBanner)
}
request = &openrtb.Imp{Banner: noFormatBanner}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.2&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&sizes=300x250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.2&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&sizes=300x250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.2&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&sizes=300x250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.2&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&sizes=300x250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"headers": {
"Accept": [
"application/json"
Expand Down