Skip to content

Commit

Permalink
dealIdをbidResponseから参照するように変更
Browse files Browse the repository at this point in the history
resultの結果を1件のみ参照するように変更
  • Loading branch information
AdGeneration committed Apr 8, 2020
1 parent 8b94c9d commit e61d102
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
61 changes: 30 additions & 31 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ 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"`
Dealid string `json:"dealid"`
Creativeid string `json:"creativeid"`
H uint64 `json:"h"`
W uint64 `json:"w"`
Expand Down Expand Up @@ -178,45 +178,44 @@ func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex
return nil, nil
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.Results))
bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)
var impId string
for _, result := range bidResp.Results {
var bitType openrtb_ext.BidType
var adm string
for _, v := range internalRequest.Imp {
bidderExt, err := adg.unmarshalExtImpBidder(&v)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
}
adgExt, err := adg.unmarshalExtImpAdgeneration(&bidderExt)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
var bitType openrtb_ext.BidType
var adm string
for _, v := range internalRequest.Imp {
bidderExt, err := adg.unmarshalExtImpBidder(&v)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
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),
}}
}
adgExt, err := adg.unmarshalExtImpAdgeneration(&bidderExt)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
}
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(&result, impId)
adm = adg.createAd(&bidResp.Results[0], impId)
bid := openrtb.Bid{
ID: bidResp.Locationid,
ImpID: impId,
AdM: adm,
Price: result.Cpm,
W: result.W,
H: result.H,
CrID: result.Creativeid,
DealID: result.Dealid,
Price: bidResp.Results[0].Cpm,
W: bidResp.Results[0].W,
H: bidResp.Results[0].H,
CrID: bidResp.Results[0].Creativeid,
DealID: bidResp.Dealid,
}

bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
},
"ttl": 10,
"w": 300,
"dealid": "test-deal-id",
"weight": 1
}
],
"dealid": "test-deal-id",
"rotation": "0",
"scheduleid": "512601",
"sdktype": "0",
Expand Down

0 comments on commit e61d102

Please sign in to comment.