mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
|
|
package shared
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/formancehq/formance-sdk-go/v2/pkg/utils"
|
|
"math/big"
|
|
)
|
|
|
|
type V2TargetIDType string
|
|
|
|
const (
|
|
V2TargetIDTypeStr V2TargetIDType = "str"
|
|
V2TargetIDTypeBigint V2TargetIDType = "bigint"
|
|
)
|
|
|
|
type V2TargetID struct {
|
|
Str *string
|
|
Bigint *big.Int
|
|
|
|
Type V2TargetIDType
|
|
}
|
|
|
|
func CreateV2TargetIDStr(str string) V2TargetID {
|
|
typ := V2TargetIDTypeStr
|
|
|
|
return V2TargetID{
|
|
Str: &str,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func CreateV2TargetIDBigint(bigint *big.Int) V2TargetID {
|
|
typ := V2TargetIDTypeBigint
|
|
|
|
return V2TargetID{
|
|
Bigint: bigint,
|
|
Type: typ,
|
|
}
|
|
}
|
|
|
|
func (u *V2TargetID) UnmarshalJSON(data []byte) error {
|
|
|
|
str := ""
|
|
if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil {
|
|
u.Str = &str
|
|
u.Type = V2TargetIDTypeStr
|
|
return nil
|
|
}
|
|
|
|
bigint := big.NewInt(0)
|
|
if err := utils.UnmarshalJSON(data, &bigint, "", true, true); err == nil {
|
|
u.Bigint = bigint
|
|
u.Type = V2TargetIDTypeBigint
|
|
return nil
|
|
}
|
|
|
|
return errors.New("could not unmarshal into supported union types")
|
|
}
|
|
|
|
func (u V2TargetID) MarshalJSON() ([]byte, error) {
|
|
if u.Str != nil {
|
|
return utils.MarshalJSON(u.Str, "", true)
|
|
}
|
|
|
|
if u.Bigint != nil {
|
|
return utils.MarshalJSON(u.Bigint, "", true)
|
|
}
|
|
|
|
return nil, errors.New("could not marshal union type: all fields are null")
|
|
}
|