tsk-58: Update names of Contact endpoint (#67)
Closes #58 Reviewed-on: phoenix/textsender-api#67 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -3,6 +3,7 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
|
||||
@@ -116,3 +117,30 @@ func (m *MockContactStore) ContactExists(ctx context.Context, phoneNumber string
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
func (m *MockContactStore) UpdateNames(ctx context.Context, con *contact.Contact, firstname *string, lastname *string, nickname *string) (int64, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
if m.Error != nil {
|
||||
return 0, m.Error
|
||||
} else if firstname == nil && lastname == nil && nickname == nil {
|
||||
return 0, fmt.Errorf("Names are not provided")
|
||||
} else {
|
||||
if c, exists := m.Contacts[*con.Id]; !exists {
|
||||
return 0, fmt.Errorf("Contact does not exist")
|
||||
} else {
|
||||
if firstname != nil {
|
||||
c.Firstname = firstname
|
||||
}
|
||||
if lastname != nil {
|
||||
c.Lastname = lastname
|
||||
}
|
||||
if nickname != nil {
|
||||
c.Nickname = nickname
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user