Skip to content

Commit cb7e851

Browse files
committed
rename "utility" config to "smarthub" config
1 parent e48bd4d commit cb7e851

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extract_days: 10
2-
utility:
2+
smarthub:
33
api_url: https://novec.smarthub.coop
44
username: johndoe@gmail.com
55
password: smarthub_password

internal/app/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type OAuth struct {
1818
}
1919

2020
// Auth authenticates with the api and returns a json web token for use with the api.
21-
func Auth(config UtilityConfig) (string, error) {
21+
func Auth(config SmartHubConfig) (string, error) {
2222
client := &http.Client{}
2323
formData := url.Values{}
2424
formData.Set("userId", config.Username)
@@ -63,7 +63,7 @@ type PollRequest struct {
6363
// FetchData calls the api to get data for a particular time period.
6464
// Note that the api may return a PENDING status or actual data.
6565
// However, parsing of the response is handled in ParseReader.
66-
func FetchData(start, end time.Time, config UtilityConfig, jwt string) (io.ReadCloser, error) {
66+
func FetchData(start, end time.Time, config SmartHubConfig, jwt string) (io.ReadCloser, error) {
6767
client := http.Client{}
6868
pollRequest := PollRequest{
6969
TimeFrame: "HOURLY",

internal/app/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ type InfluxConfig struct {
1919
Insecure bool `yaml:"insecure"`
2020
}
2121

22-
// UtilityConfig is the config for SmartHub.
22+
// SmartHubConfig is the config for SmartHub.
2323
// Account is your account number, available on your bill.
2424
// ServiceLocation appears to be an internal number, and must be retrieved from your browser. See README.md.
25-
type UtilityConfig struct {
25+
type SmartHubConfig struct {
2626
ApiUrl string `yaml:"api_url"`
2727
Username string `yaml:"username"`
2828
Password string `yaml:"password"`
@@ -32,9 +32,9 @@ type UtilityConfig struct {
3232

3333
// Config is the config format for electric-usage-downloader
3434
type Config struct {
35-
ExtractDays int `yaml:"extract_days"`
36-
Utility UtilityConfig `yaml:"utility"`
37-
InfluxDB InfluxConfig `yaml:"influxdb"`
35+
ExtractDays int `yaml:"extract_days"`
36+
SmartHub SmartHubConfig `yaml:"smarthub"`
37+
InfluxDB InfluxConfig `yaml:"influxdb"`
3838
}
3939

4040
// Main runs the program.
@@ -87,16 +87,16 @@ func Main() error {
8787
fmt.Printf("Start date: %s\n", startDate)
8888
fmt.Printf("End date: %s\n", endDate)
8989

90-
jwt, err := Auth(config.Utility)
9190
fmt.Println("Authenticating with SmartHub API...")
91+
jwt, err := Auth(config.SmartHub)
9292
if err != nil {
9393
return err
9494
}
9595

9696
fmt.Println("Fetching data from SmartHub API...")
9797
usage, err := retry.DoWithData(
9898
func() ([]ElectricUsage, error) {
99-
r, err := FetchData(startDate, endDate, config.Utility, jwt)
99+
r, err := FetchData(startDate, endDate, config.SmartHub, jwt)
100100
if err != nil {
101101
return nil, err
102102
}

0 commit comments

Comments
 (0)