package user
import "encoding/json"
type Name string
type PreferencesDoNotTrackV1DoNotTrack string
type PreferencesDoNotTrackVersion string
type PreferencesTitle string
const PreferencesDoNotTrackV1DoNotTrackPreferencesDoNotTrackV1DoNotTrackALL PreferencesDoNotTrackV1DoNotTrack = "ALL"
const PreferencesDoNotTrackV1DoNotTrackPreferencesDoNotTrackV1DoNotTrackESSENTIALONLY PreferencesDoNotTrackV1DoNotTrack = "ESSENTIAL_ONLY"
const PreferencesDoNotTrackV1DoNotTrackPreferencesDoNotTrackV1DoNotTrackNONE PreferencesDoNotTrackV1DoNotTrack = "NONE"
const PreferencesDoNotTrackVersionV0 PreferencesDoNotTrackVersion = "v0"
const PreferencesDoNotTrackVersionV1 PreferencesDoNotTrackVersion = "v1"
const PreferencesTitlePreferencesTitleHRH PreferencesTitle = "HRH"
const PreferencesTitlePreferencesTitleMR PreferencesTitle = "MR"
const PreferencesTitlePreferencesTitleMRS PreferencesTitle = "MRS"
const PreferencesTitlePreferencesTitleMS PreferencesTitle = "MS"
const PreferencesTitlePreferencesTitleREV PreferencesTitle = "REV"
type Location struct {
Lat string `json:"lat"`
Lng string `json:"lng"`
}
type Preferences struct {
DoNotTrack PreferencesDoNotTrack `json:"do_not_track"`
Title *PreferencesTitle `json:"title"`
}
type PreferencesDoNotTrackV0 struct {
DoNotTrack bool `json:"do_not_track"`
}
type PreferencesDoNotTrackV1 struct {
DoNotTrack PreferencesDoNotTrackV1DoNotTrack `json:"do_not_track"`
OptOutChannels []string `json:"opt_out_channels"`
}
type User struct {
FirstKnownLocation *Location `json:"first_known_location"`
Id string `json:"id"`
Labels map[string]string `json:"labels"`
LastKnownLocation *Location `json:"last_known_location"`
Name Name `json:"name"`
Preferences Preferences `json:"preferences"`
}
type PreferencesDoNotTrack struct {
Version PreferencesDoNotTrackVersion `json:"version"`
PreferencesDoNotTrackV0 `json:"-"`
PreferencesDoNotTrackV1 `json:"-"`
}
func (d PreferencesDoNotTrack) MarshalJSON() ([]byte, error) {
switch d.Version {
case "v0":
return json.Marshal(struct { Tag string `json:"version"`; PreferencesDoNotTrackV0 }{ Tag: "v0", PreferencesDoNotTrackV0: d.PreferencesDoNotTrackV0 })
case "v1":
return json.Marshal(struct { Tag string `json:"version"`; PreferencesDoNotTrackV1 }{ Tag: "v1", PreferencesDoNotTrackV1: d.PreferencesDoNotTrackV1 })
default:
panic("unknown discriminator variant")
}
}
func (d *PreferencesDoNotTrack) UnmarshalJSON(b []byte) error {
var base struct { Tag string `json:"version"` }
if err := json.Unmarshal(b, &base); err != nil {
return err
}
switch base.Tag {
case "v0":
d.Version = "v0"
return json.Unmarshal(b, &d.PreferencesDoNotTrackV0)
case "v1":
d.Version = "v1"
return json.Unmarshal(b, &d.PreferencesDoNotTrackV1)
default:
panic("unknown discriminator variant")
}
}