mirror of
https://github.com/ivuorinen/business-data-fetcher.git
synced 2026-03-18 08:01:02 +00:00
feat: parser now writes, added missing fields
updated docs, example, extensive use of Traits with better handling. valid level 9 phpstan codebase.
This commit is contained in:
@@ -2,25 +2,22 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Business Address
|
||||
* Address
|
||||
*/
|
||||
class BisAddress extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical addresses
|
||||
*/
|
||||
public int $version;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -47,11 +44,6 @@ class BisAddress extends DataTransferObject
|
||||
*/
|
||||
public ?string $city = null;
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
|
||||
/**
|
||||
* Type of address, 1 for street address, 2 for postal address
|
||||
*/
|
||||
|
||||
@@ -2,61 +2,40 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Business ID Change
|
||||
* Company Business Id Change
|
||||
*/
|
||||
class BisCompanyBusinessIdChange extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasLanguage;
|
||||
use Traits\HasChange;
|
||||
|
||||
/**
|
||||
* Description of reason
|
||||
*/
|
||||
public string $description = "";
|
||||
public string $description = '';
|
||||
|
||||
/**
|
||||
* Reason code
|
||||
*/
|
||||
public string $reason = "";
|
||||
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 = "";
|
||||
public string $oldBusinessId = '';
|
||||
|
||||
/**
|
||||
* New Business ID
|
||||
*/
|
||||
public string $newBusinessId = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
public string $newBusinessId = '';
|
||||
}
|
||||
|
||||
@@ -2,30 +2,27 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Business Line
|
||||
*/
|
||||
class BisCompanyBusinessLine extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Zero for main line of business, positive for others
|
||||
*/
|
||||
public int $order;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical lines of business
|
||||
*/
|
||||
public int $version;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -35,10 +32,5 @@ class BisCompanyBusinessLine extends DataTransferObject
|
||||
/**
|
||||
* Name of line of business
|
||||
*/
|
||||
public string $name = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
public string $name = '';
|
||||
}
|
||||
|
||||
@@ -2,43 +2,35 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Contact Detail
|
||||
*/
|
||||
class BisCompanyContactDetail extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical contact details
|
||||
*/
|
||||
public int $version;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
*/
|
||||
public ?string $endDate = null;
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
|
||||
/**
|
||||
* Value of contact detail
|
||||
*/
|
||||
public string $value = "";
|
||||
public string $value = '';
|
||||
|
||||
/**
|
||||
* Type of contact detail
|
||||
*/
|
||||
public string $type = "";
|
||||
public string $type = '';
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Spatie\DataTransferObject\Attributes\CastWith;
|
||||
use Spatie\DataTransferObject\Casters;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
/**
|
||||
* Company Details
|
||||
@@ -91,12 +91,12 @@ class BisCompanyDetails extends DataTransferObject
|
||||
/**
|
||||
* Business ID
|
||||
*/
|
||||
public string $businessId = "";
|
||||
public string $businessId = '';
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Company form
|
||||
@@ -111,5 +111,5 @@ class BisCompanyDetails extends DataTransferObject
|
||||
/**
|
||||
* Primary company name
|
||||
*/
|
||||
public string $name = "";
|
||||
public string $name = '';
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Form
|
||||
*/
|
||||
class BisCompanyForm extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical company forms
|
||||
*/
|
||||
public int $version;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -30,20 +27,10 @@ class BisCompanyForm extends DataTransferObject
|
||||
/**
|
||||
* Name of company form
|
||||
*/
|
||||
public string $name = "";
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
* Type of company form
|
||||
*/
|
||||
public ?string $language = null;
|
||||
|
||||
/**
|
||||
* Type of company form.
|
||||
*
|
||||
* Note: According to spec, this shouldn't be nullable,
|
||||
* but payloads show otherwise.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $type;
|
||||
public string $type = '';
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Language
|
||||
*/
|
||||
class BisCompanyLanguage extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical company forms
|
||||
*/
|
||||
public int $version;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -28,17 +25,7 @@ class BisCompanyLanguage extends DataTransferObject
|
||||
public ?string $endDate = null;
|
||||
|
||||
/**
|
||||
* Bankruptcy, liquidation or restructuring proceedings
|
||||
* Name of language
|
||||
*/
|
||||
public string $name = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
|
||||
/**
|
||||
* Type of liquidation
|
||||
*/
|
||||
public string $type = "";
|
||||
public string $name = '';
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Liquidation
|
||||
*/
|
||||
class BisCompanyLiquidation extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical company forms
|
||||
*/
|
||||
public int $version;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -30,15 +27,10 @@ class BisCompanyLiquidation extends DataTransferObject
|
||||
/**
|
||||
* Bankruptcy, liquidation or restructuring proceedings
|
||||
*/
|
||||
public string $name = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Type of liquidation
|
||||
*/
|
||||
public string $type = "";
|
||||
public string $type = '';
|
||||
}
|
||||
|
||||
@@ -2,33 +2,27 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Name
|
||||
*/
|
||||
class BisCompanyName extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Order
|
||||
*
|
||||
* Zero for primary company name,
|
||||
* other for translations of the primary company name
|
||||
* and auxiliary company names
|
||||
* Zero for primary company name, other for translations of the primary company name and auxiliary company names
|
||||
*/
|
||||
public int $order;
|
||||
/**
|
||||
* One for current version and >1 for historical company names
|
||||
*/
|
||||
public int $version;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -38,10 +32,5 @@ class BisCompanyName extends DataTransferObject
|
||||
/**
|
||||
* Company name
|
||||
*/
|
||||
public string $name = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
public string $name = '';
|
||||
}
|
||||
|
||||
@@ -2,18 +2,22 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Exceptions\UnexpectedValueException;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Registered Entry
|
||||
*/
|
||||
class BisCompanyRegisteredEntry extends DataTransferObject
|
||||
{
|
||||
use Traits\HasAuthority;
|
||||
use Traits\HasLanguage;
|
||||
use Traits\HasRegister;
|
||||
|
||||
/**
|
||||
* Description of entry
|
||||
*/
|
||||
public string $description = "";
|
||||
public string $description = '';
|
||||
|
||||
/**
|
||||
* Zero for common entries, one for ‘Unregistered’ and two for ‘Registered’
|
||||
@@ -23,76 +27,10 @@ class BisCompanyRegisteredEntry extends DataTransferObject
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
*/
|
||||
public ?string $endDate = null;
|
||||
|
||||
/**
|
||||
* register (int):
|
||||
* - One for Trade Register,
|
||||
* - two for Register of Foundations,
|
||||
* - three for Register of Associations,
|
||||
* - four for Tax Administration,
|
||||
* - five for Prepayment Register,
|
||||
* - six for VAT Register,
|
||||
* - seven for Employer Register and
|
||||
* - eight for register of bodies liable for tax on insurance premiums
|
||||
*
|
||||
* @see getRegisterText()
|
||||
*/
|
||||
public int $register;
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language;
|
||||
/**
|
||||
* authority (int):
|
||||
* - One for Tax Administration,
|
||||
* - two for Finnish Patent and Registration Office and
|
||||
* - three for Population Register
|
||||
*
|
||||
* @see getAuthorityText()
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public int $authority;
|
||||
|
||||
public function getStatusText(): string
|
||||
{
|
||||
// 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),
|
||||
};
|
||||
}
|
||||
|
||||
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),
|
||||
};
|
||||
}
|
||||
|
||||
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),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,30 +2,27 @@
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Dto;
|
||||
|
||||
use Ivuorinen\BusinessDataFetcher\Traits\HasSource;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
/**
|
||||
* Company Registered Office
|
||||
*/
|
||||
class BisCompanyRegisteredOffice extends DataTransferObject
|
||||
{
|
||||
use HasSource;
|
||||
use Traits\HasSource;
|
||||
use Traits\HasVersion;
|
||||
use Traits\HasLanguage;
|
||||
|
||||
/**
|
||||
* Zero for primary place of registered office, positive for others
|
||||
*/
|
||||
public int $order;
|
||||
|
||||
/**
|
||||
* One for current version and >1 for historical places of registered office
|
||||
*/
|
||||
public int $version;
|
||||
|
||||
/**
|
||||
* Date of registration
|
||||
*/
|
||||
public string $registrationDate = "";
|
||||
public string $registrationDate = '';
|
||||
|
||||
/**
|
||||
* Ending date of registration
|
||||
@@ -35,10 +32,5 @@ class BisCompanyRegisteredOffice extends DataTransferObject
|
||||
/**
|
||||
* Name of place of registered office
|
||||
*/
|
||||
public string $name = "";
|
||||
|
||||
/**
|
||||
* Two letter language code
|
||||
*/
|
||||
public ?string $language = null;
|
||||
public string $name = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user