Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19006 improve API for subscriptions #145

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

palina-krukovich
Copy link
Contributor

@palina-krukovich palina-krukovich commented Jul 10, 2024

Summary by CodeRabbit

  • New Features

    • Updated user profile management to use a structured request body for setting active subscriptions.
    • Added specific error handling for type mismatches and unreadable messages.
  • Bug Fixes

    • Enhanced validation for subscription-related API calls to ensure data integrity.

@palina-krukovich palina-krukovich self-assigned this Jul 10, 2024
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes streamline subscription management in the UserProfileController by switching to a single DTO for the request body and enhancing error handling in the RestResponseEntityExceptionHandler. A new DTO ActiveSubscriptionRequestDto was introduced to encapsulate the subscription parameters with validation constraints.

Changes

File Change Summary
src/.../UserProfileController.java Updated method to use DTO for subscription request body instead of individual parameters.
src/.../RestResponseEntityExceptionHandler.java Added handlers for TypeMismatchException and HttpMessageNotReadableException with specific error messages.
src/.../dto/ActiveSubscriptionRequestDto.java Introduced new DTO class with validation constraints for subscription parameters.

Poem

In the code where subscriptions bloom,
A DTO now finds its room.
Errors handled with grace anew,
With messages clear, and purpose true.
The rabbits rejoice in fields of green,
For cleaner code they've ever seen! 🌸🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 68d8e1a and 1f3f930.

Files selected for processing (3)
  • src/main/java/io/kontur/disasterninja/controller/UserProfileController.java (3 hunks)
  • src/main/java/io/kontur/disasterninja/controller/exception/RestResponseEntityExceptionHandler.java (2 hunks)
  • src/main/java/io/kontur/disasterninja/dto/ActiveSubscriptionRequestDto.java (1 hunks)
Additional comments not posted (6)
src/main/java/io/kontur/disasterninja/dto/ActiveSubscriptionRequestDto.java (3)

18-19: Validation annotations are appropriate.

The @NotNull annotation for appId is correctly applied.


21-23: Validation annotations are appropriate.

The @NotBlank and @Size annotations for billingPlanId are correctly applied.


25-27: Validation annotations are appropriate.

The @NotBlank and @Size annotations for billingSubscriptionId are correctly applied.

src/main/java/io/kontur/disasterninja/controller/UserProfileController.java (1)

4-4: Import statement is appropriate.

The import of ActiveSubscriptionRequestDto is necessary and correctly added.

src/main/java/io/kontur/disasterninja/controller/exception/RestResponseEntityExceptionHandler.java (2)

49-58: Method handleTypeMismatch is appropriate.

The method correctly handles TypeMismatchException by providing a context-specific error message.


60-76: Method handleHttpMessageNotReadable is appropriate.

The method correctly handles HttpMessageNotReadableException by providing a context-specific error message.

Copy link
Contributor

@gabriel-fallen gabriel-fallen left a comment

Choose a reason for hiding this comment

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

Nice work!

@palina-krukovich palina-krukovich merged commit 1b1e545 into main Jul 10, 2024
2 checks passed
@palina-krukovich palina-krukovich deleted the 19006-improve-api-for-subscriptions branch July 10, 2024 12:39
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