soat-fiap / FIAP.TechChallenge.ByteMeBurger

Repository for FIAP SOAT post degree Tech Challenge
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

feat: create and search customer by cpf #15 #1 #2 #21

Closed italopessoa closed 2 months ago

italopessoa commented 2 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

Walkthrough

The refinements in the tech challenge project include enhancing functionalities and making improvements across various layers like API, Application, Domain, Infrastructure, and Testing. Key enhancements involve adding customer and product services, APIs, repositories, updating project structures, and integrating FluentAssertions in tests for improved readability and assertion management.

Changes

File Path Change Summary
src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Entity.cs Renamed generic type parameter to TId and updated Equals and GetHashCode methods based on the new type parameter.
src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/ValueObject.cs Updated Equals method signature to accept a nullable object parameter.
src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs Added imports for services, ports, and repository. Updated service and repository registrations. Uncommented Swagger setup for development environment. Removed array initialization for summaries.
src/FIAP.TechChallenge.ByteMeBurger.Infrastructure/Repository/InMemoryCustomerRepository.cs Introduced InMemoryCustomerRepository class implementing ICustomerRepository with methods for asynchronous customer search by CPF and new customer creation in an in-memory collection.


<!-- walkthrough_end --><!-- This is an auto-generated comment: raw summary by coderabbit.ai -->
<!--

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Entity.cs: 
- The generic type parameter in the `Entity` class has been renamed from `T` to `TId`.
- The `Equals` and `GetHashCode` methods have been updated to work with the `Id` property based on the new type parameter.

---

src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/ValueObject.cs: 
- Updated the `Equals` method signature in `ValueObject.cs` to accept a nullable object parameter, changing `public override bool Equals(object obj)` to `public override bool Equals(object? obj)`.

---

src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs: ## Short summary
- Added imports for services, ports, and repository.
- Added service and repository registrations.
- Uncommented Swagger setup for development environment.
- Removed array initialization for `summaries`.

---

src/FIAP.TechChallenge.ByteMeBurger.Infrastructure/Repository/InMemoryCustomerRepository.cs: 
- This file introduces an `InMemoryCustomerRepository` class that implements an `ICustomerRepository` interface. It provides methods to find a customer by CPF asynchronously and to create a new customer in an in-memory collection.

-->
<!-- end of auto-generated comment: raw summary by coderabbit.ai --><!-- This is an auto-generated comment: short summary by coderabbit.ai -->
<!--

### PR Objectives

This pull request, titled "feat: create and search customer by cpf #15 #1 #2" and numbered 21, introduces several enhancements and new features to the FIAP.TechChallenge.ByteMeBurger project. The primary focus is on customer management functionalities, specifically creating and searching for customers by their CPF (Cadastro de Pessoas Físicas, a Brazilian tax identification number). Key changes include:

1. **Refactoring**: The project now utilizes FluentAssertions for more readable and robust testing assertions.
2. **Testing**: Addition of unit tests to ensure the reliability and correctness of the new functionalities.
3. **Data Transfer Objects (DTOs)**: Introduction of `CustomerDto` to facilitate data transfer operations.
4. **Commands**: Implementation of `CreateCustomerCommand` to handle the creation of new customers.
5. **Ports**: Addition of product-related ports to abstract core functionalities which can be adapted for different external services or databases.

These changes are part of ongoing efforts to enhance the application's architecture and maintainability, as indicated by the linked issues #15, #1, and #2.

### AI-Generated Summary of Generated Summaries

The pull request introduces significant updates across multiple layers of the FIAP.TechChallenge.ByteMeBurger application, focusing on enhancing customer management and product service functionalities:

1. **Code Refactoring and Testing**:
   - Refactored code to use FluentAssertions for improved testing assertions.
   - Added unit tests to ensure the reliability and correctness of the new functionalities.

2. **Data Handling Enhancements**:
   - Introduced `CustomerDto` for efficient data transfer operations.
   - Implemented `CreateCustomerCommand` to manage the creation of new customers.

3. **Architecture Updates**:
   - Renamed the generic type parameter in the `Entity` class to `TId` for clarity.
   - Updated `Equals` and `GetHashCode` methods in the `Entity` class to work with the `Id` property based on the new type parameter.
   - Modified the `Equals` method signature in `ValueObject.cs` to accept a nullable object parameter.

These changes collectively enhance the application's functionality, maintainability, and testing capabilities, ensuring a more robust and efficient codebase for managing customer data and product services effectively.

-->
<!-- end of auto-generated comment: short summary by coderabbit.ai -->

---

<details>

<summary>Recent Review Details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**

<details>
<summary>Commits</summary>
Files that changed from the base of the PR and between 871ac899cc68296757bee1bfe34179847583599b and 031323da95a7c5c5d91fbb6a0851962f5d833935.
</details>

<details>
<summary>Files selected for processing (2)</summary>

* src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs (2 hunks)
* src/FIAP.TechChallenge.ByteMeBurger.Infrastructure/Repository/InMemoryCustomerRepository.cs (1 hunks)

</details>

<details>
<summary>Files skipped from review as they are similar to previous changes (1)</summary>

* src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs

</details>

<details>
<summary>Additional Context Used</summary>

<details>
<summary>Path-based Instructions (1)</summary>
<blockquote>

<details><summary>src/FIAP.TechChallenge.ByteMeBurger.Infrastructure/Repository/InMemoryCustomerRepository.cs (1)</summary><blockquote>

Pattern `**/*.cs`: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

</blockquote></details>

</blockquote></details>

</details>

</details><!-- commit_ids_reviewed_start -->

<!-- 64115ed469d4c1ce0af626db154722fb4690173d -->
<!-- 871ac899cc68296757bee1bfe34179847583599b -->
<!-- 031323da95a7c5c5d91fbb6a0851962f5d833935 -->

<!-- commit_ids_reviewed_end --><!-- tips_start -->

---

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?

<details>
<summary>Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai):

- 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.`

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 a review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->