Skip to content

Feat: fetch newsletter subscribers#694

Closed
Scepter00 wants to merge 4 commits intohngprojects:devfrom
Scepter00:feat/fetch-newsletter-subscribers
Closed

Feat: fetch newsletter subscribers#694
Scepter00 wants to merge 4 commits intohngprojects:devfrom
Scepter00:feat/fetch-newsletter-subscribers

Conversation

@Scepter00
Copy link
Contributor

This API endpoint allows authorized users (e.g., administrators) to retrieve a complete list of subscribers who have signed up for the newsletter. The response will include relevant subscriber details such as email and subscription date, enabling efficient management and communication. A GET request available at GET /api/v1/newsletter-subscription.

Changes implemented

  • Implemented a GetSubscribers class in the organisation package.
  • Defined SubscribersResponse and SubscribersDto.
  • Wrote unit tests in the NewsletterServiceTest class.
  • Added a controller.

image

private final EmailServiceImpl emailService;

private static final int DEFAULT_PAGE = 0;
private static final int DEFAULT_SIZE = 20;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this and add to your controller class:
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,


public SubscribersResponse getSubscribersResponse(Integer page, Integer size) {
int effectivePage = (page == null || page < 0) ? DEFAULT_PAGE : page;
int effectiveSize = (size == null || size <= 0) ? DEFAULT_SIZE : size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed once you implement the change above

…nd set them in NewsletterController and also updated tests to reflect these changes
@Scepter00 Scepter00 closed this Mar 1, 2025
…nd set them in NewsletterController and also updated tests to reflect these changes
@Scepter00 Scepter00 reopened this Mar 1, 2025
@Scepter00 Scepter00 closed this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants