package member

type AccountType int32

const (
	AccountTypeNone   AccountType = -1
	AccountTypePhone  AccountType = 1 // 手機
	AccountTypeMail   AccountType = 2 // 信箱
	AccountTypeDefine AccountType = 3 // 自定義帳號
)

var convAccountTypeCode = map[string]AccountType{
	"phone":    AccountTypePhone,
	"email":    AccountTypeMail,
	"platform": AccountTypeDefine,
}

func GetAccountTypeByCode(code string) AccountType {
	result, ok := convAccountTypeCode[code]
	if !ok {
		return AccountTypeNone
	}

	return result
}

// IsValid returns true if the account type is valid
func (a AccountType) IsValid() bool {
	return a >= AccountTypePhone && a <= AccountTypeDefine
}
