| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | _ "embed" |
| 5 | "encoding/json" |
| 6 | "maps" |
| 7 | ) |
| 8 | |
| 9 | // ProviderProtocolEndpoint is a documented SDK base URL, not a complete request URL. |
| 10 | // This is catalog metadata; it does not migrate saved user connections. |
| 11 | type ProviderProtocolEndpoint struct { |
| 12 | BaseURL string `json:"baseUrl"` |
| 13 | Source string `json:"source"` |
| 14 | CheckedOn string `json:"checkedOn"` |
| 15 | AuthHeader bool `json:"authHeader,omitempty"` |
| 16 | ResponsesMode string `json:"responsesMode,omitempty"` |
| 17 | } |
| 18 | |
| 19 | //go:embed provider_protocol_endpoints.json |
| 20 | var protocolEndpointJSON []byte |
| 21 | |
| 22 | var documentedProtocolEndpoints = func() map[string]map[string]ProviderProtocolEndpoint { |
| 23 | var result map[string]map[string]ProviderProtocolEndpoint |
| 24 | if err := json.Unmarshal(protocolEndpointJSON, &result); err != nil { |
| 25 | panic(err) |
| 26 | } |
| 27 | return result |
| 28 | }() |
| 29 | |
| 30 | func ProtocolEndpointsForCatalog(c ProviderCatalog) map[string]ProviderProtocolEndpoint { |
| 31 | source := documentedProtocolEndpoints[c.BrandID+"|"+c.Region+"|"+c.Product] |
| 32 | result := make(map[string]ProviderProtocolEndpoint, len(source)) |
| 33 | maps.Copy(result, source) |
| 34 | return result |
| 35 | } |
| 36 |