feat: used parser output to recreate the DTOs

This commit is contained in:
2024-08-15 03:57:04 +03:00
parent 15a4593345
commit 8089a5c0dd
11 changed files with 243 additions and 329 deletions

View File

@@ -7,77 +7,58 @@ use Spatie\DataTransferObject\DataTransferObject;
/**
* Business Address
*
* - careOf (string, optional): Care of address
* - street (string, optional): Street address
* - postCode (string, optional): ZIP code
* - city (string, optional): City of address
* - language (string, optional): Two letter language code
* - type (integer): Type of address, 1 for street address, 2 for postal address
* - country (string, optional): Two letter country code
*/
class BisAddress extends DataTransferObject
{
use HasSource;
/**
* One for current version and >1 for historical company names
*
* @var int
* One for current version and >1 for historical addresses
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate = '';
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate = null;
/**
* Care of address (c/o)
*
* @var string|null
* Care of address
*/
public ?string $careOf;
public ?string $careOf = null;
/**
* Street address
*
* @var string|null
*/
public ?string $street;
public ?string $street = null;
/**
* ZIP code
*
* @var string|null
*/
public ?string $postCode;
public ?string $postCode = null;
/**
* City of address
*
* @var string|null
*/
public ?string $city;
public ?string $city = null;
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language;
public ?string $language = null;
/**
* Type of address, 1 for street address, 2 for postal address
*
* @var int
*/
public int $type;
/**
* Two-letter country code
*
* @var string|null
* Two letter country code
*/
public ?string $country;
public ?string $country = null;
}

View File

@@ -7,28 +7,56 @@ use Spatie\DataTransferObject\DataTransferObject;
/**
* Company Business ID Change
*
* - description (string): Description of reason
* - reason (string): Reason code
* - changeDate (string, optional): Date of Business ID change
* - change (integer):
* 2 = Business ID removal,
* 3 = Combining of double IDs,
* 5 = ID changed,
* 44 = Fusion,
* 45 = Operator continuing VAT activities,
* 46 = Relation to predecessor,
* 47 = Division,
* 48 = Bankruptcy relationship,
* 49 = Operations continued by a private trader,
* 57 = Partial division,
* DIF = Division,
* FUU = Fusion
* - oldBusinessId (string): Old Business ID
* - newBusinessId (string): New Business ID
* - language (string, optional): Two letter language code
*/
class BisCompanyBusinessIdChange extends DataTransferObject
{
use HasSource;
/**
* Description of reason
*/
public string $description = "";
/**
* Reason code
*/
public string $reason = "";
/**
* Date of Business ID change
*/
public ?string $changeDate = null;
/**
* Business ID Change
*
* 2 = Business ID removal,
* 3 = Combining of double IDs,
* 5 = ID changed,
* 44 = Fusion,
* 45 = Operator continuing VAT activities,
* 46 = Relation to predecessor,
* 47 = Division,
* 48 = Bankruptcy relationship,
* 49 = Operations continued by a private trader,
* 57 = Partial division,
* DIF = Division,
* FUU = Fusion
*/
public int $change;
/**
* Old Business ID
*/
public string $oldBusinessId = "";
/**
* New Business ID
*/
public string $newBusinessId = "";
/**
* Two letter language code
*/
public ?string $language = null;
}

View File

@@ -7,58 +7,38 @@ use Spatie\DataTransferObject\DataTransferObject;
/**
* Company Business Line
*
* - order (integer): Zero for main line of business, positive for others
* - version (integer):
* One for current version and
* >1 for historical lines of business
* - registrationDate (string): Date of registration
* - endDate (string, optional): Ending date of registration
* - name (string): Name of line of business
* - language (string, optional): Two letter language code
*/
class BisCompanyBusinessLine extends DataTransferObject
{
use HasSource;
/**
* Order
*
* Zero for primary company name,
* other for translations of the primary company name
* and auxiliary company names
*
* @var int
* Zero for main line of business, positive for others
*/
public int $order;
/**
* One for current version and >1 for historical company names
*
* @var int
* One for current version and >1 for historical lines of business
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate = '';
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate = null;
/**
* Name of line of business
*
* @var string
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language = null;
}

View File

@@ -14,38 +14,31 @@ class BisCompanyContactDetail extends DataTransferObject
/**
* One for current version and >1 for historical contact details
*
* @var int
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate;
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate;
public ?string $endDate = null;
/**
* Two letter language code
*
* @var string
*/
public string $language;
public ?string $language = null;
/**
* Value of contact detail
*
* @var string
*/
public string $value;
public string $value = "";
/**
* Type of contact detail
*
* @var string
*/
public string $type;
public string $type = "";
}

View File

