Refactor code structure and remove redundant sections for improved readability and maintainability
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 26s

This commit is contained in:
2025-07-06 14:23:35 -04:00
parent b61b5664b7
commit 152eb2c7b7
9 changed files with 813 additions and 156 deletions

View File

@ -20,16 +20,47 @@ The following samples will assist you to become as comfortable as possible with
import "git.savin.nyc/alex/mysubaru"
```
#### Create a new MySubaru connection and get a car by VIN
#### Create a new MySubaru API Client
```go
// Create a MySubaru Client
mysubaru, _ := New()
outback := mysubaru.GetVehicleByVIN("VIN-CODE-HERE")
msc, err := mysubaru.New(cfg)
if err != nil {
cfg.Logger.Error("cannot create MySubaru client", "error", err)
os.Exit(1)
}
```
#### Get a car by VIN
```go
outback, err := msc.GetVehicleByVIN("1HGCM82633A004352")
if err != nil {
cfg.Logger.Error("cannot get a vehicle by VIN", "error", err)
os.Exit(1)
}
```
#### Start/Stop Lights request
```go
outback.LightsStart()
time.Sleep(30 * time.Second)
outback.LightsStop()
```
// Execute a LightsStart command
events, err := outback.LightsStart()
if err != nil {
cfg.Logger.Error("cannot execute LightsStart command", "error", err)
os.Exit(1)
}
for event := range events {
fmt.Printf("Lights Start Event: %+v\n", event)
}
// Wait for a while to see the lights on
time.Sleep(20 * time.Second)
// Execute a LightsStop command
events, err = outback.LightsStop()
if err != nil {
cfg.Logger.Error("cannot execute LightsStop command", "error", err)
os.Exit(1)
}
for event := range events {
fmt.Printf("Lights Stop Event: %+v\n", event)
}
```