PHP code example of integration-helper / integration-version-magento-client

1. Go to this page and download the library: Download integration-helper/integration-version-magento-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

integration-helper / integration-version-magento-client example snippets


use IntegrationHelper\IntegrationVersion\Repository\IntegrationVersionRepositoryInterface;

public function __construct(
        protected IntegrationVersionRepositoryInterface $integrationVersionRepository,
        protected IntegrationVersionManager $integrationVersionManager
    ){}

 public function importsRun() {
 foreach ($this->integrationVersionRepository->getItems() as $item) {
            $source = $item->getSource();
            $latestOutputData = $this->integrationVersionManager->getLatestHashData($source);
            if($latestOutputData->isError()) {
                $this->integrationVersionManager->saveLatestHash($source, $latestOutputData);
                continue;
            }

            $identities = [];
            foreach (
                $this->integrationVersionManager
                    ->getIdentities(
                        $source,
                        $item->getHash(),
                        $item->getUpdatedAtValue())
                as $items) {
                $identities[] = //.... get identities 
            }
            
            //Get Yours Api request from Mapped $source-$request
            
            if($identities) {
                $request->importByIdentities($identities);
                //Request by Api and get Items by ids
            }
        }
 }
  

 
Vendor\ApiAppIntegrationVersion\Service\RunImports:



declare(strict_types=1);

namespace Vendor\ApiAppIntegrationVersion\Service;

use IntegrationHelper\IntegrationVersion\Repository\IntegrationVersionRepositoryInterface;
use IntegrationHelper\IntegrationVersionMagentoClient\Service\IntegrationVersionManager;
use IntegrationHelper\IntegrationVersion\Model\IntegrationVersionInterface;

class RunImports
{

    public function __construct(
        protected IntegrationVersionRepositoryInterface $integrationVersionRepository,
        protected IntegrationVersionManager $integrationVersionManager
    ){}

    /**
     * @param array $args
     * @return void
     */
    public function execute()
    {
        /**
         * @var $item IntegrationVersionInterface
         */
        foreach ($this->integrationVersionRepository->getItems() as $item) {
            $source = $item->getSource();
            $latestOutputData = $this->integrationVersionManager->getLatestHashData($source);
            if($latestOutputData->isError()) {
                $this->integrationVersionManager->saveLatestHash($source, $latestOutputData);
                continue;
            }

            $identities = [];
            foreach (
                $this->integrationVersionManager
                    ->getIdentities(
                        $source,
                        $item->getHash(),
                        $item->getUpdatedAtValue())
                as $items) {
               // $identities[] = //.... get identities 
            }
            
            if($identities) {
                //Request by Api and get Items by ids
            }
        }

    }
}