Add Result types to Go SDK and properly populate body/map fields (#358)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-15 01:08:21 -04:00
1 parent d8dc1ed0b2
commit a00ee7a948
61 files changed
+1888 -1099

No files matched your search

+16 -34
View File
@@ -1,46 +1,28 @@
package api
import "github.com/fatih/structs"
import (
"bytes"
"github.com/fatih/structs"
)
func init() {
structs.DefaultTagName = "json"
}
// Bool returns the given bool as a bool pointer
func Bool(in bool) *bool {
ret := new(bool)
*ret = in
return ret
type GenericResult interface {
GetItem() interface{}
GetResponseBody() *bytes.Buffer
GetResponseMap() map[string]interface{}
}
// String returns the given string as a string pointer
func String(in string) *string {
ret := new(string)
*ret = in
return ret
type GenericDeleteResult interface {
GetResponseBody() *bytes.Buffer
GetResponseMap() map[string]interface{}
}
// StringOrNil is like String, but the returned pointer will be nil if the
// string is empty
func StringOrNil(in string) *string {
if in == "" {
return nil
}
return String(in)
}
// Int returns the given int64 as an int64 pointer
func Int(in int32) *int32 {
ret := new(int32)
*ret = in
return ret
}
// IntOrNil is like Int, but the returned pointer will be nil if the integer is
// 0
func IntOrNil(in int32) *int32 {
if in == 0 {
return nil
}
return Int(in)
type GenericListResult interface {
GetItems() interface{}
GetResponseBody() *bytes.Buffer
GetResponseMap() map[string]interface{}
}