reprogl
1package oauth2
3import (4"encoding/json"5"strings"6)
7
8type Gender string9
10type ResourceOwnerInterface interface {11GetUserData() (*UserData, error)12}
13
14const (15Male Gender = "male"16Female Gender = "female"17Unknown Gender = "n/a"18)
19
20type UserData struct {21ID string `json:"id"`22Username string `json:"username,omitempty"`23DisplayName string `json:"displayName,omitempty"`24FirstName string `json:"firstName,omitempty"`25LastName string `json:"lastName,omitempty"`26Gender Gender `json:"gender,omitempty"`27Email string `json:"email,omitempty"`28Avatar string `json:"avatar,omitempty"`29Provider string `json:"dataProvider"`30
31RawData string `json:"rawData"`32}
33
34func (a *Gender) UnmarshalJSON(b []byte) error {35var s string36if err := json.Unmarshal(b, &s); err != nil {37return err38}39
40switch strings.ToLower(s) {41case "male":42*a = Male43case "female":44*a = Female45default:46*a = Unknown47}48
49return nil50}
51