Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Feb 24, 2022
1 parent bcf02a6 commit ea4d9f1
Show file tree
Hide file tree
Showing 1,009 changed files with 34,072 additions and 4,401 deletions.
File renamed without changes.
8 changes: 0 additions & 8 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

1,282 changes: 1,011 additions & 271 deletions .idea/workspace.xml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions cmd/cmd_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func cmdApiLoginFunc(cmd *cobra.Command, args []string) {
var cmdApiGet = &cobra.Command{
Use: "get",
// Aliases: []string{""},
Short: fmt.Sprintf("Get details from iSolarCloud"),
Long: fmt.Sprintf("Get details from iSolarCloud"),
Short: fmt.Sprintf("GetByJson details from iSolarCloud"),
Long: fmt.Sprintf("GetByJson details from iSolarCloud"),
Example: PrintExamples("api get", "<endpoint> [area]"),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
Expand All @@ -136,7 +136,7 @@ func cmdApiGetFunc(cmd *cobra.Command, args []string) {
break
}

Cmd.Error = SunGrow.Get(args[0], args[1]).GetError()
Cmd.Error = SunGrow.GetByJson(args[0], args[1]).GetError()
if Cmd.Error != nil {
break
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func cmdApiRawFunc(cmd *cobra.Command, args []string) {
break
}

Cmd.Error = SunGrow.Get(args[0], args[1]).GetError()
Cmd.Error = SunGrow.GetByJson(args[0], args[1]).GetError()
if Cmd.Error != nil {
break
}
Expand Down Expand Up @@ -204,7 +204,7 @@ func cmdApiSaveFunc(cmd *cobra.Command, args []string) {
break
}

Cmd.Error = SunGrow.Get(args[0], args[1]).GetError()
Cmd.Error = SunGrow.GetByJson(args[0], args[1]).GetError()
if Cmd.Error != nil {
break
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ var cmdDataLogin = &cobra.Command{
var cmdDataGet = &cobra.Command{
Use: "get",
// Aliases: []string{""},
Short: fmt.Sprintf("Get high-level data from iSolarCloud"),
Long: fmt.Sprintf("Get high-level data from iSolarCloud"),
Short: fmt.Sprintf("GetByJson high-level data from iSolarCloud"),
Long: fmt.Sprintf("GetByJson high-level data from iSolarCloud"),
Example: PrintExamples("data get", "<endpoint>"),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
Expand Down
16 changes: 14 additions & 2 deletions cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@ func init() {
break
}
Cmd.ConfigDir = filepath.Join(Cmd.ConfigDir, "."+DefaultBinaryName)

_, Cmd.Error = os.Stat(Cmd.ConfigDir)
if os.IsExist(Cmd.Error) {
break
}

Cmd.Error = os.MkdirAll(Cmd.ConfigDir, 0700)
if Cmd.Error != nil {
break
}

Cmd.CacheDir, Cmd.Error = os.UserHomeDir()
if Cmd.Error != nil {
break
}
Cmd.CacheDir = filepath.Join(Cmd.CacheDir, "."+DefaultBinaryName, "cache")
_, Cmd.Error = os.Stat(Cmd.CacheDir)
if os.IsExist(Cmd.Error) {
break
}
Cmd.Error = os.MkdirAll(Cmd.CacheDir, 0700)
if Cmd.Error != nil {
break
}

Cmd.ConfigFile = filepath.Join(Cmd.ConfigDir, defaultConfigFile)
Cmd.ApiTokenFile = filepath.Join(Cmd.ConfigDir, defaultTokenFile)

Expand Down
3 changes: 2 additions & 1 deletion cmd/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var DefaultAreas = []string{"all"}

type CommandArgs struct {
ConfigDir string
CacheDir string
ConfigFile string
WriteConfig bool
Quiet bool
Expand Down Expand Up @@ -108,7 +109,7 @@ func (ca *CommandArgs) ProcessArgs(cmd *cobra.Command, args []string) error {
for range Only.Once {
ca.Args = args

SunGrow = iSolarCloud.NewSunGro(ca.ApiUrl)
SunGrow = iSolarCloud.NewSunGro(ca.ApiUrl, ca.CacheDir)
if SunGrow.Error != nil {
break
}
Expand Down
37 changes: 33 additions & 4 deletions iSolarCloud/AliSmsService/msgDownwardStatusReceipt/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"time"
)

var _ api.EndPoint = (*EndPoint)(nil)
Expand All @@ -27,7 +28,7 @@ type Response struct {
ResultData ResultData `json:"result_data"`
}

func Init(apiRoot *api.Web) EndPoint {
func Init(apiRoot api.Web) EndPoint {
return EndPoint{
EndPointStruct: api.EndPointStruct{
ApiRoot: apiRoot,
Expand All @@ -44,7 +45,7 @@ func Init(apiRoot *api.Web) EndPoint {
// ****************************************
// Methods not scoped by api.EndPoint interface type

func (e EndPoint) Init(apiRoot *api.Web) *EndPoint {
func (e EndPoint) Init(apiRoot api.Web) *EndPoint {
ret := Init(apiRoot)
return &ret
}
Expand All @@ -57,10 +58,12 @@ func (e EndPoint) GetResponse() Response {
return e.Response
}

//goland:noinspection GoUnusedExportedFunction
func Assert(e api.EndPoint) EndPoint {
return e.(EndPoint)
}

//goland:noinspection GoUnusedExportedFunction
func AssertResultData(e api.EndPoint) ResultData {
return e.(EndPoint).Response.ResultData
}
Expand Down Expand Up @@ -119,11 +122,11 @@ func (e EndPoint) IsError() bool {
return false
}

func (e EndPoint) ReadFile() error {
func (e EndPoint) ReadDataFile() error {
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
func (e EndPoint) WriteDataFile() error {
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

Expand Down Expand Up @@ -172,6 +175,10 @@ func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request.RequestData)
}

func (e EndPoint) GetRequestMd5() string {
return apiReflect.GetRequestMd5(e.Request.RequestData)
}

func (e EndPoint) IsRequestValid() error {
for range Only.Once {
// req := e.GetRequest()
Expand Down Expand Up @@ -251,3 +258,25 @@ func (e EndPoint) MarshalJSON() ([]byte, error) {
// Response: e.Response,
// })
}

func (e EndPoint) CheckCacheFile() bool {
return e.IsCacheFileOk(e.Request.RequestData)
}

func (e EndPoint) ReadCacheFile() api.EndPoint {
e.Error = e.CacheRead(e.Request.RequestData, &e)
return e
}

func (e EndPoint) WriteCacheFile() error {
return e.CacheWrite(e.Request.RequestData, e)
}

func (e EndPoint) SetCacheTimeout(duration time.Duration) api.EndPoint {
e.ApiRoot.SetCacheTimeout(duration)
return e
}

func (e EndPoint) GetCacheTimeout() time.Duration {
return e.ApiRoot.GetCacheTimeout()
}
2 changes: 1 addition & 1 deletion iSolarCloud/AliSmsService/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func init() {
// fmt.Printf("Name: %s\n", name)
}

func Init(apiRoot *api.Web) Area {
func Init(apiRoot api.Web) Area {
area := Area{
ApiRoot: apiRoot,
Name: api.GetArea(Area{}),
Expand Down
37 changes: 33 additions & 4 deletions iSolarCloud/AppService/acceptPsSharing/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"time"
)

var _ api.EndPoint = (*EndPoint)(nil)
Expand All @@ -27,7 +28,7 @@ type Response struct {
ResultData ResultData `json:"result_data"`
}

func Init(apiRoot *api.Web) EndPoint {
func Init(apiRoot api.Web) EndPoint {
return EndPoint{
EndPointStruct: api.EndPointStruct{
ApiRoot: apiRoot,
Expand All @@ -44,7 +45,7 @@ func Init(apiRoot *api.Web) EndPoint {
// ****************************************
// Methods not scoped by api.EndPoint interface type

func (e EndPoint) Init(apiRoot *api.Web) *EndPoint {
func (e EndPoint) Init(apiRoot api.Web) *EndPoint {
ret := Init(apiRoot)
return &ret
}
Expand All @@ -57,10 +58,12 @@ func (e EndPoint) GetResponse() Response {
return e.Response
}

//goland:noinspection GoUnusedExportedFunction
func Assert(e api.EndPoint) EndPoint {
return e.(EndPoint)
}

//goland:noinspection GoUnusedExportedFunction
func AssertResultData(e api.EndPoint) ResultData {
return e.(EndPoint).Response.ResultData
}
Expand Down Expand Up @@ -119,11 +122,11 @@ func (e EndPoint) IsError() bool {
return false
}

func (e EndPoint) ReadFile() error {
func (e EndPoint) ReadDataFile() error {
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
func (e EndPoint) WriteDataFile() error {
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

Expand Down Expand Up @@ -172,6 +175,10 @@ func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request.RequestData)
}

func (e EndPoint) GetRequestMd5() string {
return apiReflect.GetRequestMd5(e.Request.RequestData)
}

func (e EndPoint) IsRequestValid() error {
for range Only.Once {
// req := e.GetRequest()
Expand Down Expand Up @@ -251,3 +258,25 @@ func (e EndPoint) MarshalJSON() ([]byte, error) {
// Response: e.Response,
// })
}

func (e EndPoint) CheckCacheFile() bool {
return e.IsCacheFileOk(e.Request.RequestData)
}

func (e EndPoint) ReadCacheFile() api.EndPoint {
e.Error = e.CacheRead(e.Request.RequestData, &e)
return e
}

func (e EndPoint) WriteCacheFile() error {
return e.CacheWrite(e.Request.RequestData, e)
}

func (e EndPoint) SetCacheTimeout(duration time.Duration) api.EndPoint {
e.ApiRoot.SetCacheTimeout(duration)
return e
}

func (e EndPoint) GetCacheTimeout() time.Duration {
return e.ApiRoot.GetCacheTimeout()
}

0 comments on commit ea4d9f1

Please sign in to comment.