@@ -12,121 +12,104 @@ use Spatie\DataTransferObject\DataTransferObject;
class BisCompanyDetails extends DataTransferObject
{
/**
* Business ID
*
* @var string
* Primary company name and translations
* @var BisCompanyName[] $names
*/
public string $businessId;
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyName::class)]
public array $names = [];
/**
* Primary company name
*
* @var string
* Auxiliary company name and translations
* @var ?BisCompanyName[] $auxiliaryNames
*/
public string $name;
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyName::class)]
public ?array $auxiliaryNames = [];
/**
* Company's street and postal addresses
* @var ?BisAddress[] $addresses
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisAddress::class)]
public ?array $addresses = [];
/**
* Company form and translations
* @var ?BisCompanyForm[] $companyForms
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyForm::class)]
public ?array $companyForms = [];
/**
* Bankruptcy, liquidation or restructuring proceedings
* @var ?BisCompanyLiquidation[] $liquidations
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyLiquidation::class)]
public ?array $liquidations = [];
/**
* Company's lines of business and translations
* @var ?BisCompanyBusinessLine[] $businessLines
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyBusinessLine::class)]
public ?array $businessLines = [];
/**
* Company's language(s)
* @var ?BisCompanyLanguage[] $languages
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyLanguage::class)]
public ?array $languages = [];
/**
* Company's place of registered office and its translations
* @var ?BisCompanyRegisteredOffice[] $registeredOffices
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyRegisteredOffice::class)]
public ?array $registeredOffices = [];
/**
* Company's contact details and translations
* @var ?BisCompanyContactDetail[] $contactDetails
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyContactDetail::class)]
public ?array $contactDetails = [];
/**
* Company's registered entries
* @var ?BisCompanyRegisteredEntry[] $registeredEntries
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyRegisteredEntry::class)]
public ?array $registeredEntries = [];
/**
* Company's Business ID changes
* @var ?BisCompanyBusinessIdChange[] $businessIdChanges
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyBusinessIdChange::class)]
public ?array $businessIdChanges = [];
/**
* Business ID
*/
public string $businessId = "";
/**
* Date of registration
*
* @var string
*/
public string $registrationDate;
public string $registrationDate = "";
/**
* Company form
*
* @var string|null
*/
public ?string $companyForm = null;
/**
* A URI for more details, if details aren't already included
*
* @var string|null
*/
public ?string $detailsUri = null;
/**
* Primary company name and translations
*
* @var BisCompanyName[] $names
* Primary company name
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyName::class)]
public ?array $names = null;
/**
* Auxiliary company name and translations
*
* @var BisCompanyName[] $auxiliaryNames
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyName::class)]
public ?array $auxiliaryNames = null;
/**
* Company's street and postal addresses
*
* @var BisAddress[]|null $addresses
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisAddress::class)]
public ?array $addresses = null;
/**
* Company form and translations
*
* @var BisCompanyForm[]|null $companyForms
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyForm::class)]
public ?array $companyForms = null;
/**
* Bankruptcy, liquidation or restructuring proceedings
*
* @var BisCompanyLiquidation[]|null $liquidations
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyLiquidation::class)]
public ?array $liquidations = null;
/**
* Company's lines of business and translations
*
* @var BisCompanyBusinessLine[]|null $businessLines
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyBusinessLine::class)]
public ?array $businessLines = null;
/**
* Company's language(s)
*
* @var BisCompanyLanguage[]|null $languages
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyLanguage::class)]
public ?array $languages = null;
/**
* Company's place of registered office and its translations
*
* @var BisCompanyRegisteredOffice[]|null $registeredOffices
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyRegisteredOffice::class)]
public ?array $registeredOffices = null;
/**
* Company's contact details and translations
*
* @var BisCompanyContactDetail[]|null $contactDetails
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyContactDetail::class)]
public ?array $contactDetails = null;
/**
* Company's registered entries
*
* @var BisCompanyRegisteredEntry[]|null $registeredEntries
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyRegisteredEntry::class)]
public ?array $registeredEntries = null;
/**
* Company's Business ID changes
*
* @var BisCompanyBusinessIdChange[]|null $businessIdChanges
*/
#[CastWith(Casters\ArrayCaster::class, itemType: BisCompanyBusinessIdChange::class)]
public ?array $businessIdChanges = null;
public string $name = "";
}

View File

@@ -14,34 +14,29 @@ class BisCompanyForm extends DataTransferObject
/**
* One for current version and >1 for historical company forms
*
* @var int
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate;
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate;
public ?string $endDate = null;
/**
* Name of company form
*
* @var string
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language;
public ?string $language = null;
/**
* Type of company form.
*

View File

@@ -13,33 +13,32 @@ class BisCompanyLanguage extends DataTransferObject
use HasSource;
/**
* One for current version and >1 for historical company names
*
* @var int
* One for current version and >1 for historical company forms
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate = '';
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate = null;
/**
* Company name
*
* @var string
* Bankruptcy, liquidation or restructuring proceedings
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language = null;
/**
* Type of liquidation
*/
public string $type = "";
}

