Skip to content

Commit 086a144

Browse files
committed
Updated changelog.md + update ContactAdditionalAddress
1 parent c934ffd commit 086a144

29 files changed

+45
-726
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 12 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -2,167 +2,24 @@
22

33
All notable changes to `laravel-bexio` will be documented in this file.
44

5-
## [Unreleased]
5+
## 20251110
66

7-
### 🚨 Breaking Changes
7+
### Removed ContactAdditionalAddresses
88

9-
#### OAuth Implementation
9+
- **Removed** `ContactAdditionalAddressDTO` and `CreateEditContactAdditionalAddressDTO`
10+
- **Removed** all `ContactAdditionalAddresses` request classes:
11+
- `CreateContactAdditionalAddressRequest`
12+
- `EditAContactAdditionalAddressRequest`
13+
- `FetchAContactAdditionalAddressRequest`
14+
- `FetchAListOfContactAdditionalAddressesRequest`
15+
- `SearchContactAdditionalAddressesRequest`
16+
- `DeleteAContactAdditionalAddressRequest`
1017

11-
**⚠️ MAJOR BREAKING CHANGES** - The authentication system has been completely redesigned to support OAuth alongside token authentication.
12-
13-
##### BexioConnector Constructor Changes
14-
15-
**Before (Token only):**
16-
```php
17-
// Old constructor - DEPRECATED
18-
$connector = new BexioConnector($token);
19-
$connector = new BexioConnector(); // Used config('bexio.auth.token')
20-
```
21-
22-
**After (OAuth + Token support):**
23-
```php
24-
// New constructor - REQUIRED
25-
use CodebarAg\Bexio\Dto\OAuthConfiguration\ConnectWithToken;
26-
use CodebarAg\Bexio\Dto\OAuthConfiguration\ConnectWithOAuth;
27-
28-
// Token authentication
29-
$connector = new BexioConnector(new ConnectWithToken($token));
30-
$connector = new BexioConnector(new ConnectWithToken()); // Uses config
31-
32-
// OAuth authentication
33-
$connector = new BexioConnector(new ConnectWithOAuth($clientId, $clientSecret, $redirectUri, $scopes));
34-
$connector = new BexioConnector(new ConnectWithOAuth()); // Uses config
35-
36-
// Auto-resolve from container (default behavior)
37-
$connector = new BexioConnector(); // Will resolve OAuth config if available
38-
```
39-
40-
##### Configuration Structure Changes
41-
42-
**Before:**
43-
```php
44-
// config/bexio.php
45-
return [
46-
'auth' => [
47-
'token' => env('BEXIO_API_TOKEN'),
48-
],
49-
];
50-
```
51-
52-
**After:**
53-
```php
54-
// config/bexio.php
55-
return [
56-
'auth' => [
57-
'token' => env('BEXIO_API_TOKEN'),
58-
'oauth' => [
59-
'client_id' => env('BEXIO_OAUTH_CLIENT_ID'),
60-
'client_secret' => env('BEXIO_OAUTH_CLIENT_SECRET'),
61-
'redirect_uri' => env('BEXIO_OAUTH_REDIRECT_URI'),
62-
'scopes' => explode(',', env('BEXIO_OAUTH_SCOPES')),
63-
],
64-
],
65-
'cache_store' => env('BEXIO_CACHE_STORE'),
66-
'route_prefix' => null,
67-
'redirect_url' => env('BEXIO_REDIRECT_URL', ''),
68-
];
69-
```
70-
71-
##### New Environment Variables Required
72-
73-
Add these new environment variables for OAuth support:
74-
75-
```dotenv
76-
# OAuth Authentication (NEW)
77-
BEXIO_OAUTH_CLIENT_ID=your_client_id_here
78-
BEXIO_OAUTH_CLIENT_SECRET=your_client_secret_here
79-
BEXIO_OAUTH_REDIRECT_URI=https://yourapp.com/bexio/callback
80-
BEXIO_OAUTH_SCOPES=openid,profile,email,accounting,contact_show
81-
82-
# Optional OAuth Configuration
83-
BEXIO_CACHE_STORE=redis
84-
BEXIO_REDIRECT_URL=/dashboard
85-
```
86-
87-
##### Service Provider Changes
88-
89-
- New OAuth resolver contracts are automatically registered
90-
- OAuth routes are automatically registered at `/bexio/redirect` and `/bexio/callback`
91-
- Route prefix can be customized via `config('bexio.route_prefix')`
92-
93-
##### Migration Guide
94-
95-
1. **Update your BexioConnector instantiation:**
96-
```php
97-
// OLD - This will break
98-
$connector = new BexioConnector($token);
99-
100-
// NEW - Required change
101-
$connector = new BexioConnector(new ConnectWithToken($token));
102-
```
103-
104-
2. **Publish and update config file:**
105-
```bash
106-
php artisan vendor:publish --provider="CodebarAg\Bexio\BexioServiceProvider" --tag="bexio-config" --force
107-
```
108-
109-
3. **For OAuth usage:**
110-
- Register your application in Bexio Developer Portal
111-
- Add OAuth environment variables to `.env`
112-
- Use `ConnectWithOAuth` for OAuth authentication
113-
- Use built-in routes `/bexio/redirect` and `/bexio/callback`
114-
115-
4. **For multi-tenant applications:**
116-
- Implement custom `BexioOAuthConfigResolver` interface
117-
- Implement custom `BexioOAuthAuthenticationStoreResolver` interface
118-
- Optionally implement custom `BexioOAuthAuthenticationValidateResolver` interface for validation logic
119-
- Bind your implementations in a service provider
120-
121-
### ✨ New Features
122-
123-
- **OAuth 2.0 Support**: Full OAuth 2.0 implementation with PKCE support
124-
- **Multi-tenant OAuth**: Support for multiple Bexio accounts via custom resolvers
125-
- **OAuth Authentication Validation**: Custom validation logic before storing OAuth tokens with API access and custom redirects
126-
- **Automatic Token Refresh**: OAuth tokens are automatically refreshed when expired
127-
- **Encrypted Token Storage**: OAuth tokens are encrypted when cached
128-
- **Built-in OAuth Routes**: Automatic OAuth flow handling
129-
- **Configurable Cache Stores**: Support for custom cache stores for token storage
130-
- **Comprehensive Scopes**: Support for all Bexio API and OpenID Connect scopes
131-
132-
#### OAuth Authentication Validation
133-
134-
The new `BexioOAuthAuthenticationValidateResolver` allows you to implement custom validation logic that runs after OAuth authentication but before the token is stored. This powerful feature provides:
135-
136-
- **API Access**: Full `BexioConnector` instance with authenticated access to Bexio API
137-
- **Custom Validation**: Validate user permissions, company restrictions, or any business logic
138-
- **Custom Redirects**: Return custom redirect responses with your own error handling
139-
- **Exception Handling**: Gracefully handle API errors during validation
140-
141-
**Example Use Cases:**
142-
- Validate user email against an allowlist
143-
- Check company permissions via Bexio API calls
144-
- Verify required OAuth scopes are present
145-
- Implement custom business rules for authorization
146-
147-
**Default Behavior**: By default, all OAuth authentications are accepted (validation returns success)
148-
149-
### 🔧 Configuration
150-
151-
- **New OAuth Configuration**: Complete OAuth configuration structure
152-
- **Route Customization**: Customizable OAuth route prefix
153-
- **Cache Store Configuration**: Configurable cache store for token storage
154-
- **Redirect URL Configuration**: Configurable post-authentication redirect
155-
156-
### 📚 Documentation
157-
158-
- **Updated README**: Comprehensive OAuth and multi-tenant documentation
159-
- **OAuth Validation Documentation**: Complete guide for custom OAuth authentication validation with examples
160-
- **Migration Examples**: Detailed migration examples for all scenarios
161-
- **Scope Documentation**: Complete OAuth scope enumeration and documentation
18+
**Migration:** Use `AdditionalAddresses` instead, which provides the same functionality with additional fields (`street_name`, `house_number`, `address_addition`, `name_addition`). All requests now use `contactId` as the parameter name for consistency.
16219

