-
Notifications
You must be signed in to change notification settings - Fork 9
Add contact event functionality #52
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds a new Contact API method to create contact events, introduces a corresponding DTO, updates examples to demonstrate event creation, extends tests to cover success and error cases, and updates README with new capability bullets. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Contact API (createContactEvent)
participant HTTP as HTTP Client
participant SVC as Mailtrap API
Dev->>SDK: createContactEvent(contactIdentifier, CreateContactEvent)
SDK->>HTTP: POST /contacts/{encoded(contactIdentifier)}/events\nbody: { name, params }
HTTP->>SVC: Request
alt Success
SVC-->>HTTP: 2xx Response
HTTP-->>SDK: ResponseInterface
SDK-->>Dev: ResponseInterface
else Error
SVC-->>HTTP: 4xx/5xx Error
HTTP-->>SDK: Error details
SDK-->>Dev: Exception (HttpClientException)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
CHANGELOG.md (2)
1-1
: Future-dated release entry — use “Unreleased” until tag, or update on release dayThe 3.8.0 entry is dated 2025-09-22, which is in the future relative to today (2025-09-18). Suggest marking as Unreleased until tagging, then replace with the actual release date.
Option A — keep as Unreleased for now:
-## [3.8.0] - 2025-09-22 +## [Unreleased]Option B — if you are tagging 3.8.0 today, update the date:
-## [3.8.0] - 2025-09-22 +## [3.8.0] - 2025-09-18
2-2
: Capitalize “Event” for consistencyPrior entries use Title Case (e.g., “Contact Imports”, “Contact Fields”). Align this one to “Create Contact Event”.
-- Add Create Contact event API functionality +- Add Create Contact Event API functionality
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
CHANGELOG.md
(1 hunks)README.md
(2 hunks)examples/general/contacts.php
(2 hunks)src/Api/General/Contact.php
(2 hunks)src/DTO/Request/Contact/CreateContactEvent.php
(1 hunks)tests/Api/General/ContactTest.php
(2 hunks)
🔥 Files not summarized due to errors (1)
- CHANGELOG.md: Error: Server error: no LLM provider could handle the message
🧰 Additional context used
🧬 Code graph analysis (4)
src/DTO/Request/Contact/CreateContactEvent.php (1)
src/Api/General/Contact.php (1)
Contact
(19-363)
src/Api/General/Contact.php (2)
src/DTO/Request/Contact/CreateContactEvent.php (2)
CreateContactEvent
(12-42)toArray
(35-41)src/Api/AbstractApi.php (2)
handleResponse
(84-111)httpPost
(43-50)
examples/general/contacts.php (3)
src/Api/General/Contact.php (2)
Contact
(19-363)createContactEvent
(301-309)src/DTO/Request/Contact/CreateContactEvent.php (3)
CreateContactEvent
(12-42)init
(20-23)toArray
(35-41)src/Helper/ResponseHelper.php (1)
ResponseHelper
(14-37)
tests/Api/General/ContactTest.php (8)
src/Api/General/Contact.php (2)
Contact
(19-363)createContactEvent
(301-309)src/DTO/Request/Contact/CreateContactEvent.php (2)
CreateContactEvent
(12-42)toArray
(35-41)src/Api/AbstractApi.php (1)
AbstractApi
(18-150)src/DTO/Request/Contact/ImportContact.php (1)
toArray
(49-57)src/DTO/Request/Contact/UpdateContact.php (1)
toArray
(56-68)src/DTO/Request/Contact/CreateContact.php (1)
toArray
(39-46)src/Helper/ResponseHelper.php (1)
ResponseHelper
(14-37)src/Exception/HttpClientException.php (1)
HttpClientException
(14-84)
🔇 Additional comments (11)
README.md (1)
25-25
: Documentation is accurately updated to reflect new capabilities.The README correctly documents the three new capabilities added by this PR:
- "Sending domain management CRUD" under Email API/SMTP
- "Events" under Contact management/Import
- "Billing info" under General
These additions accurately reflect the expanded feature set, with the "Events" capability directly related to the CreateContactEvent functionality introduced in this PR.
Also applies to: 38-38, 42-42
examples/general/contacts.php (2)
5-5
: Import statement is correctly added.The CreateContactEvent DTO is properly imported to support the new example.
326-350
: Example demonstrates the new contact event functionality effectively.The example correctly shows:
- Using email as the contact identifier
- Creating an event with CreateContactEvent::init()
- Including both required (name) and optional (params) fields
- Proper error handling with try-catch
- Displaying the response using ResponseHelper
The parameter structure with mixed types (int, string, bool, null) provides a comprehensive example.
src/Api/General/Contact.php (2)
10-10
: Import statement correctly added for the new DTO.
294-309
: The createContactEvent method implementation looks good.The method correctly:
- Accepts a contact identifier (email or UUID) and CreateContactEvent DTO
- URL-encodes the contact identifier to handle special characters in emails
- Uses the DTO's toArray() method for the request body
- Follows the existing pattern used by other methods in this class
- Returns a ResponseInterface wrapped with handleResponse for error handling
src/DTO/Request/Contact/CreateContactEvent.php (1)
1-42
: The CreateContactEvent DTO is well-structured and follows established patterns.The implementation:
- Correctly implements RequestInterface
- Uses constructor property promotion (PHP 8 feature)
- Provides a static factory method init() consistent with other DTOs
- Implements toArray() for request serialization
- Makes params optional with a sensible default (empty array)
- Is marked as final to prevent inheritance
tests/Api/General/ContactTest.php (5)
8-8
: Import statement correctly added for testing the new DTO.
657-699
: The basic createContactEvent test is comprehensive.The test properly verifies:
- URL encoding of the email identifier
- Correct request path construction
- Payload serialization via toArray()
- Response handling and data assertions
701-740
: Test correctly validates UUID-based contact identification.Good coverage of using a UUID instead of email as the contact identifier.
742-769
: Empty params test validates optional parameter behavior.Correctly verifies that events can be created without params, using the default empty array.
771-926
: Excellent error handling test coverage.The test suite comprehensively covers error scenarios:
- 404: Contact not found
- 422: Validation errors (empty name, complex validation errors)
- 401: Authentication failures
- 403: Authorization failures
- 429: Rate limiting
Each test properly validates the expected error message format.
Motivation
Support new create contact event functionality
Changes
How to test
composer test
Summary by CodeRabbit
New Features
Documentation
Tests