client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultDateFormat may be changed for the whole package to use a different format
	// look in the time package for further information
	DefaultDateFormat = "2006-01-02"

	// DefaultDateTimeFormat may be changed for the whole package to use a different format
	// look in the time package for further information
	DefaultDateTimeFormat = "2006-01-02T15:04:05-07:00"

	// DefaultZipCodeRegex is used to validate German zip codes
	DefaultZipCodeRegex = regexp.MustCompile(`^((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))$`)

	// DefaultUserAgent is the default user agent of this library
	DefaultUserAgent = "github.com/jxsl13/stromgedacht"
)

Functions

This section is empty.

Types

type Client

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

Client which conforms to the OpenAPI3 specification for this service.

func New

func New(opts ...Option) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) GetForecast added in v0.3.0

func (c *Client) GetForecast(zip string, from, to time.Time) (*api.ForecastViewModel, error)

GetForecast Retrieval of the StromGedacht forecast in the TransnetBW control area for a specified time period at a specified location (zip code). Pass zero-time (time.Time{}) to fall back to API defaults for from and to parameters. By providing no date, it uses the date 7 days ago. Only up to 7 days into the past can be requested.

func (*Client) GetForecastContext added in v0.3.0

func (c *Client) GetForecastContext(ctx context.Context, zip string, from, to time.Time) (*api.ForecastViewModel, error)

GetForecastContext Retrieval of the StromGedacht forecast in the TransnetBW control area for a specified time period at a specified location (zip code). Pass zero-time (time.Time{}) to fall back to API defaults for from and to parameters. By providing no date, it uses the date 7 days ago. Only up to 7 days into the past can be requested.

func (*Client) GetNow

func (c *Client) GetNow(zip string) (*api.RegionStateNowViewModel, error)

GetNow Retrieval of the StromGedacht status in the TransnetBW control area for the current time at a specified location (postal code).

func (*Client) GetNowContext

func (c *Client) GetNowContext(ctx context.Context, zip string) (*api.RegionStateNowViewModel, error)

GetNowContext Retrieval of the StromGedacht status in the TransnetBW control area for the current time at a specified location (postal code).

func (*Client) GetStates

func (c *Client) GetStates(zip string, from, to time.Time) (*api.RegionStateRangeViewModel, error)

GetStates Retrieval of the StromGedacht statuses in the TransnetBW control area for a specified time period at a specified location (zip code), whereby the status can be retrieved a maximum of 4 days into the past and a maximum of 2 days into the future.

func (*Client) GetStatesContext

func (c *Client) GetStatesContext(ctx context.Context, zip string, from, to time.Time) (*api.RegionStateRangeViewModel, error)

GetStatesContext Retrieval of the StromGedacht statuses in the TransnetBW control area for a specified time period at a specified location (zip code), whereby the status can be retrieved a maximum of 4 days into the past and a maximum of 2 days into the future.

type Option

type Option func(*clientOptions) error

func WithApiUrl

func WithApiUrl(apiUrl string) Option

WithApiUrl changes the base url of the api

func WithContext

func WithContext(ctx context.Context) Option

WithContext change sthe default context that is used for every method that does NOT expect a context

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPCLient changes the used http client

func WithTimeFormat

func WithTimeFormat(format string) Option

WithTimeFormat changes the format of the used time string

func WithUserAgent added in v0.2.0

func WithUserAgent(userAgent string) Option

WithUserAgent sets the User-Agent for every client request

func WithZipCodeRegex

func WithZipCodeRegex(regex string) Option

WithZipCodeRegex changes the format of the used time string

Jump to

Keyboard shortcuts

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