mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
f0d014eba2
Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
73 lines
1.3 KiB
Go
73 lines
1.3 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
apiutil "github.com/absmach/supermq/api/http/util"
|
|
"github.com/absmach/supermq/invitations"
|
|
)
|
|
|
|
const maxLimitSize = 100
|
|
|
|
type sendInvitationReq struct {
|
|
UserID string `json:"user_id,omitempty"`
|
|
DomainID string `json:"domain_id,omitempty"`
|
|
Relation string `json:"relation,omitempty"`
|
|
Resend bool `json:"resend,omitempty"`
|
|
}
|
|
|
|
func (req *sendInvitationReq) validate() error {
|
|
if req.UserID == "" {
|
|
return apiutil.ErrMissingID
|
|
}
|
|
if req.DomainID == "" {
|
|
return apiutil.ErrMissingDomainID
|
|
}
|
|
if err := invitations.CheckRelation(req.Relation); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type listInvitationsReq struct {
|
|
invitations.Page
|
|
}
|
|
|
|
func (req *listInvitationsReq) validate() error {
|
|
if req.Page.Limit > maxLimitSize || req.Page.Limit < 1 {
|
|
return apiutil.ErrLimitSize
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type acceptInvitationReq struct {
|
|
DomainID string `json:"domain_id,omitempty"`
|
|
}
|
|
|
|
func (req *acceptInvitationReq) validate() error {
|
|
if req.DomainID == "" {
|
|
return apiutil.ErrMissingDomainID
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type invitationReq struct {
|
|
userID string
|
|
domainID string
|
|
}
|
|
|
|
func (req *invitationReq) validate() error {
|
|
if req.userID == "" {
|
|
return apiutil.ErrMissingID
|
|
}
|
|
if req.domainID == "" {
|
|
return apiutil.ErrMissingDomainID
|
|
}
|
|
|
|
return nil
|
|
}
|