/* Hindsight HTTP API HTTP API for Hindsight API version: 0.4.15 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package hindsight import ( "encoding/json" "time" "fmt" ) // Timestamp When the content occurred. Accepts an ISO 8601 datetime string (e.g. '2024-01-15T10:30:00Z'), null/omitted (defaults to now), or the special string 'unset' to explicitly store without any timestamp (use this for timeless content such as fictional documents or static reference material). type Timestamp struct { String *string TimeTime *time.Time } // Unmarshal JSON data into any of the pointers in the struct func (dst *Timestamp) UnmarshalJSON(data []byte) error { var err error // this object is nullable so check if the payload is null or empty string if string(data) == "" || string(data) == "{}" { return nil } // try to unmarshal JSON data into String err = json.Unmarshal(data, &dst.String); if err == nil { jsonString, _ := json.Marshal(dst.String) if string(jsonString) == "{}" { // empty struct dst.String = nil } else { return nil // data stored in dst.String, return on the first match } } else { dst.String = nil } // try to unmarshal JSON data into TimeTime err = json.Unmarshal(data, &dst.TimeTime); if err == nil { jsonTimeTime, _ := json.Marshal(dst.TimeTime) if string(jsonTimeTime) == "{}" { // empty struct dst.TimeTime = nil } else { return nil // data stored in dst.TimeTime, return on the first match } } else { dst.TimeTime = nil } return fmt.Errorf("data failed to match schemas in anyOf(Timestamp)") } // Marshal data from the first non-nil pointers in the struct to JSON func (src *Timestamp) MarshalJSON() ([]byte, error) { if src.String != nil { return json.Marshal(&src.String) } if src.TimeTime != nil { return json.Marshal(&src.TimeTime) } return nil, nil // no data in anyOf schemas } type NullableTimestamp struct { value *Timestamp isSet bool } func (v NullableTimestamp) Get() *Timestamp { return v.value } func (v *NullableTimestamp) Set(val *Timestamp) { v.value = val v.isSet = true } func (v NullableTimestamp) IsSet() bool { return v.isSet } func (v *NullableTimestamp) Unset() { v.value = nil v.isSet = false } func NewNullableTimestamp(val *Timestamp) *NullableTimestamp { return &NullableTimestamp{value: val, isSet: true} } func (v NullableTimestamp) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableTimestamp) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }