diff --git a/client/authsms.go b/client/authsms.go index d98be55..64d395b 100644 --- a/client/authsms.go +++ b/client/authsms.go @@ -6,6 +6,7 @@ import ( "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/subject" + "go.mongodb.org/mongo-driver/bson" ) // AuthSMS ... @@ -36,3 +37,24 @@ func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.C return r.Data, nil } + +func (s AuthSMS) GetListPermission() (*model.GetListPermissionResponse, error) { + msg, err := natsio.GetServer().Request(subject.AuthSMS.GetListPermission, toBytes(bson.M{})) + if err != nil { + return nil, err + } + + var r struct { + Data *model.GetListPermissionResponse `json:"data"` + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} diff --git a/model/authsms_response.go b/model/authsms_response.go index 0effbbc..d1e6b24 100644 --- a/model/authsms_response.go +++ b/model/authsms_response.go @@ -3,3 +3,7 @@ package model type CreateUserSMSResponse struct { ID string `json:"_id"` } + +type GetListPermissionResponse struct { + Permission []string `json:"permission"` +} diff --git a/subject/authsms.go b/subject/authsms.go index 4b7a0ad..b89ca3c 100644 --- a/subject/authsms.go +++ b/subject/authsms.go @@ -7,7 +7,9 @@ func getAuthSMSValue(val string) string { } var AuthSMS = struct { - CreateUserSMS string + CreateUserSMS string + GetListPermission string }{ - CreateUserSMS: getAuthSMSValue("create_user_sms"), + CreateUserSMS: getAuthSMSValue("create_user_sms"), + GetListPermission: getAuthSMSValue("get_list_permission"), }