InvoiceRequestMapper.php 1.18 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
/**
 * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
 * @author     Mediotype                     https://www.mediotype.com/
 */

namespace Vertex\Mapper\Api70;

use Vertex\Mapper\InvoiceRequestMapperInterface;
use Vertex\Mapper\Api60\InvoiceRequestMapper as InvoiceRequestMapper60;
use Vertex\Services\Invoice\RequestInterface;

/**
 * API Level 70 implementation of {@see InvoiceRequestMapperInterface}
 */
class InvoiceRequestMapper implements InvoiceRequestMapperInterface
{
    /** @var InvoiceRequestMapper60 $parentMapper */
    private $parentMapper;

    /**
     * @param InvoiceRequestMapper60|null $parentMapper
     */
    public function __construct(InvoiceRequestMapper60 $parentMapper = null)
    {
        $this->parentMapper = $parentMapper ?: new InvoiceRequestMapper60(
            null,
            new CustomerMapper(),
            new LineItemMapper()
        );
    }

    /**
     * @inheritDoc
     */
    public function build(\stdClass $map)
    {
        return $this->parentMapper->build($map);
    }

    /**
     * @inheritDoc
     */
    public function map(RequestInterface $object)
    {
        return $this->parentMapper->map($object);
    }
}