HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/vertex/sdk/src/Mapper/Api60/SellerMapper.php
<?php

/**
 * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
 * @author     Mediotype Development         <diveinto@mediotype.com>
 */

namespace Vertex\Mapper\Api60;

use Vertex\Data\Seller;
use Vertex\Data\SellerInterface;
use Vertex\Mapper\AddressMapperInterface;
use Vertex\Mapper\MapperUtilities;
use Vertex\Mapper\SellerMapperInterface;

/**
 * API Level 60 implementation of {@see SellerMapperInterface}
 */
class SellerMapper implements SellerMapperInterface
{
    /**
     * Maximum length for a Company Code
     */
    const COMPANY_CODE_MAX = 40;

    /**
     * Minimum length for a Company Code
     */
    const COMPANY_CODE_MIN = 1;

    /** @var AddressMapperInterface */
    private $addressMapper;

    /** @var MapperUtilities */
    private $utilities;

    /**
     * @param MapperUtilities|null $utilities
     * @param AddressMapperInterface|null $addressMapper
     */
    public function __construct(MapperUtilities $utilities = null, AddressMapperInterface $addressMapper = null)
    {
        $this->utilities = $utilities ?: new MapperUtilities();
        $this->addressMapper = $addressMapper ?: new AddressMapper();
    }

    /**
     * @inheritDoc
     */
    public function getCompanyCodeMaxLength()
    {
        return static::COMPANY_CODE_MAX;
    }

    /**
     * @inheritDoc
     */
    public function getCompanyCodeMinLength()
    {
        return static::COMPANY_CODE_MIN;
    }

    /**
     * @inheritDoc
     */
    public function validateCompanyCode($fieldValue)
    {
        // TODO: Implement validateCompanyCode() method.
    }

    /**
     * @inheritdoc
     */
    public function build(\stdClass $map)
    {
        $object = new Seller();

        if (isset($map->Company)) {
            $object->setCompanyCode($map->Company instanceof \stdClass ? $map->Company->_ : $map->Company);
        }

        if (isset($map->PhysicalOrigin)) {
            $object->setPhysicalOrigin($this->addressMapper->build($map->PhysicalOrigin));
        }

        if (isset($map->AdministrativeOrigin)) {
            $object->setAdministrativeOrigin($this->addressMapper->build($map->AdministrativeOrigin));
        }

        return $object;
    }

    /**
     * @inheritdoc
     */
    public function map(SellerInterface $object)
    {
        $map = new \stdClass();

        $map = $this->utilities->addToMapWithLengthValidation(
            $map,
            $object->getCompanyCode(),
            'Company',
            $this->getCompanyCodeMinLength(),
            $this->getCompanyCodeMaxLength(),
            true
        );

        if ($object->getPhysicalOrigin() !== null) {
            $map->PhysicalOrigin = $this->addressMapper->map($object->getPhysicalOrigin());
        }

        if ($object->getAdministrativeOrigin() !== null) {
            $map->AdministrativeOrigin = $this->addressMapper->map($object->getAdministrativeOrigin());
        }

        return $map;
    }
}