Skip to content

Commit

Permalink
ServerResult.resultsの値は存在確認のために使用するように変更
Browse files Browse the repository at this point in the history
fix: 複数bidリクエストが送られてきた場合に `Not found matched adgeneration's LocationID in BidResponse`エラーを不必要に返してた問題の修正
  • Loading branch information
AdGeneration committed Apr 8, 2020
1 parent e61d102 commit 6a19150
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
70 changes: 32 additions & 38 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@ type AdgenerationAdapter struct {
}

// Server Responses
type adgServerResponseResult struct {
Locationid string `json:"locationid"`
Dealid string `json:"dealid"`
Results []adgServerResponse `json:"results"`
}
type adgServerResponse struct {
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"`
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) {
Expand Down Expand Up @@ -169,7 +167,7 @@ func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}}
}
var bidResp adgServerResponseResult
var bidResp adgServerResponse
err := json.Unmarshal(response.Body, &bidResp)
if err != nil {
return nil, []error{err}
Expand Down Expand Up @@ -199,29 +197,25 @@ func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex
}
if adgExt.Id == bidResp.Locationid {
impId = v.ID
} else {
return nil, []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("Not found matched adgeneration's LocationID in BidResponse.: %s", adgExt.Id),
}}
}

bitType = openrtb_ext.BidTypeBanner
adm = adg.createAd(&bidResp.Results[0], impId)
bid := openrtb.Bid{
ID: bidResp.Locationid,
ImpID: impId,
AdM: adm,
Price: bidResp.Results[0].Cpm,
W: bidResp.Results[0].W,
H: bidResp.Results[0].H,
CrID: bidResp.Results[0].Creativeid,
DealID: bidResp.Dealid,
}
bitType = openrtb_ext.BidTypeBanner
adm = adg.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,
})
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: bitType,
})
}
}
return bidResponse, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"beacon": "<img src=\"https://tg.socdm.com/bc/v3?b=beaconID&amp;xuid=XUID&amp;ctsv=CTSV&amp;seqid=SeqID&amp;seqtime=SeqTime&amp;seqctx=SeqCtx&amp;t=.gif\" width=\"1\" height=\"1\" style=\"display:none;border:none;padding:0;margin:0;width:1px;height:1px\"/>",
"beaconurl": "https://tg.socdm.com/bc/v3?b=beaconID&t=.gif",
"cpm": 46.6,
"creativeid": "DummyDsp_SdkTeam_supership.jp",
"creativeid": "Dummy_supership.jp",
"h": 250,
"landing_url": "",
"scheduleid": "512601",
Expand Down Expand Up @@ -137,7 +137,7 @@
"impid": "some-impression-id",
"price": 46.6,
"adm": "<div id=\"medibasspContainer\">\n <iframe src=\"https:\/\/s3-ap-northeast-1.amazonaws.com\/sdk-temp\/adg-sample-ad\/300x250.html?prc=-Cuepak&rd=https%3A%2F%2Ftg.socdm.com%2Frd%2Fv1%2Fz%2FhKFj2gDXY2hzbT0xOTgsZmJkZGMyNWEvNTgyNzgvU1NQTE9DLzUxMjYwMS83MjExNS43Njg1NS41MTI2MDEvMTA5MzkyNi82NDkxOS81ODI3ODpTU1BMT0M6Ki9jdD0xNTg1MjEyMDg1Nzg5O3NyPWh0dHBzO2RzcGlkPTMwMTtwcj16RGFfYVY0O3ByYj15UTtwcm89eVE7cHJvYz1KUFk7Y3JkMnk9MTA5LjQzMDAwMDAwMDAwMDAxO2NyeTJkPTAuMDA5MTM4MjYxOTAyNTg2MTI3MztpZHg9MDulc2VxaWTaACQ0NzFhM2JlNS1lYTQzLWRhZjAtYjhjZi1mNjJkNTA1N2Y5ZWOnc2VxdGltZa0xNTg1MjEyMDg1Nzg5pHh1aWS4WE52SVNNQ281bUlBQU1hN2dOUUFBQUFB%2Fp%2Fctsv%3Dm-ad226%3Bseqid%3D471a3be5-ea43-daf0-b8cf-f62d5057f9ec%3B%2Fg%2FU%3A%3Furl%3D\" style=\"border: 0px;\" width=\"300\" height=\"250\" frameborder=\"0\" scrolling=\"no\"><\/iframe>\n <\/div>\n <img src=\"https://tg.socdm.com/bc/v3?b=beaconID&amp;xuid=XUID&amp;ctsv=CTSV&amp;seqid=SeqID&amp;seqtime=SeqTime&amp;seqctx=SeqCtx&amp;t=.gif\" width=\"1\" height=\"1\" style=\"display:none;border:none;padding:0;margin:0;width:1px;height:1px\"/>",
"crid": "DummyDsp_SdkTeam_supership.jp",
"crid": "Dummy_supership.jp",
"w": 300,
"h": 250,
"dealid": "test-deal-id"
Expand Down

0 comments on commit 6a19150

Please sign in to comment.