ibrows / post_barcode_bundle

通过瑞士邮政 SOAP API创建条形码的组件

dev-master 2017-04-28 06:02 UTC

This package is not auto-updated.

Last update: 2024-09-16 02:01:38 UTC


README

IbrowsPostBarcodeBundle 允许您通过瑞士邮政 API 创建信件和包裹条形码。更多详细信息请参阅:http://www.post.ch/post-barcode-cug

安装和设置组件

  1. 获取源代码

    $ php composer.phar require ibrows/post_barcode_bundle

    Composer 将将组件安装到您项目的 ibrows/post_barcode_bundle 目录。

  2. 将组件添加到您的 AppKernel

    // app/AppKernerl.php
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Ibrows\PostBarcodeBundle\IbrowsPostBarcodeBundle(),
            // ...
        );
        // ...
    }

配置

设置凭据、路径和实体

    ibrows_post_barcode:
        soap:
            wsdl: '%kernel.root_dir%/../vendor/ibrows/post_barcode_bundle/Soap/wsdl'
            dir: '%kernel.root_dir%/../vendor/ibrows/post_barcode_bundle/Soap/Classes'
            namespace: 'Ibrows\PostBarcodeBundle\Soap\classes'
            endpoint: "https://wsbc.post.ch/wsbc/barcode/v2_2"
            username: <postApiUser>
            password: <postApiPassword>
            frankingLicence: <frankingLicenceNumber>
    
        barcode:
            folder: '%kernel.root_dir%/../web/barcodes'

使用示例

    $recipient = new Address();
    $recipient->setCountry('CH');
    $recipient->setCity('Zürich');
    $recipient->setCompany('iBROWS AG');
    $recipient->setFirstName('Manuel');
    $recipient->setLastName('Knobel');
    $recipient->setPrimaryStreet('Seestrasse 356');
    $recipient->setZipCode('8038');
    $recipient->setTitle(Address::MISTER);

    $customer = clone $recipient;

    $service = $this->getContainer()->get('ibrows_post_barcode.soap.client.service.barcode');
    $service->generateLabel($recipient, $customer);