2020-04-12 20:33:35 +02:00
|
|
|
package client
|
|
|
|
|
|
|
|
|
|
// UserAdded is the event sent when a new user is added to a company
|
|
|
|
|
type UserAdded struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
CompanyID string `json:"companyId"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UserRemoved is the event sent when a user is removed from a company
|
|
|
|
|
type UserRemoved struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
CompanyID string `json:"companyId"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Privilege is an enumeration of all available privileges
|
|
|
|
|
type Privilege string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
PrivilegeAdmin = "ADMIN"
|
|
|
|
|
PrivilegeCompany = "COMPANY"
|
|
|
|
|
PrivilegeConsumer = "CONSUMER"
|
|
|
|
|
PrivilegeTime = "TIME"
|
|
|
|
|
PrivilegeInvoicing = "INVOICING"
|
|
|
|
|
PrivilegeAccounting = "ACCOUNTING"
|
|
|
|
|
PrivilegeSupplier = "SUPPLIER"
|
2025-09-06 14:49:56 +02:00
|
|
|
PrivilegeSalary = "SALARY"
|
2020-04-12 20:33:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var AllPrivilege = []Privilege{
|
|
|
|
|
PrivilegeAdmin,
|
|
|
|
|
PrivilegeCompany,
|
|
|
|
|
PrivilegeConsumer,
|
|
|
|
|
PrivilegeTime,
|
|
|
|
|
PrivilegeInvoicing,
|
|
|
|
|
PrivilegeAccounting,
|
|
|
|
|
PrivilegeSupplier,
|
2025-09-06 14:49:56 +02:00
|
|
|
PrivilegeSalary,
|
2020-04-12 20:33:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Privilege) IsValid() bool {
|
|
|
|
|
switch e {
|
2025-09-06 14:49:56 +02:00
|
|
|
case PrivilegeAdmin, PrivilegeCompany, PrivilegeConsumer, PrivilegeTime, PrivilegeInvoicing, PrivilegeAccounting, PrivilegeSupplier, PrivilegeSalary:
|
2020-04-12 20:33:35 +02:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Privilege) String() string {
|
|
|
|
|
return string(e)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrivilegeAdded is the event sent when a new privilege is added
|
|
|
|
|
type PrivilegeAdded struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
CompanyID string `json:"companyId"`
|
|
|
|
|
Privilege Privilege `json:"privilege"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrivilegeRemoved is the event sent when a privilege is removed
|
|
|
|
|
type PrivilegeRemoved struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
CompanyID string `json:"companyId"`
|
|
|
|
|
Privilege Privilege `json:"privilege"`
|
|
|
|
|
}
|