From bf4ae8758ca4766e80080b12419c2fe811c6b1ca Mon Sep 17 00:00:00 2001 From: xmgiddev <133856186+xmgiddev@users.noreply.github.com> Date: Thu, 4 Jan 2024 01:20:55 +0200 Subject: [PATCH] rem host, add region --- adapters/mgidX/mgidX.go | 9 ++++++++- adapters/mgidX/params_test.go | 9 +++++---- openrtb_ext/imp_mgidX.go | 2 +- static/bidder-params/mgidX.json | 6 ++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/adapters/mgidX/mgidX.go b/adapters/mgidX/mgidX.go index 250347e5589..9956fc99252 100644 --- a/adapters/mgidX/mgidX.go +++ b/adapters/mgidX/mgidX.go @@ -110,7 +110,14 @@ func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtMgidX, } func (a *adapter) buildEndpointURL(params *openrtb_ext.ImpExtMgidX) (string, error) { - endpointParams := macros.EndpointTemplateParams{Host: params.Host} + var endpointParams macros.EndpointTemplateParams + + if params.Region == "eu" { + endpointParams = macros.EndpointTemplateParams{Host: "eu"} + } else { + endpointParams = macros.EndpointTemplateParams{Host: "us-east-x"} + } + return macros.ResolveMacros(a.endpoint, endpointParams) } diff --git a/adapters/mgidX/params_test.go b/adapters/mgidX/params_test.go index fe6f5096fa7..8fbde82688b 100644 --- a/adapters/mgidX/params_test.go +++ b/adapters/mgidX/params_test.go @@ -34,14 +34,15 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"placementId": "test", "host": "us-east"}`, - `{"placementId": "1", "host": "us-east"}`, - `{"endpointId": "test", "host": "eu"}`, - `{"endpointId": "1", "host": "eu"}`, + `{"placementId": "test", "region": "us-east"}`, + `{"placementId": "1", "region": "eu"}`, + `{"endpointId": "test"}`, + `{"endpointId": "1"}`, } var invalidParams = []string{ `{"placementId": 42}`, `{"endpointId": 42}`, `{"placementId": "1", "endpointId": "1"}`, + `{"placementId": "1", "region": "other"}`, } diff --git a/openrtb_ext/imp_mgidX.go b/openrtb_ext/imp_mgidX.go index 8c39a71c5fd..7cf800b36a7 100644 --- a/openrtb_ext/imp_mgidX.go +++ b/openrtb_ext/imp_mgidX.go @@ -3,5 +3,5 @@ package openrtb_ext type ImpExtMgidX struct { PlacementID string `json:"placementId"` EndpointID string `json:"endpointId"` - Host string `json:"host"` + Region string `json:"region"` } diff --git a/static/bidder-params/mgidX.json b/static/bidder-params/mgidX.json index 7b24582d1ad..2cce2a1280a 100644 --- a/static/bidder-params/mgidX.json +++ b/static/bidder-params/mgidX.json @@ -14,6 +14,12 @@ "type": "string", "minLength": 1, "description": "Endpoint ID" + }, + "region": { + "type": "string", + "minLength": 1, + "description": "Region", + "enum": ["us-east", "eu"] } }, "oneOf": [