fix unmarshal argument pointer
This commit is contained in:
parent
bfcb423cdf
commit
25050d2f0e
5 changed files with 44 additions and 37 deletions
|
@ -1,5 +1,7 @@
|
|||
package v1
|
||||
|
||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
@ -7,209 +9,207 @@ import (
|
|||
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
||||
)
|
||||
|
||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||
|
||||
func mkerr(response client_protocol.BasicResponse) error {
|
||||
switch response.ErrorType {
|
||||
case "AccountAlreadyVerifiedError":
|
||||
result := AccountAlreadyVerifiedError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "AccountHasNoKeysError":
|
||||
result := AccountHasNoKeysError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "AccountLockedError":
|
||||
result := AccountLockedError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "CaptchaRequiredError":
|
||||
result := CaptchaRequiredError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "FingerprintVersionMismatchError":
|
||||
result := FingerprintVersionMismatchError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "GroupLinkNotActiveError":
|
||||
result := GroupLinkNotActiveError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "GroupNotActiveError":
|
||||
result := GroupNotActiveError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "GroupVerificationError":
|
||||
result := GroupVerificationError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InternalError":
|
||||
result := InternalError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidAttachmentError":
|
||||
result := InvalidAttachmentError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidBase64Error":
|
||||
result := InvalidBase64Error{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidFingerprintError":
|
||||
result := InvalidFingerprintError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidGroupError":
|
||||
result := InvalidGroupError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidGroupStateError":
|
||||
result := InvalidGroupStateError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidInviteURIError":
|
||||
result := InvalidInviteURIError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidProxyError":
|
||||
result := InvalidProxyError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidRecipientError":
|
||||
result := InvalidRecipientError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "InvalidRequestError":
|
||||
result := InvalidRequestError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "NoKnownUUIDError":
|
||||
result := NoKnownUUIDError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "NoSendPermissionError":
|
||||
result := NoSendPermissionError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "NoSuchAccountError":
|
||||
result := NoSuchAccountError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "NoSuchSessionError":
|
||||
result := NoSuchSessionError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "OwnProfileKeyDoesNotExistError":
|
||||
result := OwnProfileKeyDoesNotExistError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "ProfileUnavailableError":
|
||||
result := ProfileUnavailableError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "ServerNotFoundError":
|
||||
result := ServerNotFoundError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "UnknownGroupError":
|
||||
result := UnknownGroupError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "UnknownIdentityKeyError":
|
||||
result := UnknownIdentityKeyError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "UntrustedIdentityError":
|
||||
result := UntrustedIdentityError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result
|
||||
case "UserAlreadyExistsError":
|
||||
result := UserAlreadyExistsError{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package {{.Version}}
|
||||
|
||||
// {{ .Banner }}
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
@ -7,13 +9,11 @@ import (
|
|||
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
||||
)
|
||||
|
||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||
|
||||
func mkerr(response client_protocol.BasicResponse) error {
|
||||
switch response.ErrorType { {{ range $structName, $type := .Types }}
|
||||
case "{{ $structName }}":
|
||||
result := {{ $structName }}{}
|
||||
err := json.Unmarshal(response.Error, result)
|
||||
err := json.Unmarshal(response.Error, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -41,12 +41,14 @@ type StructsTemplateInput struct {
|
|||
Types map[string]*Type
|
||||
Version string
|
||||
ImportVersions []string
|
||||
Banner string
|
||||
}
|
||||
|
||||
type ActionsTemplateInput struct {
|
||||
Actions map[string]*Action
|
||||
Version string
|
||||
Responses bool
|
||||
Banner string
|
||||
}
|
||||
|
||||
var typeMap = map[string]string{
|
||||
|
@ -69,6 +71,8 @@ var fieldNameMap = map[string]string{
|
|||
"gv1-migration": "Gv1Migration",
|
||||
}
|
||||
|
||||
var banner = "DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo"
|
||||
|
||||
func (d *DataType) fixForVersion(field, version string) {
|
||||
response, ok := typeMap[d.Type]
|
||||
if ok {
|
||||
|
@ -111,7 +115,7 @@ func main() {
|
|||
}
|
||||
|
||||
for version, actions := range response.Actions {
|
||||
inputs := ActionsTemplateInput{Version: version, Responses: false}
|
||||
inputs := ActionsTemplateInput{Version: version, Responses: false, Banner: banner}
|
||||
for action, a := range actions {
|
||||
actions[action].FnName = strings.Title(action)
|
||||
if a.Request != "" {
|
||||
|
@ -151,6 +155,7 @@ func main() {
|
|||
inputs := StructsTemplateInput{
|
||||
Version: version,
|
||||
Types: make(map[string]*Type),
|
||||
Banner: banner,
|
||||
}
|
||||
for typeName, t := range types {
|
||||
for fieldName, field := range t.Fields {
|
||||
|
@ -199,6 +204,7 @@ func main() {
|
|||
inputs := StructsTemplateInput{
|
||||
Version: version,
|
||||
Types: make(map[string]*Type),
|
||||
Banner: banner,
|
||||
}
|
||||
for typeName, t := range types {
|
||||
for fieldName, field := range t.Fields {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package {{.Version}}
|
||||
|
||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||
// {{ .Banner }}
|
||||
|
||||
import ({{if .Responses}}
|
||||
"encoding/json"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package {{.Version}}
|
||||
|
||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||
// {{ .Banner }}
|
||||
|
||||
{{if gt (.ImportVersions | len) 0}}
|
||||
import (
|
||||
{{range $version := .ImportVersions}}
|
||||
|
|
Loading…
Reference in a new issue