From 2fe6379c78612240aca1b7f96f034c331c6fd793 Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 21 Jan 2025 15:35:26 +0400 Subject: [PATCH] Add missing imports --- internal/config/external_apis.go | 49 ------------------- .../clients/coinmarketcap/coinmarketcap.go | 2 +- internal/shared/http/clients/http_clients.go | 1 + 3 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 internal/config/external_apis.go diff --git a/internal/config/external_apis.go b/internal/config/external_apis.go deleted file mode 100644 index c39d3a86..00000000 --- a/internal/config/external_apis.go +++ /dev/null @@ -1,49 +0,0 @@ -package config - -import ( - "fmt" - "time" -) - -type ExternalAPIsConfig struct { - CoinMarketCap *CoinMarketCapConfig `mapstructure:"coinmarketcap"` -} - -type CoinMarketCapConfig struct { - APIKey string `mapstructure:"api_key"` - BaseURL string `mapstructure:"base_url"` - Timeout time.Duration `mapstructure:"timeout"` - CacheTTL time.Duration `mapstructure:"cache_ttl"` -} - -func (cfg *ExternalAPIsConfig) Validate() error { - if cfg.CoinMarketCap == nil { - return fmt.Errorf("missing coinmarketcap config") - } - - if err := cfg.CoinMarketCap.Validate(); err != nil { - return err - } - - return nil -} - -func (cfg *CoinMarketCapConfig) Validate() error { - if cfg.APIKey == "" { - return fmt.Errorf("missing coinmarketcap api key") - } - - if cfg.BaseURL == "" { - return fmt.Errorf("missing coinmarketcap base url") - } - - if cfg.Timeout <= 0 { - return fmt.Errorf("invalid coinmarketcap timeout") - } - - if cfg.CacheTTL <= 0 { - return fmt.Errorf("invalid coinmarketcap cache ttl") - } - - return nil -} diff --git a/internal/shared/http/clients/coinmarketcap/coinmarketcap.go b/internal/shared/http/clients/coinmarketcap/coinmarketcap.go index b3177118..b92987aa 100644 --- a/internal/shared/http/clients/coinmarketcap/coinmarketcap.go +++ b/internal/shared/http/clients/coinmarketcap/coinmarketcap.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/babylonlabs-io/staking-api-service/internal/config" + "github.com/babylonlabs-io/staking-api-service/internal/shared/config" "github.com/babylonlabs-io/staking-api-service/internal/shared/types" ) diff --git a/internal/shared/http/clients/http_clients.go b/internal/shared/http/clients/http_clients.go index 257dc2ba..ef0258ce 100644 --- a/internal/shared/http/clients/http_clients.go +++ b/internal/shared/http/clients/http_clients.go @@ -2,6 +2,7 @@ package clients import ( "github.com/babylonlabs-io/staking-api-service/internal/shared/config" + "github.com/babylonlabs-io/staking-api-service/internal/shared/http/clients/coinmarketcap" "github.com/babylonlabs-io/staking-api-service/internal/shared/http/clients/ordinals" )