Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Feb 22, 2022
1 parent 6fea3bf commit c3e8d20
Show file tree
Hide file tree
Showing 1,130 changed files with 41,131 additions and 14,122 deletions.
1,187 changes: 1,147 additions & 40 deletions .idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions iSolarCloud/add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ else
echo "Directory ${DIRNAME} exists"
echo ""
diff "${TEMPLATE}" "${DIRNAME}"
exit
# exit
fi

if [ ! -f "${DIRNAME}/data.go" ]
if [ -f "${DIRNAME}/data.go" ]
then
perl -pe "s#nullEndPoint#${NAME}#g; s#%URL%#${URL}#g" ${TEMPLATE}/data.go > "${DIRNAME}/data.go"
else
echo "File ${DIRNAME}/data.go exists"
fi

if [ ! -f "${DIRNAME}/struct.go" ]
if [ -f "${DIRNAME}/struct.go" ]
then
perl -pe "s/nullEndPoint/${NAME}/g" ${TEMPLATE}/struct.go > "${DIRNAME}/struct.go"
else
Expand Down
38 changes: 34 additions & 4 deletions iSolarCloud/sungro/AppService/acceptPsSharing/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package acceptPsSharing

import (
"GoSungrow/iSolarCloud/api/apiReflect"
"errors"
"fmt"
)


const Url = ""

const Url = "/v1/powerStationService/acceptPsSharing"
const Disabled = true

type RequestData struct {
// DeviceType string `json:"device_type" required:"true"`
Expand All @@ -22,6 +22,36 @@ func (rd RequestData) Help() string {
return ret
}


type ResultData struct {
Dummy string `json:"dummy"`
}

func (e *ResultData) IsValid() error {
var err error
switch {
case e.Dummy == "":
break
default:
err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
}
return err
}

//type DecodeResultData ResultData
//
//func (e *ResultData) UnmarshalJSON(data []byte) error {
// var err error
//
// for range Only.Once {
// if len(data) == 0 {
// break
// }
// var pd DecodeResultData
//
// // Store ResultData
// _ = json.Unmarshal(data, &pd)
// e.Dummy = pd.Dummy
// }
//
// return err
//}
58 changes: 37 additions & 21 deletions iSolarCloud/sungro/AppService/acceptPsSharing/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (
"fmt"
)


var _ api.EndPoint = (*EndPoint)(nil)

type EndPoint struct {
api.EndPointStruct
Request Request
Request Request
Response Response
}

Expand All @@ -29,8 +28,8 @@ type Response struct {
}

func Init(apiRoot *api.Web) EndPoint {
return EndPoint {
EndPointStruct: api.EndPointStruct {
return EndPoint{
EndPointStruct: api.EndPointStruct{
ApiRoot: apiRoot,
Area: api.GetArea(EndPoint{}),
Name: api.GetName(EndPoint{}),
Expand All @@ -42,7 +41,6 @@ func Init(apiRoot *api.Web) EndPoint {
}
}


// ****************************************
// Methods not scoped by api.EndPoint interface type

Expand All @@ -63,7 +61,6 @@ func Assert(e api.EndPoint) EndPoint {
return e.(EndPoint)
}


// ****************************************
// Methods defined by api.EndPoint interface type

Expand All @@ -74,6 +71,10 @@ func (e EndPoint) Help() string {
return ret
}

func (e EndPoint) IsDisabled() bool {
return Disabled
}

func (e EndPoint) GetArea() api.AreaName {
return e.Area
}
Expand All @@ -90,8 +91,12 @@ func (e EndPoint) Call() api.EndPoint {
return e.ApiRoot.Get(e)
}

func (e EndPoint) GetData() api.Json {
return api.GetAsPrettyJson(e.Response.ResultData)
func (e EndPoint) GetData(raw bool) api.Json {
if raw {
return api.Json(e.ApiRoot.Body)
} else {
return api.GetAsPrettyJson(e.Response.ResultData)
}
}

func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
Expand Down Expand Up @@ -139,10 +144,6 @@ func (e EndPoint) SetRequestByJson(j api.Json) api.EndPoint {
if e.Error != nil {
break
}
e.Error = e.IsRequestValid()
if e.Error != nil {
break
}
}
return e
}
Expand All @@ -157,13 +158,13 @@ func (e EndPoint) GetRequestJson() api.Json {

func (e EndPoint) IsRequestValid() error {
for range Only.Once {
req := e.GetRequest()
// req := e.Request.RequestCommon
e.Error = req.RequestCommon.IsValid()
//req := e.GetRequest()
//req := e.Request.RequestCommon
e.Error = e.Request.RequestCommon.IsValid()
if e.Error != nil {
break
}
e.Error = req.RequestData.IsValid()
e.Error = e.Request.RequestData.IsValid()
if e.Error != nil {
break
}
Expand All @@ -173,13 +174,10 @@ func (e EndPoint) IsRequestValid() error {

func (e EndPoint) SetResponse(ref []byte) api.EndPoint {
for range Only.Once {
// r := e.GetResponse()
// e.Error = json.Unmarshal(ref, &r)
e.Error = json.Unmarshal(ref, &e.Response)
if e.Error != nil {
break
}
// e.ResponseCommon = r
}
return e
}
Expand All @@ -194,12 +192,14 @@ func (e EndPoint) ResponseRef() interface{} {

func (e EndPoint) IsResponseValid() error {
for range Only.Once {
// resp := e.GetResponse()
// e.Error = resp.ResponseCommon.IsValid()
e.Error = e.Response.ResponseCommon.IsValid()
if e.Error != nil {
break
}
e.Error = e.Response.ResultData.IsValid()
if e.Error != nil {
break
}
}
return e.Error
}
Expand All @@ -218,4 +218,20 @@ func (e EndPoint) ResponseString() string {

func (e EndPoint) MarshalJSON() ([]byte, error) {
return api.MarshalJSON(e)

// return json.Marshal(&struct {
// Area string `json:"area"`
// EndPoint string `json:"endpoint"`
// Host string `json:"api_host"`
// Url string `json:"endpoint_url"`
// Request interface{} `json:"request"`
// Response interface{} `json:"response"`
// }{
// Area: string(e.Area),
// EndPoint: string(e.Name),
// Host: e.ApiRoot.Url.String(),
// Url: e.Url.String(),
// Request: e.Request,
// Response: e.Response,
// })
}
38 changes: 34 additions & 4 deletions iSolarCloud/sungro/AppService/activateEmail/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package activateEmail

import (
"GoSungrow/iSolarCloud/api/apiReflect"
"errors"
"fmt"
)


const Url = ""

const Url = "/v1/userService/activateEmail"
const Disabled = true

type RequestData struct {
// DeviceType string `json:"device_type" required:"true"`
Expand All @@ -22,6 +22,36 @@ func (rd RequestData) Help() string {
return ret
}


type ResultData struct {
Dummy string `json:"dummy"`
}

func (e *ResultData) IsValid() error {
var err error
switch {
case e.Dummy == "":
break
default:
err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
}
return err
}

//type DecodeResultData ResultData
//
//func (e *ResultData) UnmarshalJSON(data []byte) error {
// var err error
//
// for range Only.Once {
// if len(data) == 0 {
// break
// }
// var pd DecodeResultData
//
// // Store ResultData
// _ = json.Unmarshal(data, &pd)
// e.Dummy = pd.Dummy
// }
//
// return err
//}
Loading

0 comments on commit c3e8d20

Please sign in to comment.