Skip to content

Commit 9a9e4b8

Browse files
tanthammarclaude
andcommitted
Fix VAT service documentation examples
- Split VAT lookup into separate examples for business name vs full details - Correct BusinessNameFromVatID to show it returns string, not object - Add proper error handling for VatDetailsFromVatID using valid property - Show all available object properties in full details example 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9960689 commit 9a9e4b8

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,13 @@ $plusgiro = FakePlusgiro::make();
171171
## Services
172172

173173
### VAT Information Lookup
174+
175+
#### Get Business Name Only
174176
```php
175177
use TantHammar\LaravelRules\Services\BusinessNameFromVatID;
176-
use TantHammar\LaravelRules\Services\VatDetailsFromVatID;
177178
use TantHammar\LaravelRules\Enums\BusinessNameLookupError;
178179

179-
// Get business details from VAT ID
180+
// Get business name from VAT ID
180181
$result = BusinessNameFromVatID::lookup('SE556556567801');
181182

182183
if ($result instanceof BusinessNameLookupError) {
@@ -186,14 +187,31 @@ if ($result instanceof BusinessNameLookupError) {
186187
BusinessNameLookupError::ServiceUnavailable => 'VAT service temporarily unavailable',
187188
};
188189
} else {
189-
// Success - $result is the VAT details object
190-
$businessName = $result->name;
191-
$address = $result->address;
192-
$vatNumber = $result->vatNumber;
190+
// Success - $result is the business name string
191+
$businessName = $result;
193192
}
193+
```
194194

195-
// Get full VAT details
195+
#### Get Full VAT Details Object
196+
```php
197+
use TantHammar\LaravelRules\Services\VatDetailsFromVatID;
198+
199+
// Get full VAT details object
196200
$details = VatDetailsFromVatID::lookup('SE556556567801');
201+
202+
// Check if lookup was successful
203+
if ($details->valid) {
204+
// Success - access object properties
205+
$countryCode = $details->countryCode;
206+
$vatNumber = $details->vatNumber;
207+
$requestDate = $details->requestDate;
208+
$businessName = $details->name;
209+
$businessAddress = $details->address;
210+
} else {
211+
// Failed - returns empty object with valid = false
212+
// This happens when VAT ID is invalid or service is unavailable
213+
$errorMessage = 'VAT ID not found or service unavailable';
214+
}
197215
```
198216

199217
### Business Type Detection

0 commit comments

Comments
 (0)