Fix setAuth() when field is of type Optional[string]

This commit is contained in:
Elara 2022-12-10 15:17:18 -08:00
parent fa357b4bff
commit 4714be0ac9

View File

@ -162,12 +162,16 @@ func (c *Client) setAuth(data any) any {
return data
}
authType := authField.Kind()
if authType != reflect.String {
switch authField.Type().String() {
case "string":
authField.SetString(c.token)
case "types.Optional[string]":
setMtd := authField.MethodByName("Set")
out := setMtd.Call([]reflect.Value{reflect.ValueOf(c.token)})
authField.Set(out[0])
default:
return data
}
authField.SetString(c.token)
return val.Elem().Interface()
}