Add missing gRPC functions
This commit is contained in:
@@ -29,7 +29,11 @@ func (s MobilityAccountsServerImpl) Login(ctx context.Context, req *LoginRequest
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.NotFound, "could not log in : %v", err)
|
||||
}
|
||||
response := AccountFromStorageType(account)
|
||||
response, err := AccountFromStorageType(account)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
|
||||
}
|
||||
return &LoginResponse{Account: response}, nil
|
||||
}
|
||||
func (s MobilityAccountsServerImpl) Register(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error) {
|
||||
@@ -39,14 +43,38 @@ func (s MobilityAccountsServerImpl) Register(ctx context.Context, req *RegisterR
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.AlreadyExists, "account creation failed : %v", err)
|
||||
}
|
||||
response := AccountFromStorageType(account)
|
||||
response, err := AccountFromStorageType(account)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
|
||||
}
|
||||
return &RegisterResponse{Account: response}, nil
|
||||
}
|
||||
func (MobilityAccountsServerImpl) UpdateData(context.Context, *UpdateDataRequest) (*UpdateDataResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateData not implemented")
|
||||
func (s MobilityAccountsServerImpl) UpdateData(ctx context.Context, req *UpdateDataRequest) (*UpdateDataResponse, error) {
|
||||
a := req.Account.ToStorageType()
|
||||
account, err := s.handler.UpdateData(a.ID, a.Data)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "issue while apdating account : %v", err)
|
||||
}
|
||||
response, err := AccountFromStorageType(account)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
|
||||
}
|
||||
return &UpdateDataResponse{Account: response}, nil
|
||||
}
|
||||
func (MobilityAccountsServerImpl) GetAccount(context.Context, *GetAccountRequest) (*GetAccountResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAccount not implemented")
|
||||
func (s MobilityAccountsServerImpl) GetAccount(ctx context.Context, req *GetAccountRequest) (*GetAccountResponse, error) {
|
||||
account, err := s.handler.GetAccount(req.Id)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.AlreadyExists, "issue while retrieving account : %v", err)
|
||||
}
|
||||
response, err := AccountFromStorageType(account)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
|
||||
}
|
||||
return &GetAccountResponse{Account: response}, nil
|
||||
}
|
||||
func (s MobilityAccountsServerImpl) GetAccounts(ctx context.Context, req *GetAccountsRequest) (*GetAccountsResponse, error) {
|
||||
responses, err := s.handler.GetAccounts(req.Namespaces)
|
||||
@@ -54,11 +82,32 @@ func (s MobilityAccountsServerImpl) GetAccounts(ctx context.Context, req *GetAcc
|
||||
return nil, status.Errorf(codes.NotFound, "could not get accounts : %v", err)
|
||||
}
|
||||
var accounts []*Account
|
||||
|
||||
for _, a := range responses {
|
||||
accounts = append(accounts, AccountFromStorageType(&a))
|
||||
account, err := AccountFromStorageType(&a)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "could not get accounts : %v", err)
|
||||
}
|
||||
accounts = append(accounts, account)
|
||||
}
|
||||
return &GetAccountsResponse{Accounts: accounts}, nil
|
||||
}
|
||||
func (s MobilityAccountsServerImpl) GetAccountsBatch(ctx context.Context, req *GetAccountsBatchRequest) (*GetAccountsBatchResponse, error) {
|
||||
responses, err := s.handler.GetAccountsBatch(req.Accountids)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.NotFound, "could not get accounts : %v", err)
|
||||
}
|
||||
var accounts []*Account
|
||||
|
||||
for _, a := range responses {
|
||||
account, err := AccountFromStorageType(&a)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "could not get accounts : %v", err)
|
||||
}
|
||||
accounts = append(accounts, account)
|
||||
}
|
||||
return &GetAccountsBatchResponse{Accounts: accounts}, nil
|
||||
}
|
||||
func (MobilityAccountsServerImpl) ChangePassword(ctc context.Context, req *ChangePasswordRequest) (*ChangePasswordResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user