GithubHelp home page GithubHelp logo

stuba / finnish-company-info Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rikukukkaniemi/finnish-company-info

0.0 0.0 0.0 108 KB

Get Finnish company information using business ID (y-tunnus)

PHP 99.51% Makefile 0.49%

finnish-company-info's Introduction

Finnish Company Info

With this PHP library you can easily fetch data on a company given its business ID (y-tunnus):

  • Name of the company
  • Website
  • Current address (street, city, postal code)
  • Current main line of business (code and textual description)

Library uses https://avoindata.prh.fi/ytj_en.html as the data source.

Installation

You can require library with:

composer require rikukukkaniemi/finnish-company-info

See requirements from Packagist.

How to use

Here is an example on how to use the library:

public function example(CompanyInfoService $companyInfoService): void
{
    try {
        $companyInfo = $companyInfoService->getCompanyInformation('1234567-8');
    } catch (CompanyInfoException) {
        // Handle exception
        return;
    }

    $companyInfo->getName();                                // String
    $companyInfo->getWebsite();                             // String or null

    $currentAddress = $companyInfo->getCurrentAddress();    // Address object
    $currentAddress->getStreet();                           // String
    $currentAddress->getCity();                             // String
    $currentAddress->getPostalCode();                       // String

    $businessLines = $companyInfo->getBusinessLines();      // Array of BusinessLine objects (can be empty)
    $businessLines[0]->getCode();                           // String
    $businessLines[0]->getDescription();                    // String
    $businessLines[0]->getLanguage();                       // String (language of description)
}

Note that CompanyInfoException is the parent exception. You can also catch a more specific cases of exceptions:

  • InvalidBusinessIdException when business ID seems to be invalid.
  • CompanyNotFoundException when company is not found for given business ID.
  • UnexpectedClientDataException when the data source returns unexpected data. Should not occur unless data source is broken.

The example code can also be found here.

finnish-company-info's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.