octopus

package
v0.0.0-...-cf21f3e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTariffCode

func BuildTariffCode(fuel, registers, product, area string) string

func ParseTariffCode

func ParseTariffCode(tc string) (string, string, string, string, error)

ParseTariffCode splits a tariff code from an agreement into its cnstituent parts: <Fuel>-<Registers>-<Product code>-<Postcode area>

Types

type Account

type Account struct {
	Number     string     `json:"number"`
	Properties []Property `json:"properties"`
}

type Agreement

type Agreement struct {
	TariffCode string     `json:"tariff_code"`
	ValidFrom  time.Time  `json:"valid_from"`
	ValidTo    *time.Time `json:"valid_to"`
}

type Client

type Client struct {
	EndPoint  string
	AccountID string
	Key       string
}

func (*Client) Account

func (c *Client) Account(ctx context.Context) (Account, error)

func (*Client) Consumption

func (c *Client) Consumption(ctx context.Context, mpan string, serial string, from time.Time, to time.Time) (Consumption, error)

func (*Client) Products

func (c *Client) Products(ctx context.Context, availableAt *time.Time) (Products, error)

func (*Client) TariffRates

func (c *Client) TariffRates(ctx context.Context, prod, fuel, tariff, rate string, from time.Time, to time.Time) (TariffRate, error)

type Consumption

type Consumption struct {
	Count    int    `json:"count"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Results  []struct {
		Consumption   float64   `json:"consumption"`
		IntervalStart time.Time `json:"interval_start"`
		IntervalEnd   time.Time `json:"interval_end"`
	} `json:"results"`
}

type ElectricityMeterPoint

type ElectricityMeterPoint struct {
	MPAN                string      `json:"mpan"`
	ProfileClass        int         `json:"profile_class"`
	ConsumptionStandard int         `json:"consumption_standard"`
	Meters              []Meter     `json:"meters"`
	Agreements          []Agreement `json:"agreements"`
}

func (ElectricityMeterPoint) ActiveAgreement

func (em ElectricityMeterPoint) ActiveAgreement(at time.Time) *Agreement

func (ElectricityMeterPoint) ActiveMeters

func (em ElectricityMeterPoint) ActiveMeters() []Meter

type GasMeterPoints

type GasMeterPoints struct {
	MPRN                string      `json:"mprn"`
	ProfileClass        int         `json:"profile_class"`
	ConsumptionStandard int         `json:"consumption_standard"`
	Meters              []Meter     `json:"meters"`
	Agreements          []Agreement `json:"agreements"`
}

type Meter

type Meter struct {
	SerialNumber string     `json:"serial_number"`
	Registers    []Register `json:"registers"`
}

type Product

type Product struct {
	Code          string      `json:"code"`
	FullName      string      `json:"full_name"`
	DisplayName   string      `json:"display_name"`
	Description   string      `json:"description"`
	IsVariable    bool        `json:"is_variable"`
	IsGreen       bool        `json:"is_green"`
	IsTracker     bool        `json:"is_tracker"`
	IsPrepay      bool        `json:"is_prepay"`
	IsBusiness    bool        `json:"is_business"`
	IsRestricted  bool        `json:"is_restricted"`
	Term          int         `json:"term"`
	Brand         string      `json:"brand"`
	AvailableFrom time.Time   `json:"available_from"`
	AvailableTo   interface{} `json:"available_to"`
	Links         []struct {
		Href   string `json:"href"`
		Method string `json:"method"`
		Rel    string `json:"rel"`
	} `json:"links"`
}

type Products

type Products struct {
	Count    int       `json:"count"`
	Next     string    `json:"next"`
	Previous string    `json:"previous"`
	Results  []Product `json:"results"`
}

func (Products) FindByTariff

func (p Products) FindByTariff(t string) *Product

type Property

type Property struct {
	ID                     int                     `json:"id"`
	MovedInAt              time.Time               `json:"moved_in_at"`
	MovedOutAt             *time.Time              `json:"moved_out_at"`
	AddressLine1           string                  `json:"address_line_1"`
	AddressLine2           string                  `json:"address_line_2"`
	AddressLine3           string                  `json:"address_line_3"`
	Town                   string                  `json:"town"`
	County                 string                  `json:"county"`
	Postcode               string                  `json:"postcode"`
	ElectricityMeterPoints []ElectricityMeterPoint `json:"electricity_meter_points"`
	GasMeterPoints         []GasMeterPoints        `json:"gas_meter_points"`
}

type RateInterval

type RateInterval struct {
	ValueExcVat float64   `json:"value_exc_vat"`
	ValueIncVat float64   `json:"value_inc_vat"`
	ValidFrom   time.Time `json:"valid_from"`
	ValidTo     time.Time `json:"valid_to"`
}

type Register

type Register struct {
	Identifier           string `json:"identifier"`
	Rate                 string `json:"rate"`
	IsSettlementRegister bool   `json:"is_settlement_register"`
}

type TariffRate

type TariffRate struct {
	Count    int            `json:"count"`
	Next     string         `json:"next"`
	Previous string         `json:"previous"`
	Results  []RateInterval `json:"results"`
}

Jump to

Keyboard shortcuts

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