client

package
v0.0.0-...-3d748ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpClient

func NewHttpClient(o ...HttpClientOption) *http.Client

Types

type APIWeatherClient

type APIWeatherClient struct {
	// contains filtered or unexported fields
}

func (*APIWeatherClient) GetByCity

func (api *APIWeatherClient) GetByCity(ctx context.Context, city string) (*dto.WeatherByCity, error)

type AstroAPIClient

type AstroAPIClient struct {
	// contains filtered or unexported fields
}

func (*AstroAPIClient) GetByCity

func (api *AstroAPIClient) GetByCity(ctx context.Context, city string) (*dto.AstroByCity, error)

type AstroApiErr

type AstroApiErr struct {
	Cod     int    `json:"cod"`
	Message string `json:"message"`
}

AstroApiErr represents an error response from the OpenWeather API.

func (AstroApiErr) Error

func (w AstroApiErr) Error() string

type AstroClient

type AstroClient interface {
	GetByCity(ctx context.Context, city string) (*dto.AstroByCity, error)
}

func NewAstroAPIClient

func NewAstroAPIClient(openWeatherBaseURL, openWeatherApiKey string) AstroClient

type HttpClientOption

type HttpClientOption func(*http.Client)

func WithTimeout

func WithTimeout(timeout time.Duration) HttpClientOption

type MockAstroClient

type MockAstroClient struct {
	Response *dto.AstroByCity
	Error    error
}

func NewMockAstroClient

func NewMockAstroClient(err error) *MockAstroClient

func (*MockAstroClient) GetByCity

func (m *MockAstroClient) GetByCity(_ context.Context, _ string) (*dto.AstroByCity, error)

type MockWeatherClient

type MockWeatherClient struct {
	Response *dto.WeatherByCity
	Error    error
	Delay    time.Duration
}

func NewMockWeatherClient

func NewMockWeatherClient(err error, delay time.Duration) *MockWeatherClient

func (*MockWeatherClient) GetByCity

func (m *MockWeatherClient) GetByCity(ctx context.Context, _ string) (*dto.WeatherByCity, error)

type WeatherApiErr

type WeatherApiErr struct {
	Err struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

WeatherApiErr code: 1006 No matching location found

func (WeatherApiErr) Error

func (w WeatherApiErr) Error() string

type WeatherClient

type WeatherClient interface {
	GetByCity(ctx context.Context, city string) (*dto.WeatherByCity, error)
}

func NewWeatherAPIClient

func NewWeatherAPIClient(weatherBaseURL, weatherApiKey string) WeatherClient

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL