in resources/resources.go [452:470]
func (t *Terminal) UnmarshalJSON(b []byte) error {
rawFields := make(map[string]any)
if err := json.Unmarshal(b, &rawFields); err != nil {
return err
}
if len(rawFields) == 0 {
// The JSON object was empty; leave the structured object empty too.
return nil
}
if idVal, ok := rawFields["name"]; ok {
idString, ok := idVal.(string)
if !ok {
return fmt.Errorf("invalid value for the field 'name': %+v: %w", idVal, util.HTTPError(http.StatusBadRequest))
}
t.ID = idString
}
t.rawFields = rawFields
return nil
}