1package apiquery
2
3import (
4 "github.com/anthropics/anthropic-sdk-go/packages/param"
5 "reflect"
6)
7
8func (e *encoder) newRichFieldTypeEncoder(t reflect.Type) encoderFunc {
9 f, _ := t.FieldByName("Value")
10 enc := e.typeEncoder(f.Type)
11 return func(key string, value reflect.Value) ([]Pair, error) {
12 if opt, ok := value.Interface().(param.Optional); ok && opt.Valid() {
13 return enc(key, value.FieldByIndex(f.Index))
14 } else if ok && param.IsNull(opt) {
15 return []Pair{{key, "null"}}, nil
16 }
17 return nil, nil
18 }
19}