Repository navigation
π§ Patch Release v2.0.2 - ApiPermission Enum Enhancement
π Overview
This patch release enhances the ApiPermission enum by adding a new DELIVERY permission level and normalizing case naming conventions.
β οΈ BREAKING CHANGES
ApiPermission Enum
Case Name Change:
// v2.0.1 (Old)
ApiPermission::READ_ONLY
// v2.0.2 (New)
ApiPermission::READONLYValue Change:
// v2.0.1 (Old)
'read-only'
// v2.0.2 (New)
'readonly'β¨ New Features
New Permission Level: DELIVERY
Added a new permission level specifically for delivery-only API access:
use GoSuccess\Digistore24\Api\Enum\ApiPermission;
// Available permission levels
ApiPermission::READONLY // Value: 'readonly' - Read-only access
ApiPermission::DELIVERY // Value: 'delivery' - Delivery operations only
ApiPermission::WRITABLE // Value: 'writable' - Full write accessUse Cases for DELIVERY Permission:
- API keys used exclusively for order delivery/fulfillment
- Limited access scope for third-party integrations
- Separation of concerns between read, delivery, and write operations
π§ͺ Quality Assurance
- β 1145/1145 Unit Tests Passing (+8 new tests, 2294 assertions)
- β PHPStan Level 9: 0 errors (654 files analyzed, +1 file)
- β PHP CS Fixer: 0 violations (PSR-12 compliant)
- β
New Test File:
ApiPermissionTest.phpwith comprehensive coverage
π Test Coverage
The new ApiPermissionTest includes:
- β Value Validation - All cases have correct string values
- β Label Testing - All cases return proper human-readable labels
- β
Case-Insensitive Conversion -
fromString()handles mixed case - β Invalid Input Handling - Graceful null returns for invalid values
- β Labels Mapping - Complete value-to-label array generation
- β Values Array - All valid string values extraction
- β
Validation Method -
isValid()checks for valid permissions - β Edge Cases - Null, empty string, and invalid value handling
π§ Migration Guide
For users upgrading from v2.0.1 β v2.0.2
If you're using ApiPermission enum directly in your code:
// Old (v2.0.1)
if ($permission === ApiPermission::READ_ONLY) {
// read-only logic
}
// New (v2.0.2)
if ($permission === ApiPermission::READONLY) {
// read-only logic
}
// New DELIVERY case
if ($permission === ApiPermission::DELIVERY) {
// delivery-only logic
}String Value Changes:
// Old (v2.0.1)
ApiPermission::fromString('read-only'); // β
Worked
// New (v2.0.2)
ApiPermission::fromString('readonly'); // β
Now works
ApiPermission::fromString('read-only'); // β Returns null
ApiPermission::fromString('delivery'); // β
New DELIVERY caseNote: The fromString() method is case-insensitive, so 'READONLY', 'ReadOnly', and 'readonly' all work.
π¦ Files Changed
3 files changed: 81 insertions(+), 3 deletions(-)
Modified Files (2)
src/Enum/ApiPermission.php- Added DELIVERY case, renamed READ_ONLY β READONLYRELEASE_NOTES.md- Updated release documentation
New Files (1)
tests/Unit/Enum/ApiPermissionTest.php- Comprehensive test suite (8 tests)
π‘ Why This Change?
1. Consistency
- PHP property naming convention: use
readonlykeyword (notread_only) - Hyphenated values (
'read-only') are inconsistent with camelCase/PascalCase - Aligns with modern PHP 8.4 conventions
2. Separation of Concerns
READONLY- View data only (GET operations)DELIVERY- Fulfill orders, update delivery status (limited POST/PUT)WRITABLE- Full CRUD operations (unrestricted access)
3. Security
- Granular permission control for API keys
- Minimize attack surface by limiting key capabilities
- Better audit trail with specific permission levels
π― Impact Analysis
Who is affected?
- Low Impact: Most users don't directly interact with
ApiPermissionenum - Medium Impact: Users with custom permission checking logic
- High Impact: Users storing permission strings in databases (migration required)
Database Migration (if storing permissions):
-- Update existing 'read-only' values to 'readonly'
UPDATE api_keys SET permission = 'readonly' WHERE permission = 'read-only';
-- Verify no old values remain
SELECT * FROM api_keys WHERE permission = 'read-only';π Changelog Summary
Added
ApiPermission::DELIVERYcase for delivery-only operationsApiPermissionTestwith 8 comprehensive test methods- Label for DELIVERY permission: "Delivery"
Changed (Breaking)
ApiPermission::READ_ONLYβApiPermission::READONLY- String value:
'read-only'β'readonly'
Improved
- Test coverage increased from 1137 to 1145 tests (+8)
- Assertions increased from 2286 to 2294 (+8)
- PHPStan now analyzes 654 files (was 653)
Full Changelog: v2.0.1...v2.0.2