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

DPMMA-2550 Point Groups API #13517

Merged
merged 12 commits into from Apr 29, 2024

Conversation

patrykgruszka
Copy link
Member

@patrykgruszka patrykgruszka commented Mar 4, 2024

Q A
Bug fix? (use the a.b branch) [ N ]
New feature/enhancement? (use the a.x branch) [ Y ]
Deprecations? [ N ]
BC breaks? (use the c.x branch) [ N ]
Automated tests included? [ Y ]
Related user documentation PR URL mautic/mautic-documentation#...
Related developer documentation PR URL mautic/developer-documentation-new#185
Issue(s) addressed Fixes #...

Description:

This PR adds API endpoints for Point Groups management.

mautic_api_pointGroups_getall          GET     /api/points/groups                                                                               
mautic_api_pointGroups_getone          GET     /api/points/groups/{id}                                                                          
mautic_api_pointGroups_new             POST    /api/points/groups/new                                                                                                                                        
mautic_api_pointGroups_editput         PUT     /api/points/groups/{id}/edit                                                                     
mautic_api_pointGroups_editpatch       PATCH   /api/points/groups/{id}/edit                                                                                                                           
mautic_api_pointGroups_delete          DELETE  /api/points/groups/{id}/delete                                                                   
mautic_api_getcontactpointgroups       GET     /api/contacts/{contactId}/points/groups                                                          
mautic_api_getcontactpointgroup        GET     /api/contacts/{contactId}/points/groups/{groupId}                                                
mautic_api_adjustcontactgrouppoints    POST    /api/contacts/{contactId}/points/groups/{groupId}/{operator}/{value} 

Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)

  2. Create a new point group:

    • Endpoint: POST https://your-api-host.com/api/points/groups/new
    • Payload: JSON payload with the following fields:
      {
          "name": "New Point Group",
          "description": "Description of the new point group"
      }
  3. Retrieve all point groups:

    • Endpoint: GET https://your-api-host.com/api/points/groups
  4. Update the created point group:

    • Endpoint: PATCH https://your-api-host.com/api/points/groups/{id}/edit
    • Payload: JSON payload with the fields to update:
      {
          "name": "Updated Point Group Name",
          "description": "Updated description of the point group"
      }
  5. Delete the created point group:

    • Endpoint: DELETE https://your-api-host.com/api/points/groups/{id}/delete
  6. Get contact group points:

    • Endpoint: GET https://your-api-host.com/api/contacts/{leadId}/points/groups
  7. Adjust contact group points:

    • Plus operation:
      • Endpoint: POST https://your-api-host.com/api/contacts/{leadId}/points/groups/{groupId}/plus/{value}
    • Minus operation:
      • Endpoint: POST https://your-api-host.com/api/contacts/{leadId}/points/groups/{groupId}/minus/{value}
    • Set operation:
      • Endpoint: POST https://your-api-host.com/api/contacts/{leadId}/points/groups/{groupId}/set/{value}
    • Divide operation:
      • Endpoint: POST https://your-api-host.com/api/contacts/{leadId}/points/groups/{groupId}/divide/{value}
    • Multiply operation:
      • Endpoint: POST https://your-api-host.com/api/contacts/{leadId}/points/groups/{groupId}/times/{value}

When testing these endpoints, ensure that you replace placeholders such as {leadId}, {groupId}, and {value} with actual IDs and values as required for your specific test cases. Additionally, for endpoints that require a request body, provide the appropriate JSON payload with the necessary fields and values.

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 61.50%. Comparing base (6d1027d) to head (11575ef).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.x   #13517      +/-   ##
============================================
+ Coverage     61.43%   61.50%   +0.07%     
- Complexity    34050    34067      +17     
============================================
  Files          2240     2241       +1     
  Lines        101773   101850      +77     
============================================
+ Hits          62520    62639     +119     
+ Misses        39253    39211      -42     
Files Coverage Δ
app/bundles/PointBundle/Entity/Group.php 100.00% <100.00%> (+38.09%) ⬆️
...p/bundles/PointBundle/Entity/GroupContactScore.php 100.00% <100.00%> (ø)
app/bundles/PointBundle/Entity/GroupRepository.php 100.00% <100.00%> (ø)
app/bundles/PointBundle/Model/PointGroupModel.php 85.24% <100.00%> (+44.56%) ⬆️
...Bundle/Controller/Api/PointGroupsApiController.php 87.93% <87.93%> (ø)

... and 1 file with indirect coverage changes

@patrykgruszka patrykgruszka added ready-to-test PR's that are ready to test code-review-needed PR's that require a code review before merging API Anything related to the API points-scoring Anything related to points labels Mar 6, 2024
RCheesley
RCheesley previously approved these changes Apr 19, 2024
Copy link
Sponsor Member

@RCheesley RCheesley left a comment

Choose a reason for hiding this comment

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

Tested all endpoints (thank you SO MUCH for the awesome documentation in the PR @patrykgruszka it really helps testers when you provide both the path and the snippet!).

All working as expected. Thanks for the great work! 🚀

@RCheesley RCheesley added pending-test-confirmation PR's that require one test before they can be merged and removed ready-to-test PR's that are ready to test labels Apr 19, 2024
Copy link
Sponsor Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

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

The code looks great! I have a few small suggestions. The functional tests are testing the happy paths. It would be great to have tests that check also 404s, xss and similar. But happy path tests are still way better than none 👍

@escopecz escopecz added the pending-feedback PR's and issues that are awaiting feedback from the author label Apr 24, 2024
@patrykgruszka patrykgruszka removed the pending-feedback PR's and issues that are awaiting feedback from the author label Apr 26, 2024
@patrykgruszka
Copy link
Member Author

Thanks! I've updated the code and added some extra tests :)

Would you have some time to look at the related PR in the API library? mautic/api-library#322

Copy link
Sponsor Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

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

I see no issue in the code. The Point group/score is covered with functional tests 👍

@escopecz escopecz removed the code-review-needed PR's that require a code review before merging label Apr 29, 2024
@escopecz escopecz added code-review-passed PRs which have passed code review and removed pending-test-confirmation PR's that require one test before they can be merged labels Apr 29, 2024
@escopecz escopecz added this to the 5.1.0 milestone Apr 29, 2024
@escopecz escopecz added the enhancement Any improvement to an existing feature or functionality label Apr 29, 2024
@escopecz escopecz merged commit f86c50e into mautic:5.x Apr 29, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Anything related to the API code-review-passed PRs which have passed code review enhancement Any improvement to an existing feature or functionality points-scoring Anything related to points
Projects
Status: 🥳 Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants