🏷️ Added some helpers for profile domain

This commit is contained in:
Maxim Lebedev 2022-02-25 20:30:08 +05:00
parent 3e9bd5df18
commit 2b97bde091
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 16 additions and 0 deletions

View File

@ -33,6 +33,10 @@ func TestProfile(tb testing.TB) *Profile {
}
}
func (p Profile) HasName() bool {
return len(p.Name) > 0
}
// GetName safe returns first name, if any.
func (p Profile) GetName() string {
if len(p.Name) == 0 {
@ -42,6 +46,10 @@ func (p Profile) GetName() string {
return p.Name[0]
}
func (p Profile) HasURL() bool {
return len(p.URL) > 0
}
// GetURL safe returns first URL, if any.
func (p Profile) GetURL() *URL {
if len(p.URL) == 0 {
@ -51,6 +59,10 @@ func (p Profile) GetURL() *URL {
return p.URL[0]
}
func (p Profile) HasPhoto() bool {
return len(p.Photo) > 0
}
// GetPhoto safe returns first photo, if any.
func (p Profile) GetPhoto() *URL {
if len(p.Photo) == 0 {
@ -60,6 +72,10 @@ func (p Profile) GetPhoto() *URL {
return p.Photo[0]
}
func (p Profile) HasEmail() bool {
return len(p.Email) > 0
}
// GetEmail safe returns first email, if any.
func (p Profile) GetEmail() *Email {
if len(p.Email) == 0 {