riesenia / pohoda

XML generator a parser pre Pohodu
34 stars 30 forks source link

automaticLiquidation support #49

Open Vitexus opened 1 week ago

Vitexus commented 1 week ago

Is there way how to create request looks like https://www.stormware.cz/xml/samples/version_2/import/Banka/Bank_03_v2.0.xml using this library ?

Maybe i need something like src/Pohoda/Type/AutomaticLiquidationType.php ?

<?php
/**
 * This file is part of riesenia/pohoda package.
 *
 * Licensed under the MIT License
 * (c) RIESENIA.com
 */

declare(strict_types=1);

namespace Riesenia\Pohoda\Type;

use Riesenia\Pohoda\Agenda;
use Riesenia\Pohoda\Common\OptionsResolver;
use Riesenia\Pohoda\Common\SetNamespaceTrait;

class AutomaticLiquidationType extends Agenda
{
    use SetNamespaceTrait;

    /**
     * {@inheritdoc}
     */
    public function getXML(): \SimpleXMLElement
    {
        if ($this->_namespace === null) {
            throw new \LogicException('Namespace not set.');
        }

        $xml = $this->_createXML()->addChild($this->_namespace . ':automaticLiquidationType', '', $this->_namespace($this->_namespace));

        $this->_addElements($xml, $this->_data, $this->_namespace);

        return $xml;
    }

    /**
     * {@inheritdoc}
     */

     protected function _configureOptions(OptionsResolver $resolver)
     {
         // available options
         $resolver->setDefined(['type', 'filter', 'agenda']);
     }
}
segy commented 1 week ago

Yes - you'd need to create AutomaticLiquidation class. If you're going to implement, please do not add it under the Type namespace - add a new namespace Liquidation / AutomaticLiquidation.

Vitexus commented 1 week ago

@segy thank you for your advice. Please do not close this issue, I will work on it.