csg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 16 Imported by: 0

README

csg

China Southern Power Grid (中国南方电网) API

Docs

import "github.com/caiguanhao/csg"
ctx := context.Background()
client, err := csg.Login(ctx, "phone", "password")
accounts, err := client.GetAccounts(ctx)
bills, err := client.GetBills(ctx, accounts[0], 2023)
accounts2, err := client.GetAccountsWithMeteringPointId(ctx, accounts[0])
usages, err := client.GetDailyUsages(ctx, accounts2[0], 2023, 9)

Reference: china_southern_power_grid_stat

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id       string
	Number   string
	AreaCode string
	FullName string
	Address  string
}

type AccountWithMeteringPointId

type AccountWithMeteringPointId struct {
	Account
	MeteringPointId string
}

type Bill

type Bill struct {
	From         time.Time
	To           time.Time
	Usage        string
	TotalCharges string
}

type Client

type Client struct {
	AccessToken string
}

func Login

func Login(ctx context.Context, phone, password string) (*Client, error)

Login with phone and password, return client with access token if success.

func (Client) GetAccounts

func (client Client) GetAccounts(ctx context.Context) ([]Account, error)

Get all associated accounts.

func (Client) GetAccountsWithMeteringPointId

func (client Client) GetAccountsWithMeteringPointId(ctx context.Context, account Account) ([]AccountWithMeteringPointId, error)

Get all associated accounts with metering point id.

func (Client) GetBills

func (client Client) GetBills(ctx context.Context, account Account, year int) ([]Bill, error)

Get bills in year of specific account.

func (Client) GetDailyUsages

func (client Client) GetDailyUsages(ctx context.Context, account AccountWithMeteringPointId, year, month int) ([]DailyUsage, error)

Get daily electricity usage in month of specific account.

type DailyUsage

type DailyUsage struct {
	Date  string
	Usage string
}

Jump to

Keyboard shortcuts

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