Coder Social home page Coder Social logo

teryt-api's Introduction

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads License

Scrutinizer Code Quality Build Status Code Coverage

Code Climate Issue Count

Dependency Status

TERYT WS1 API - Polish address database

Installation

Install the latest version with composer

composer require mrcnpdlk/teryt-api

Basic usage

Cache

Library supports Cache bundles based on PSR-16 standard.

For below example was used phpfastcache/phpfastcache. phpfastcache/phpfastcache supports a lot of endpoints, i.e. Files, Sqlite, Redis and many other. More information about using cache and configuration it you can find in this Wiki.

    /**
     * Cache in system files
     */
    $oInstanceCacheFiles = new \phpFastCache\Helper\Psr16Adapter('files');

Log

Library also supports logging packages based on PSR-3 standard, i.e. very popular monolog/monolog.

$oInstanceLogger = new \Monolog\Logger('name_of_my_logger');
$oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        \Psr\Log\LogLevel::DEBUG
    )
);

Teryt Authentication

Service TERYT WS1 shares API based on SOAP Protocol. More information about service you can find on this site There are two ways to connect to the server:

  • production database - you need login/password
  • testing database - default authentication with default login/password pair

First of all we need configure connection calling setTerytConfig() method and optionally set cache and log instances

use mrcnpdlk\Teryt\Client;
use mrcnpdlk\Teryt\NativeApi;
use mrcnpdlk\Teryt\Config;

$oConfig = new Config([
    'logger'       => $oInstanceLogger,
    'cache'        => $oInstanceCacheFiles,
    'username'     => 'my_login',
    'password'     => 'my_password',
    'isProduction' => true,
]);
$oNativeApi = NativeApi::create($oConfig);

After that we able to call auxiliary static methods defined in NativeApi class, i.e:

var_dump($oNativeApi->CzyZalogowany());
var_dump($oNativeApi->PobierzSlownikCechULIC());
var_dump($oNativeApi->WyszukajMiejscowosc('skiernie',null));

Defined methods (\mrcnpdlk\Teryt\NativeApi)

Almost all methods from official documentation have been mapped and defined.

Full list below \mrcnpdlk\Teryt\NativeApi:

General

Method Status Description
CzyZalogowany() ๐Ÿ‘Œ
PobierzDateAktualnegoKatTerc() ๐Ÿ‘Œ
PobierzDateAktualnegoKatNTS() ๐Ÿ‘Œ
PobierzDateAktualnegoKatSimc() ๐Ÿ‘Œ
PobierzDateAktualnegoKatUlic() ๐Ÿ‘Œ

Catalog TERC

Method Status Description
PobierzListeWojewodztw() ๐Ÿ‘Œ
PobierzListePowiatow() ๐Ÿ‘Œ
PobierzListeGmin() ๐Ÿ‘Œ
PobierzGminyiPowDlaWoj() ๐Ÿ‘Œ

Catalog NTS

Method Status Description
PobierzListeRegionow() ๐Ÿ‘Œ
PobierzListeWojewodztwWRegionie() ๐Ÿ‘Œ
PobierzListePodregionow() ๐Ÿ‘Œ
PobierzListePowiatowWPodregionie() ๐Ÿ‘Œ
PobierzListeGminPowiecie() ๐Ÿ‘Œ

Catalog ULIC

Method Status Description
PobierzListeUlicDlaMiejscowosci() ๐Ÿ‘Œ

Catalog SIMC

Method Status Description
PobierzListeMiejscowosciWGminie() ๐Ÿ‘Œ
PobierzListeMiejscowosciWRodzajuGminy() ๐Ÿ‘Œ

Dictionary

Method Status Description
PobierzSlownikRodzajowJednostek() ๐Ÿ‘Œ
PobierzSlownikRodzajowSIMC() ๐Ÿ‘Œ
PobierzSlownikCechULIC() ๐Ÿ‘Œ

Catalog

Method Status Description
PobierzKatalogTERCAdr() ๐Ÿ‘Œ
PobierzKatalogTERC() ๐Ÿ‘Œ
PobierzKatalogNTS() ๐Ÿ‘Œ
PobierzKatalogSIMCAdr() ๐Ÿ‘Œ
PobierzKatalogSIMC() ๐Ÿ‘Œ
PobierzKatalogSIMCStat() ๐Ÿ‘Œ
PobierzKatalogULIC() ๐Ÿ‘Œ
PobierzKatalogULICAdr() ๐Ÿ‘Œ
PobierzKatalogULICBezDzielnic() ๐Ÿ‘Œ
PobierzKatalogWMRODZ() ๐Ÿ‘Œ

Changes

Method Status Description
PobierzZmianyTercUrzedowy() ๐Ÿ‘Œ
PobierzZmianyTercAdresowy() ๐Ÿ‘Œ
PobierzZmianyNTS() ๐Ÿ‘Œ
PobierzZmianySimcUrzedowy() ๐Ÿ‘Œ
PobierzZmianySimcAdresowy() ๐Ÿ‘Œ
PobierzZmianySimcStatystyczny() ๐Ÿ‘Œ
PobierzZmianyUlicUrzedowy() ๐Ÿ‘Œ
PobierzZmianyUlicAdresowy() ๐Ÿ‘Œ

Verification

Method Status Description
WeryfikujAdresDlaMiejscowosci() ๐Ÿ‘Œ
WeryfikujAdresDlaMiejscowosciAdresowy() ๐Ÿ‘Œ
WeryfikujAdresWmiejscowosci() ๐Ÿ‘Œ
WeryfikujAdresWmiejscowosciAdresowy() ๐Ÿ‘Œ
WeryfikujAdresDlaUlic() ๐Ÿ‘Œ
WeryfikujAdresDlaUlicAdresowy() ๐Ÿ‘Œ
WeryfikujNazwaAdresUlic() โš ๏ธ empty response
WeryfikujNazwaAdresUlicAdresowy() ๐Ÿ‘Œ

Search

Method Status Description
WyszukajJPT() โš ๏ธ empty response
WyszukajMiejscowosc() ๐Ÿ‘Œ
WyszukajMiejscowoscWJPT() ๐Ÿ‘Œ
WyszukajUlice() ๐Ÿ‘Œ
WyszukajJednostkeWRejestrze() ๐Ÿ‘Œ
WyszukajMiejscowoscWRejestrze() ๐Ÿ‘Œ
WyszukajUliceWRejestrze() ๐Ÿ‘Œ

Defined methods (\mrcnpdlk\Teryt\Api)

Method Status Description
getCity() ๐Ÿ‘Œ
$oApi = new \mrcnpdlk\Teryt\Api($oClient);
print_r($oApi->getCity('0700884'));
mrcnpdlk\Teryt\Model\City Object
(
    [id] => 0700884
    [parentId] => 0700884
    [rmId] => 01
    [rmName] => wieล›
    [name] => Burzenin
    [commune] => mrcnpdlk\Teryt\Model\Commune Object
        (
            [id] => 101414
            [tercId] => 1014052
            [name] => Burzenin
            [typeId] => 2
            [typeName] => gmina wiejska
            [district] => mrcnpdlk\Teryt\Model\District Object
                (
                    [id] => 1014
                    [name] => sieradzki
                    [typeName] => powiat
                    [province] => mrcnpdlk\Teryt\Model\Province Object
                        (
                            [id] => 10
                            [name] => ลร“DZKIE
                        )
                )
        )
)

teryt-api's People

Contributors

mrcnpdlk avatar pedrosik avatar

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.