diff --git a/apix/api.go b/apix/api.go index df1e9c4..92a7d19 100644 --- a/apix/api.go +++ b/apix/api.go @@ -328,6 +328,11 @@ func (a *ApiRequestConfig) SetTelegram(value telegram.TelegramConfig) *ApiReques return a } +func (a *ApiRequestConfig) SetKey(value string) *ApiRequestConfig { + a.Key = value + return a +} + func (a *ApiRequestConfig) Json() string { return utils.ToJson(a) } @@ -460,3 +465,17 @@ func (a *ApiRequestConfig) CombineTelegram(e EndpointConfig) telegram.TelegramCo func isDuration(t time.Duration) bool { return t != 0 && t > 0 } + +func Get(node []ApiRequestConfig, key string) ApiRequestConfig { + if len(node) == 0 { + return ApiRequestConfig{} + } + var value ApiRequestConfig + for _, v := range node { + if v.Key == key { + value = v + break + } + } + return value +} diff --git a/apix/api_model.go b/apix/api_model.go index e2611f9..90e1c89 100644 --- a/apix/api_model.go +++ b/apix/api_model.go @@ -42,6 +42,7 @@ type EndpointConfig struct { type ApiRequestConfig struct { BaseURL string `json:"base_url" yaml:"base_url"` + Key string `json:"key" yaml:"key"` Authentication AuthenticationConfig `json:"authentication" yaml:"authentication"` Headers map[string]string `json:"headers" yaml:"headers"` Endpoints map[string]EndpointConfig `json:"endpoints" yaml:"endpoints"`