Skip to content

Commit

Permalink
♻️ refactor: updated base model #9
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Nov 8, 2023
1 parent c7f567f commit 8ff7198
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apix/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions apix/api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 8ff7198

Please sign in to comment.