diff --git a/README.md b/README.md index dadd820..cca03cd 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,14 @@ Is a simple API client to interact with My Subaru service (https://www.mysubaru. ## Installation ```bash # Go Modules -go get github.com/alex-savin/go-mysubaru +go get git.savin.nyc/alex/mysubaru ``` ## Usage The following samples will assist you to become as comfortable as possible with mysubaru library. ```go // Import hassky into your code and refer it as `mysubaru`. -import "github.com/alex-savin/go-mysubaru" +import "git.savin.nyc/alex/mysubaru" ``` #### Create a new MySubaru connection and get a car by VIN diff --git a/client.go b/client.go index d3f7a90..68481e0 100644 --- a/client.go +++ b/client.go @@ -8,8 +8,8 @@ import ( "sync" "time" + "git.savin.nyc/alex/mysubaru/config" "github.com/Jeffail/gabs/v2" - "github.com/alex-savin/go-mysubaru/config" "github.com/go-resty/resty/v2" ) diff --git a/example/example.go b/example/example.go index 156cef3..fca7b75 100644 --- a/example/example.go +++ b/example/example.go @@ -5,8 +5,8 @@ import ( "log/slog" "os" - mysubaru "github.com/alex-savin/go-mysubaru" - "github.com/alex-savin/go-mysubaru/config" + mysubaru "git.savin.nyc/alex/mysubaru" + "git.savin.nyc/alex/mysubaru/config" ) // var log = *slog.Logger diff --git a/example/go.mod b/example/go.mod index 2586c8a..854cdf1 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,8 +1,8 @@ module example -go 1.21 +go 1.24 -require github.com/alex-savin/go-mysubaru v0.0.0-20231207172256-23b354b0f2c1 +require git.savin.nyc/alex/mysubaru v0.0.0-20231207172256-23b354b0f2c1 require ( github.com/Jeffail/gabs/v2 v2.7.0 // indirect diff --git a/go.mod b/go.mod index 6289dbf..9f5a6cb 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/alex-savin/go-mysubaru +module git.savin.nyc/alex/mysubaru go 1.24 diff --git a/main.go b/main.go deleted file mode 100644 index 744e7cc..0000000 --- a/main.go +++ /dev/null @@ -1,129 +0,0 @@ -package mysubaru - -import ( - "fmt" - "log/slog" - "os" - - mysubaru "github.com/alex-savin/go-mysubaru" - "github.com/alex-savin/go-mysubaru/config" -) - -// var log = *slog.Logger -var cfg = &config.Config{} - -const ( - LoggingOutputJson = "JSON" - LoggingOutputText = "TEXT" -) - -func configureLogging(config *config.Logging) *slog.Logger { //nolint:unparam - if config == nil { - return nil - } - - var level slog.Level - if err := level.UnmarshalText([]byte(config.Level)); err != nil { - slog.Warn(err.Error()) - slog.Warn(fmt.Sprintf("logging level not recognized, defaulting to level %s", slog.LevelInfo.String())) - level = slog.LevelInfo - } - - var handler slog.Handler - switch config.Output { - case LoggingOutputJson: - handler = slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{AddSource: cfg.Logging.Source, Level: level}) - case LoggingOutputText: - handler = slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{AddSource: cfg.Logging.Source, Level: level}) - default: - handler = slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{AddSource: cfg.Logging.Source, Level: level}) - } - - return slog.New(handler) -} - -func main() { - - var err error - cfg, err = config.New() - if err != nil { // Handle errors reading the config file - slog.Error("Fatal error config file", "error", err.Error()) - os.Exit(1) - } - - logger := configureLogging(cfg.Logging) - - logger.Debug("printting config", "config", cfg) - - ms, _ := mysubaru.New(logger, &cfg.MySubaru) - // mysubaru.selectVehicle("4S4BTGPD0P3199198") - - // 11.6MMAN ABS_MIL ACCS AHBL_MIL ATF_MIL AWD_MIL BSD BSDRCT_MIL CEL_MIL EBD_MIL EOL_MIL EPAS_MIL EPB_MIL ESS_MIL EYESIGHT ISS_MIL NAV_TOMTOM OPL_MIL RAB_MIL RCC REARBRK RES RESCC RHSF RPOI RPOIA SRS_MIL TEL_MIL TIF_35 TIR_33 TPMS_MIL VDC_MIL WASH_MIL g2 - // subaru1 := mysubaru.GetVehicleByVIN("4S4BTGND8L3137058") - // fmt.Printf("SUBARU #2 (Vehicle Status):\n") - // subaru1.GetVehicleStatus() - // fmt.Printf("SUBARU #2 (Vehicle Condition):\n") - // subaru1.GetVehicleCondition() - // fmt.Printf("SUBARU #1: %+v\n", subaru1) - // fmt.Printf("GEN #1: %+v\n\n", subaru1.getAPIGen()) - - // ABS_MIL ACCS AHBL_MIL ATF_MIL AWD_MIL BSD BSDRCT_MIL CEL_MIL EBD_MIL EOL_MIL EPAS_MIL EPB_MIL ESS_MIL EYESIGHT ISS_MIL OPL_MIL PANPM-TUIRWAOC PWAAADWWAP RAB_MIL RCC REARBRK RES RESCC RHSF RPOI RPOIA RTGU RVFS SRH_MIL SRS_MIL TEL_MIL TIF_35 TIR_33 TLD TPMS_MIL VALET VDC_MIL WASH_MIL g3 - subaru := ms.GetVehicleByVIN("4S4BTGPD0P3199198") - subaru.GetLocation(true) - // subaru.EngineStart() - fmt.Printf("SUBARU #1 (Vehicle Status):\n") - subaru.GetVehicleStatus() - // fmt.Printf("SUBARU #1 (Vehicle Condition):\n") - // subaru.GetVehicleCondition() - // fmt.Printf("SUBARU #1: %+v\n", subaru) - // subaru.GetClimatePresets() - // subaru.GetClimateUserPresets() - // fmt.Printf("SUBARU #2: %+v\n", subaru) - // subaru.GetVehicleHealth() - // subaru.GetFeaturesList() - - // subaru.LightsStart() - // time.Sleep(10 * time.Second) - // subaru.LightsStop() - - // subaru := mysubaru.GetVehicles()[0] - - // fmt.Printf("SUBARU: %+v\n", subaru) - - // fmt.Printf("Subaru Gen: %+v\n\n", subaru.getAPIGen()) - - // subaru.EngineOn() - // subaru.GetLocation(false) - - // subaru.GetVehicleStatus() - // subaru.GetVehicleCondition() - // fmt.Printf("SUBARU: %+v\n", subaru) - - // subaru.GetClimateQuickPresets() - // subaru.GetClimatePresets() - // subaru.GetClimateUserPresets() - - // subaru.LightsStart() - // time.Sleep(15 * time.Second) - // subaru.LightsStop() - - // subaru.listDevices() - - // subaru.GetVehicleStatus() - - // subaru.GetClimateSettings() - - // subaru.EngineStart() - // time.Sleep(15 * time.Second) - // subaru.EngineStop() - - // subaru.Unlock() - // time.Sleep(20 * time.Second) - // subaru.Lock() - - // subaru.LightsStart() - // time.Sleep(15 * time.Second) - // subaru.LightsStop() - - // subaru.GetLocation() -}