This commit is contained in:
Daniel 2023-09-06 11:42:35 +08:00
parent 8a49a6b71f
commit 16cb93d730
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 104 additions and 0 deletions

View file

@ -109,6 +109,33 @@ type Value struct {
Phone *ValuePhone `json:"phone,omitempty"`
}
func (value *Value) String() string {
switch value.Type {
case KeyTypeBlock:
return value.Block.Content
case KeyTypeText:
return value.Text.Content
case KeyTypeNumber:
return value.Number.FormattedContent
case KeyTypeDate:
return value.Date.FormattedContent
case KeyTypeMSelect:
var ret []string
for _, v := range value.MSelect {
ret = append(ret, v.Content)
}
return strings.Join(ret, " ")
case KeyTypeURL:
return value.URL.Content
case KeyTypeEmail:
return value.Email.Content
case KeyTypePhone:
return value.Phone.Content
default:
return ""
}
}
func (value *Value) ToJSONString() string {
data, err := gulu.JSON.MarshalJSON(value)
if nil != err {