View File

@@ -7,58 +7,38 @@ use Spatie\DataTransferObject\DataTransferObject;
/**
* Company Liquidation
*
* - version (integer): One for current version and >1 for historical company forms
* - registrationDate (string): Date of registration
* - endDate (string, optional): Ending date of registration
* - name (string): Bankruptcy, liquidation or restructuring proceedings
* - language (string, optional): Two letter language code
* - type (string): Type of liquidation
*/
class BisCompanyLiquidation extends DataTransferObject
{
use HasSource;
/**
* Order
*
* Zero for primary company name,
* other for translations of the primary company name
* and auxiliary company names
*
* @var int
*/
public int $order;
/**
* One for current version and >1 for historical company names
*
* @var int
* One for current version and >1 for historical company forms
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate = '';
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate = null;
/**
* Bankruptcy, liquidation or restructuring proceedings
*
* @var string
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language = null;
public string $type;
/**
* Type of liquidation
*/
public string $type = "";
}

View File

@@ -18,38 +18,30 @@ class BisCompanyName extends DataTransferObject
* Zero for primary company name,
* other for translations of the primary company name
* and auxiliary company names
*
* @var int
*/
public int $order;
/**
* One for current version and >1 for historical company names
*
* @var int
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate = '';
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate = null;
/**
* Company name
*
* @var string
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language = null;
}

View File

@@ -12,32 +12,26 @@ class BisCompanyRegisteredEntry extends DataTransferObject
{
/**
* Description of entry
*
* @var string
*/
public string $description;
public string $description = "";
/**
* Zero for common entries, one for Unregistered and two for Registered
*
* @see getStatusText()
*
* @var int
*/
public int $status;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate;
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate;
public ?string $endDate = null;
/**
* register (integer):
* register (int):
* - One for Trade Register,
* - two for Register of Foundations,
* - three for Register of Associations,
@@ -48,18 +42,14 @@ class BisCompanyRegisteredEntry extends DataTransferObject
* - eight for register of bodies liable for tax on insurance premiums
*
* @see getRegisterText()
*
* @var int
*/
public int $register;
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language;
/**
* authority (integer):
* authority (int):
* - One for Tax Administration,
* - two for Finnish Patent and Registration Office and
* - three for Population Register
@@ -74,35 +64,35 @@ class BisCompanyRegisteredEntry extends DataTransferObject
{
// Zero for common entries, one for Unregistered and two for Registered
return match ($this->status) {
0 => 'Common',
1 => 'Unregistered',
2 => 'Registered',
default => throw new UnexpectedValueException('Unexpected value: ' . $this->status)
0 => "Common",
1 => "Unregistered",
2 => "Registered",
default => throw new UnexpectedValueException("Unexpected value: " . $this->status),
};
}
public function getRegisterText(): string
{
return match ($this->register) {
1 => 'Trade Register',
2 => 'Register of Foundations',
3 => 'Register of Associations',
4 => 'Tax Administration',
5 => 'Prepayment Register',
6 => 'VAT Register',
7 => 'Employer Register',
8 => 'register of bodies liable for tax on insurance premiums',
default => throw new UnexpectedValueException('Unexpected value: ' . $this->register),
1 => "Trade Register",
2 => "Register of Foundations",
3 => "Register of Associations",
4 => "Tax Administration",
5 => "Prepayment Register",
6 => "VAT Register",
7 => "Employer Register",
8 => "register of bodies liable for tax on insurance premiums",
default => throw new UnexpectedValueException("Unexpected value: " . $this->register),
};
}
public function getAuthorityText(): string
{
return match ($this->authority) {
1 => 'Tax Administration',
2 => 'Finnish Patent and Registration Office',
3 => 'Population Register',
default => throw new UnexpectedValueException('Unexpected value: ' . $this->authority),
1 => "Tax Administration",
2 => "Finnish Patent and Registration Office",
3 => "Population Register",
default => throw new UnexpectedValueException("Unexpected value: " . $this->authority),
};
}
}

View File

@@ -14,38 +14,31 @@ class BisCompanyRegisteredOffice extends DataTransferObject
/**
* Zero for primary place of registered office, positive for others
*
* @var int
*/
public int $order;
/**
* One for current version and >1 for historical places of registered office
*
* @var int
*/
public int $version;
/**
* Date of registration
*
* @var string
*/
public string $registrationDate;
public string $registrationDate = "";
/**
* Ending date of registration
*
* @var string|null
*/
public ?string $endDate;
public ?string $endDate = null;
/**
* Name of place of registered office
*
* @var string
*/
public string $name;
public string $name = "";
/**
* Two letter language code
*
* @var string|null
*/
public ?string $language;
public ?string $language = null;
}