Enhance Customer Service with Notification Response Structures
- Introduced CustomerNotificationResponse struct to provide a detailed response format for customer notifications, improving the clarity of notification data. - Updated the Customer service interface to include methods for searching and retrieving customers with notification-specific responses, enhancing the flexibility of customer data retrieval. - Modified the Login method to accept a device token, allowing for better tracking of customer devices during login. - Refactored existing methods to utilize the new notification response structure, ensuring consistency across customer-related API responses. - Enhanced error handling and logging in the service layer for improved traceability during customer searches and logins.
This commit is contained in:
@@ -367,7 +367,7 @@ func (s *notificationService) getCustomers(ctx context.Context, values []string,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, customer := range customers.Customers {
|
||||
for _, customer := range customers {
|
||||
recipients = append(recipients, notificationRecipient{
|
||||
UserID: customer.ID,
|
||||
Email: customer.Email,
|
||||
@@ -379,7 +379,7 @@ func (s *notificationService) getCustomers(ctx context.Context, values []string,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, customer := range customers.Customers {
|
||||
for _, customer := range customers {
|
||||
recipients = append(recipients, notificationRecipient{
|
||||
UserID: customer.ID,
|
||||
Email: customer.Email,
|
||||
@@ -391,7 +391,7 @@ func (s *notificationService) getCustomers(ctx context.Context, values []string,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, customer := range customers.Customers {
|
||||
for _, customer := range customers {
|
||||
recipients = append(recipients, notificationRecipient{
|
||||
UserID: customer.ID,
|
||||
Email: customer.Email,
|
||||
@@ -401,11 +401,11 @@ func (s *notificationService) getCustomers(ctx context.Context, values []string,
|
||||
} else {
|
||||
offset := 0
|
||||
for {
|
||||
customers, err := s.customerService.Search(ctx, &customer.SearchCustomersForm{}, &response.Pagination{Limit: 100, Offset: offset})
|
||||
customers, err := s.customerService.SearchNotification(ctx, &customer.SearchCustomersForm{}, &response.Pagination{Limit: 100, Offset: offset})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, customer := range customers.Customers {
|
||||
for _, customer := range customers {
|
||||
recipients = append(recipients, notificationRecipient{
|
||||
UserID: customer.ID,
|
||||
Email: customer.Email,
|
||||
@@ -413,7 +413,7 @@ func (s *notificationService) getCustomers(ctx context.Context, values []string,
|
||||
})
|
||||
}
|
||||
offset += 100
|
||||
if len(customers.Customers) == 0 {
|
||||
if len(customers) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user