16320
### 🔄 DTO Field Updates
16421

165-
The following DTOs have been updated with new fields:
22+
- **AdditionalAddresses requests:** Standardized parameter naming to use `contactId` instead of `id` for consistency across all requests. The following DTOs have been updated with new fields:
16623

16724
#### Contact & Additional Address Fields (2025-06-04)
16825

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ We provide DTOs for the following:
710710
| BusinessYearDTO |
711711
| CalendarYearDTO |
712712
| CompanyProfileDTO |
713-
| ContactAdditionalAddressDTO |
714713
| ContactGroupDTO |
715714
| ContactRelationDTO |
716715
| ContactDTO |
@@ -751,7 +750,6 @@ In addition to the above, we also provide DTOs to be used for create and edit re
751750
|---------------------------------------|
752751
| CreateCalendarYearDTO |
753752
| CreateEditAdditionalAddressDTO |
754-
| CreateEditContactAdditionalAddressDTO |
755753
| CreateEditContactGroupDTO |
756754
| CreateEditContactRelationDTO |
757755
| CreateEditContactDTO |
@@ -858,7 +856,7 @@ $addresses = $connector->send(new SearchAddressesRequest(
858856
* Create Address
859857
*/
860858
$address = $connector->send(new CreateAnAdditionalAddressRequest(
861-
id: 1,
859+
contactId: 1,
862860
data: new CreateEditAdditionalAddressDTO(
863861
name: 'Test',
864862
subject: 'Test Subject',
@@ -974,28 +972,28 @@ $companyProfile = $connector->send(new FetchACompanyProfileRequest(
974972
### Additional Addresses
975973
```php
976974
/**
977-
* Fetch A List Of Contact Additional Addresses
975+
* Fetch A List Of Additional Addresses
978976
*/
979-
$contactAdditionalAddresses = $connector->send(new FetchAListOfContactAdditionalAddressesRequest(
977+
$additionalAddresses = $connector->send(new FetchAListOfAdditionalAddressesRequest(
980978
contactId: 1
981979
))->dto();
982980
```
983981

984982
```php
985983
/**
986-
* Fetch A Contact Additional Address
984+
* Fetch An Additional Address
987985
*/
988-
$contactAdditionalAddress = $connector->send(new FetchAContactAdditionalAddressRequest(
986+
$additionalAddress = $connector->send(new FetchAnAdditionalAddressRequest(
989987
contactId: 1,
990988
id: 1
991989
))->dto();
992990
```
993991

994992
```php
995993
/**
996-
* Search Contact Additional Address
994+
* Search Additional Addresses
997995
*/
998-
$contactAdditionalAddresses = $connector->send(new SearchContactAdditionalAddressesRequest(
996+
$additionalAddresses = $connector->send(new SearchAdditionalAddressesRequest(
999997
contactId: 1,
1000998
searchField: 'Name',
1001999
searchTerm: 'Something'
@@ -1004,44 +1002,48 @@ $contactAdditionalAddresses = $connector->send(new SearchContactAdditionalAddres
10041002

10051003
```php
10061004
/**
1007-
* Create Contact Additional Address
1005+
* Create Additional Address
10081006
*/
1009-
$contactAdditionalAddress = $connector->send(new CreateContactAdditionalAddressRequest(
1007+
$additionalAddress = $connector->send(new CreateAnAdditionalAddressRequest(
10101008
contactId: 1,
1011-
data: new CreateEditContactAdditionalAddressDTO(
1009+
data: new CreateEditAdditionalAddressDTO(
10121010
name: 'Test',
10131011
subject: 'Test Subject',
10141012
description: 'This is a test',
1015-
address: 'Test Address',
1016-
postcode: '1234',
1013+
street_name: 'Main Street',
1014+
house_number: '123',
1015+
address_addition: 'Apt 4B',
1016+
postcode: 1234,
10171017
city: 'Test City',
10181018
)
10191019
));
10201020
```
10211021

10221022
```php
10231023
/**
1024-
* Edit Contact Additional Address
1024+
* Edit Additional Address
10251025
*/
1026-
$contactAdditionalAddress = $connector->send(new EditAContactAdditionalAddressRequest(
1026+
$additionalAddress = $connector->send(new EditAnAdditionalAddressRequest(
10271027
contactId: 1,
10281028
id: 9,
1029-
data: new CreateEditContactAdditionalAddressDTO(
1029+
data: new CreateEditAdditionalAddressDTO(
10301030
name: 'Test Edit',
10311031
subject: 'Test Subject Edit',
10321032
description: 'This is a test edit',
1033-
address: 'Test Address Edit',
1034-
postcode: '4567',
1033+
street_name: 'Main Street',
1034+
house_number: '456',
1035+
address_addition: 'Suite 2',
1036+
postcode: 4567,
10351037
city: 'Test City Edit',
10361038
)
10371039
));
10381040
```
10391041

10401042
```php
10411043
/**
1042-
* Delete Contact Additional Address
1044+
* Delete Additional Address
10431045
*/
1044-
$contactAdditionalAddress = $connector->send(new DeleteAContactAdditionalAddressRequest(
1046+
$additionalAddress = $connector->send(new DeleteAnAdditionalAddressRequest(
10451047
contactId: 1,
10461048
id: 9,
10471049
));

src/Dto/ContactAdditionalAddresses/ContactAdditionalAddressDTO.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)