Skip to content

Commit

Permalink
rem host, add region
Browse files Browse the repository at this point in the history
  • Loading branch information
xmgiddev committed Jan 3, 2024
1 parent d505742 commit bf4ae87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion adapters/mgidX/mgidX.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 5 additions & 4 deletions adapters/mgidX/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}`,
}
2 changes: 1 addition & 1 deletion openrtb_ext/imp_mgidX.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
6 changes: 6 additions & 0 deletions static/bidder-params/mgidX.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"type": "string",
"minLength": 1,
"description": "Endpoint ID"
},
"region": {
"type": "string",
"minLength": 1,
"description": "Region",
"enum": ["us-east", "eu"]
}
},
"oneOf": [
Expand Down

0 comments on commit bf4ae87

Please sign in to comment.