kkuzar / prhfibis
此包已被废弃且不再维护。未建议替代包。
Prh.fi BIS v1 api 的包装组件
dev-master
2020-02-18 06:35 UTC
This package is auto-updated.
Last update: 2020-08-18 07:46:16 UTC
README
Prh.fi BIS v1 api 的包装组件 原始文档 API 文档请参考 => avoindata.prh.fi
目录
安装
使用 Composer 安装
$> composer require kkuzar/prhfibis
初始化
构建新类
$bis = new kuzar\BisV1Api();
默认选项
protected $defaultOption = [ "hostname" => "avoindata.prh.fi", "port" => 443, "path" => "/bis/v1", "method" => "GET", "protocol" => "https" ]; // this class can take any config in this format
获取选项模板
kuzar\BisV1Api()::getOptionTemplate(); public static function getOptionTemplate() { return [ "hostname" => "", "port" => 0, "path" => "", "method" => "", "protocol" => "" ]; }
API 函数
Bis v1 API 的完整包装器。
按企业 ID 检索 queryCompanyDetailWithBusinessId(intput: string)
使用芬兰企业 ID 检索公司详细信息
$bis = new kuzar\BisV1Api(); $bis->queryCompanyDetailWithBusinessId($id);
此函数将返回一个与 BIS 网站显示相同的详细 JSON。
使用查询参数检索 queryCompanyDetailWithParam(Array inputObj)
$bis = new kuzar\BisV1Api(); $bis->queryCompanyDetailWithParam([ "name" => "KES", // etc ]);
此函数将返回与 BIS 网站显示相同的详细 JSON。如果查询足够详细,此函数将返回完整详细信息,否则将返回潜在公司列表,更多详细信息请参考上述链接中的 BIS 文档。
例如:
{
"type": "fi.prh.opendata.bis",
"version": "1",
"totalResults": -1,
"resultsFrom": 0,
"previousResultsUri": null,
"nextResultsUri": "http://avoindata.prh.fi/opendata/bis/v1?totalResults=false&maxResults=10&resultsFrom=10&name=KES&companyRegistrationFrom=2014-02-28",
"exceptionNoticeUri": null,
"results": [
{
"businessId": "3114031-3",
"name": "Kestimestarit Oy",
"registrationDate": "2020-01-24",
"companyForm": "OY",
"detailsUri": "http://avoindata.prh.fi/opendata/bis/v1/3114031-3"
},
{
"businessId": "3109375-6",
"name": "Kesar Oy",
"registrationDate": "2020-01-07",
"companyForm": "OY",
"detailsUri": "http://avoindata.prh.fi/opendata/bis/v1/3109375-6"
},
...
]
}
自定义 JSON 返回
// Custom return body format return [ "name" => null, "businessId" => null, "companyForm" => null, "website" => null, "latestAddr" => null, "latestPost" => null, "latestCity" => null, "latestBusinessCode" => null, "latestBusinessLine" => null, "latestAuxiliaryNames" => null, ];
使用企业 ID 检索公司简短结构化信息 getCompanyStructedDataWithBusinessId(inputObj: object)
$bis = new kuzar\BisV1Api(); $bis->getCompanyStructedDataWithBusinessId("2299022-8");
使用参数检索公司简短结构化信息 getCompanyStructedDataWithParam(inputObj: object)
$bis = new kuzar\BisV1Api(); $bis->getCompanyStructedDataWithParam([ "name" => "KES", // etc ]);
结构化信息的示例返回
[
{
name: 'Suomen Ajoneuvotekniikka Oy',
businessId: '3099016-4',
companyForm: 'OY',
website: '0400643313',
latestAddr: 'Marjahaankierto 2-4',
latestPost: 'IISALMI',
latestCity: null,
latestBusinessCode: '45112',
latestBusinessLine: 'Retail sale of cars and light motor vehicles',
latestAuxiliaryNames: 'Keski-Suomen Rengas'
},
{
name: 'Kestävä Kollektiivi Oy',
businessId: '3093045-2',
companyForm: 'OY',
website: 'www.kestava.net',
latestAddr: 'Husares 1853, depto 302 1428 CABA ARGENTINA',
latestPost: null,
latestCity: null,
latestBusinessCode: '71121',
latestBusinessLine: 'Town and city planning',
latestAuxiliaryNames: ''
},
...
]
辅助函数
getQueryBodyTemplate getQueryTemplate()
示例代码片段
kuzar\BisV1Api()::getQueryTemplate();
此辅助函数将返回一个具有以下结构的查询对象类型
public static function getQueryTemplate() { return [ "totalResults" => "false", "maxResults" => "10", "resultsFrom" => "0", "name" => "", "businessId" => "", "registeredOffice" => "", "streetAddressPostCode" => "", "companyForm" => "", "businessLine" => "", "businessLineCode" => "", "companyRegistrationFrom" => "", "companyRegistrationTo" => "" ]; }
目前它将仅验证 companyForm、companyRegistrationFrom、companyRegistrationTo 和 businessId。