From 07fb322fb08093c376ea563a29db7fe747958537 Mon Sep 17 00:00:00 2001 From: tradplus <58809719+tradplus@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:19:32 +0800 Subject: [PATCH] feat: remove function transform and change some code by reviewer comment --- adapters/tradplus/params_test.go | 6 ++ adapters/tradplus/tradplus.go | 30 ------- .../exemplary/simple-native-1.1.json | 78 ------------------- .../tradplustest/exemplary/simple-native.json | 2 +- 4 files changed, 7 insertions(+), 109 deletions(-) delete mode 100644 adapters/tradplus/tradplustest/exemplary/simple-native-1.1.json diff --git a/adapters/tradplus/params_test.go b/adapters/tradplus/params_test.go index ab34b6a7c32..1fb0c96cb13 100644 --- a/adapters/tradplus/params_test.go +++ b/adapters/tradplus/params_test.go @@ -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}`, } diff --git a/adapters/tradplus/tradplus.go b/adapters/tradplus/tradplus.go index 6934b9c29a1..d543f890ff2 100644 --- a/adapters/tradplus/tradplus.go +++ b/adapters/tradplus/tradplus.go @@ -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} @@ -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) { diff --git a/adapters/tradplus/tradplustest/exemplary/simple-native-1.1.json b/adapters/tradplus/tradplustest/exemplary/simple-native-1.1.json deleted file mode 100644 index c97c63286ec..00000000000 --- a/adapters/tradplus/tradplustest/exemplary/simple-native-1.1.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "native": { - "request": "{\"native\":{\"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" - }, - "ext": { - "bidder": { - "accountId": "fake-account-id", - "zoneId": "" - } - } - } - ] - }, - "httpcalls": [ - { - "expectedRequest": { - "uri": "https://adx.tradplusad.com/fake-account-id/pserver", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "native": { - "request": "{\"native\":{\"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" - } - } - ] - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "8400d766-58b3-47d4-80d7-6658b337d403", - "impid": "test-imp-id", - "price": 1.2, - "adm": "some ads", - "crid": "crid_testid", - "mtype": 4 - } - ] - } - ] - } - } - } - ], - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "8400d766-58b3-47d4-80d7-6658b337d403", - "impid": "test-imp-id", - "price": 1.2, - "adm": "some ads", - "crid": "crid_testid", - "mtype": 4 - }, - "type": "native" - } - ] - } - ] -} diff --git a/adapters/tradplus/tradplustest/exemplary/simple-native.json b/adapters/tradplus/tradplustest/exemplary/simple-native.json index a2b6872d9e8..6dd785a753c 100644 --- a/adapters/tradplus/tradplustest/exemplary/simple-native.json +++ b/adapters/tradplus/tradplustest/exemplary/simple-native.json @@ -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" } }