Documentation
¶
Index ¶
- type Client
- func (c *Client) Municipalities(ctx context.Context, province Province) (Municipalities, error)
- func (c *Client) Schedule(ctx context.Context, suburbID string, stages ...Stage) (map[Stage]Schedule, error)
- func (c *Client) SearchSuburbs(ctx context.Context, searchTerm string, maxResults *int) (SearchSuburbs, error)
- func (c *Client) Status(ctx context.Context) (Stage, error)
- func (c *Client) Suburbs(ctx context.Context, municipalityID string, searchTerm string, page int) (SuburbResult, error)
- type ClientOpt
- type HttpClient
- type Municipalities
- type Municipality
- type Province
- type Schedule
- type ScheduleItem
- type SearchSuburb
- type SearchSuburbs
- type Stage
- type Suburb
- type SuburbResult
- type Suburbs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the structure for performing requests to the Eskom API.
func New ¶
New creates an instance of the Client with the given options.
The timeout is set by default to 30 seconds and can be overridden with the withTimeout option.
func (*Client) Municipalities ¶
Municipalities returns a list of municipalities that Eskom supplies to.
func (*Client) Schedule ¶
func (c *Client) Schedule(ctx context.Context, suburbID string, stages ...Stage) (map[Stage]Schedule, error)
Schedule returns the loadshedding schedule for the given suburb and stage(s).
func (*Client) SearchSuburbs ¶
func (c *Client) SearchSuburbs(ctx context.Context, searchTerm string, maxResults *int) (SearchSuburbs, error)
SearchSuburbs returns all suburbs that match the given searchTerm.
maxResults can be omitted (nil) if the default of 300 is acceptable.
func (*Client) Status ¶
Status retrieves the current Loadshedding stage.
Values of -1 and 0 indicate no loadshedding currently.
func (*Client) Suburbs ¶
func (c *Client) Suburbs(ctx context.Context, municipalityID string, searchTerm string, page int) (SuburbResult, error)
Suburbs returns a list of suburbs from the given municipality and search term.
The responses are paginated and can be iterated by using the page parameter. The result object contains a Total field to indicate the total number of results.
type ClientOpt ¶
type ClientOpt func(*Client)
func WithTimeout ¶
WithTimeout sets the http timeout for the Client to the given duration.
type Municipalities ¶
type Municipalities []Municipality
type Municipality ¶
type Schedule ¶
type Schedule struct {
Stage
Times []ScheduleItem
}
Schedule represents a loadshedding schedule for specific stage.
type ScheduleItem ¶
ScheduleItem represents a single instance of loadshedding.
type SearchSuburb ¶
type SearchSuburbs ¶
type SearchSuburbs []SearchSuburb
func (SearchSuburbs) OmitEmpty ¶
func (s SearchSuburbs) OmitEmpty() SearchSuburbs
OmitEmpty filters for SearchSuburbs with a non-zero Total.
type Stage ¶
type Stage int