From 112c1c0f7d4dd5d50222996e005537e21d172483 Mon Sep 17 00:00:00 2001 From: Tue Date: Thu, 27 Oct 2022 09:17:20 +0700 Subject: [PATCH] build auth sms --- client/authsms.go | 60 ----------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 client/authsms.go diff --git a/client/authsms.go b/client/authsms.go deleted file mode 100644 index 64d395b..0000000 --- a/client/authsms.go +++ /dev/null @@ -1,60 +0,0 @@ -package client - -import ( - "encoding/json" - "errors" - "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 ... -type AuthSMS struct{} - -// GetAutSMS ... -func GetAutSMS() AuthSMS { - return AuthSMS{} -} - -func (s AuthSMS) CreateUserSMSViaAuthSMS(p model.CreateUserSMSRequest) (*model.CreateUserSMSResponse, error) { - msg, err := natsio.GetServer().Request(subject.AuthSMS.CreateUserSMS, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.CreateUserSMSResponse `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 -} - -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 -}