Skip to content

Commit

Permalink
feat: remove function transform and change some code by reviewer comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tradplus committed Oct 25, 2024
1 parent f84c5da commit 07fb322
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 109 deletions.
6 changes: 6 additions & 0 deletions adapters/tradplus/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ var invalidParams = []string{
`{"accountId": ""}`,
`{"accountId": "", "zoneId": ""}`,
`{"accountId": "", "zoneId": "sin"}`,
`{"accountId": 123}`,
`{"accountId": {"test":1}}`,
`{"accountId": true}`,
`{"accountId": null}`,
`{"zoneId": "aaa"}`,
`{"zoneId": "aaa"}`,
`{"zoneId": null}`,
}
30 changes: 0 additions & 30 deletions adapters/tradplus/tradplus.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa
return nil, []error{err}
}

err = transform(request)
if err != nil {
return nil, []error{err}
}

reqBody, err := json.Marshal(request)
if err != nil {
return nil, []error{err}
Expand Down Expand Up @@ -105,31 +100,6 @@ func (a *adapter) buildEndpointURL(params *openrtb_ext.ExtImpTradPlus) (string,
return macros.ResolveMacros(a.endpoint, endpointParams)
}

func transform(request *openrtb2.BidRequest) error {
for i, imp := range request.Imp {
if imp.Native != nil {
var nativeRequest map[string]interface{}
nativeCopyRequest := make(map[string]interface{})
if err := json.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest); err != nil {
return err
}
_, exists := nativeRequest["native"]
if exists {
continue
}
nativeCopyRequest["native"] = nativeRequest
nativeReqByte, err := json.Marshal(nativeCopyRequest)
if err != nil {
return err
}
nativeCopy := *request.Imp[i].Native
nativeCopy.Request = string(nativeReqByte)
request.Imp[i].Native = &nativeCopy
}
}
return nil
}

// MakeBids make the bids for the bid response.
func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if adapters.IsResponseStatusCodeNoContent(response) {
Expand Down
78 changes: 0 additions & 78 deletions adapters/tradplus/tradplustest/exemplary/simple-native-1.1.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "test-imp-id",
"native": {
"request": "{\"native\":{\"assets\":[{\"id\":2,\"required\":1,\"title\":{\"len\":90}},{\"id\":6,\"img\":{\"hmin\":128,\"mimes\":[\"image/jpg\",\"image/jpeg\",\"image/png\"],\"type\":3,\"wmin\":128},\"required\":1},{\"data\":{\"len\":120,\"type\":2},\"id\":7,\"required\":1}],\"context\":1,\"plcmtcnt\":1,\"plcmttype\":4,\"ver\":\"1.2\"}}",
"request": "{\"ver\":\"1.2\",\"context\":1,\"plcmttype\":4,\"plcmtcnt\":1,\"assets\":[{\"id\":2,\"required\":1,\"title\":{\"len\":90}},{\"id\":6,\"required\":1,\"img\":{\"type\":3,\"wmin\":128,\"hmin\":128,\"mimes\":[\"image/jpg\",\"image/jpeg\",\"image/png\"]}},{\"id\":7,\"required\":1,\"data\":{\"type\":2,\"len\":120}}]}",
"ver": "1.2"
}
}
Expand Down

0 comments on commit 07fb322

Please sign in to comment.