PHP code example of liveecommerce / sigep

1. Go to this page and download the library: Download liveecommerce/sigep 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/ */

    

liveecommerce / sigep example snippets


use Live\Sigep\PostCard\Application\Service\GetPostCardStatusService;
use Live\Sigep\PostCard\Application\Service\GetPostCardStatusRequest;
use Live\Sigep\PostCard\Application\Service\GetPostCardStatusResponse;
use Live\Sigep\PostCard\Domain\Model\PostCardStatus;

$user = '';
$password = '';
$postCard = '';

$postCardStatusRequest = new GetPostCardStatusRequest($usuario, $password, $postCard);

// Setter para utilizar caso esteja em homologação
$postCardStatusRequest->setSandbox(true);

$postCardStatusService = new GetPostCardStatusService();
$postCardStatusResponse = $postCardStatusService($postCardStatusRequest);

$postCardStatus = $postCardStatusResponse->getObject();

$status = $postCardStatus->getStatus();

use Live\Sigep\PostCard\Application\Service\GetPostCardAvaliableServicesService;
use Live\Sigep\PostCard\Application\Service\GetPostCardAvaliableServicesRequest;
use Live\Sigep\PostCard\Application\Service\GetPostCardAvaliableServicesResponse;
use Live\Sigep\PostCard\Domain\Model\PostCardAvaliableServices

$user = '';
$password = '';
$postCard = '';
$contract = '';

$postCardAvaliableServicesRequest = new GetPostCardAvaliableServicesRequest(
    $user,
    $password,
    $postcard,
    $contract
);

// Setter para utilizar caso esteja em homologação
$postCardAvaliableServicesRequest->setSandbox(true);

$postCardAvaliableServicesService = new GetPostCardAvaliableServicesService();
$postCardAvaliableServicesResponse = $postCardStatusService($postCardAvaliableServicesRequest);

$postCardAvaliableServices = $postCardAvaliableServicesResponse->getObject();

$postCardNumber = $postCardAvaliableServices->getPostCardNumber();
$administrativeCode = $postCardAvaliableServices->getAdministrativeCode();
$cnpj =  $postCardAvaliableServices->getCnpj();
$services =  $postCardAvaliableServices->getServices();

foreach ($services as $service) {
    $id = $service->getId();
    $serviceCode = $service->getServiceCode();
    $description = $service->getDescription();
    $packagesQuantity = $service->getPackagesQuantity();
}

use Live\Sigep\ShippingLabel\Application\Service\GetShippingLabelsRequest;
use Live\Sigep\ShippingLabel\Application\Service\GetShippingLabelsService;
use Live\Sigep\ShippingLabel\Application\Service\GetShippingLabelsResponse;
use Live\Sigep\ShippingLabel\Domain\Model\ShippingLabel

$user = '';
$password = '';
$serviceId = '';
$receiverType = 'C';
$cnpj = '';
$quantityLabels = 1;

$getShippingLabelsRequest = new GetShippingLabelsRequest(
    $user,
    $password,
    $serviceId,
    $receiverType,
    $cnpj,
    $quantityLabels
);

// Setter para utilizar caso esteja em homologação
$getShippingLabelsRequest->setSandbox(true);

$getShippingLabelsService = new GetShippingLabelsService();
$getShippingLabelsResponse = $getShippingLabelsService($getShippingLabelsRequest);

$shippingLabels = $getShippingLabelsResponse->getData();

foreach ($shippingLabels as $shippingLabel) {
    $label = $shippingLabel->getLabel();
}

use Live\Sigep\Address\Application\Service\GetAddressByZipCodeRequest;
use Live\Sigep\Address\Application\Service\GetAddressByZipCodeService;
use Live\Sigep\Address\Application\Service\GetAddressByZipCodeResponse;
use Live\Sigep\Address\Domain\Model\Address

$cep = '';

$getAddressByZipCodeRequest = new GetAddressByZipCodeRequest('07124610');

// Setter para utilizar caso esteja em homologação
$getAddressByZipCodeRequest->setSandbox(true);

$getAddressByZipCodeService = new GetAddressByZipCodeService();
$getAddressByZipCodeResponse = $getAddressByZipCodeService($getAddressByZipCodeRequest);

$address = $getAddressByZipCodeResponse->getObject();

$zipCode = $address->getZipCode();
$street = $address->getStreet();
$district = $address->getDistrict();
$state = $address->getState();
$complement = $address->getComplement();
$additionalComplement = $address->getAdditionalComplement();
$number = $address->getNumber();
$zipCodeComplement = $address->getZipCodeComplement();

use Live\Sigep\DeliveryAvailability\Application\Service\GetDeliveryAvailabilityRequest;
use Live\Sigep\DeliveryAvailability\Application\Service\GetDeliveryAvailabilityService;
use Live\Sigep\DeliveryAvailability\Application\Service\GetDeliveryAvailabilityResponse;
use Live\Sigep\DeliveryAvailability\Domain\Model\DeliveryAvailability;

$cep = '';

$getDeliveryAvailabilityRequest = new GetDeliveryAvailabilityRequest(
    $user,
    $password,
    $administrativeCode,
    $service,
    $senderZipCode,
    $receiverZipCode
);

// Setter para utilizar caso esteja em homologação
$getDeliveryAvailabilityRequest->setSandbox(true);

$getDeliveryAvailabilityService = new GetDeliveryAvailabilityService();
$getDeliveryAvailabilityResponse = $getDeliveryAvailabilityService($getDeliveryAvailabilityRequest);

$deliveryAvailability = $getDeliveryAvailabilityResponse->getObject();

$id = $deliveryAvailability->getId();
$message = $deliveryAvailability->getMessage();

use Live\Sigep\Address\Domain\Model\Address;

$zipCode = '';
$street = '';
$district = '';
$city = '';
$state = '';
$number = '';
$complement = '';
$additionalComplement = '';
$zipCodeComplement = '';

$address = new Address(
    $zipCode,
    $street,
    $district,
    $city,
    $state
);

$address->setNumber($number);
$address->setComplement($complement);
$address->setAdditionalComplement($additionalComplement);
$address->setZipCodeComplement($zipCodeComplement);

use Live\Sigep\Address\Domain\Model\Address;
use Live\Sigep\ShippingLabel\Domain\Model\ShippingLabel;
use Live\Sigep\PrePostingList\Domain\Model\PrePostingList;
use Live\Sigep\PrePostingList\Domain\Model\AdditionalServiceType;

$address = '';
$shippingLabel = '';
$serviceCode = '';
$weight = '';
$receiverName = '';
$objectType = '';
$height = '';
$width = '';
$length = '';
$diameter = '';
$invoiceNumber = '';
$additionalService = AdditionalServiceType::NATIONALREGISTRATION;
$declaredValue = '';
$neighborAddress = '';

$address = new PrePostingList(
    $address,
    $shippingLabel,
    $serviceCode,
    $weight,
    $receiverName,
    $objectType,
    $height,
    $width,
    $length,
    $diameter,
    $invoiceNumber,
    $additionalService,
    $declaredValue,
    $neighborAddress
);

use Live\Sigep\PrePostingList\Application\Service\ClosePrePostingListRequest;
use Live\Sigep\PrePostingList\Application\Service\ClosePrePostingListService;
use Live\Sigep\PrePostingList\Application\Service\ClosePrePostingListResponse;
use Live\Sigep\Address\Domain\Model\Address;
use Live\Sigep\ShippingLabel\Domain\Model\ShippingLabel;
use Live\Sigep\PrePostingList\Domain\Model\PostalObject;
use Live\Sigep\PrePostingList\Domain\Model\PostalObjectType;
use Live\Sigep\PrePostingList\Domain\Model\AdditionalServiceType;
use Live\Sigep\PrePostingList\Domain\Model\RegionalCodeBoardType;
use Live\Sigep\PrePostingList\Domain\Model\PrePostingList;

$user = '';
$password = '';
$senderAddress = '';
$postalObjects = [];
$prePostingListClientId = '';
$postCardId = '';
$contract = '';
$administrativeCode = '';
$shippingLabels = [];
$senderName = '';
$regionalCodeBoard = RegionalCodeBoardType::SAOPAULO;

$closePrePostingListRequest = new ClosePrePostingListRequest(
    $user,
    $password,
    $senderAddress,
    $postalObjects,
    $prePostingListClientId,
    $postCardId,
    $contract,
    $administrativeCode,
    $shippingLabels,
    $senderName,
    $regionalCodeBoard
);

// Setter para utilizar caso esteja em homologação
$closePrePostingListRequest->setSandbox(true);

$closePrePostingListService = new ClosePrePostingListService();
$closePrePostingListResponse = $closePrePostingListService($closePrePostingListRequest);

$prePostingList = $closePrePostingListResponse->getObject();

$id = $prePostingList->getId();

use Live\Sigep\PrePostingList\Application\Service\GetPrePostingListXmlFromCorreiosRequest;
use Live\Sigep\PrePostingList\Application\Service\GetPrePostingListXmlFromCorreiosService;
use Live\Sigep\PrePostingList\Application\Service\GetPrePostingListXmlFromCorreiosResponse;

$user = '';
$password = '';
$plpNumber = 0;


$getPrePostingListXmlFromCorreiosRequest = new GetPrePostingListXmlFromCorreiosRequest(
    $user,
    $password,
    $plpNumber
);

// Setter para utilizar caso esteja em homologação
$getPrePostingListXmlFromCorreiosRequest->setSandbox(true);

$getPrePostingListXmlFromCorreiosService = new GetPrePostingListXmlFromCorreiosService();
$getPrePostingListXmlFromCorreiosResponse = $getPrePostingListXmlFromCorreiosService($getPrePostingListXmlFromCorreiosRequest);

$getPrePostingListXmlFromCorreios = $getPrePostingListXmlFromCorreiosResponse->getData();

$xml = $getPrePostingListXmlFromCorreios['xml'];

use Live\Sigep\DeliverySuspension\Application\Service\GetDeliverySuspensionRequest;
use Live\Sigep\DeliverySuspension\Application\Service\GetDeliverySuspensionService;
use Live\Sigep\DeliverySuspension\Application\Service\GetDeliverySuspensionResponse;
use Live\Sigep\PrePostingList\Domain\Model\PrePostingList;
use Live\Sigep\ShippingLabel\Domain\Model\ShippingLabel;

$user = '';
$password = '';
$label = '';
$plp = 0;
$shippingLabel = new ShippingLabel($label);
$prePostingList = new PrePostingList($plp);

$getDeliverySuspensionRequest = new GetDeliverySuspensionRequest(
    $user,
    $password,
    $shippingLabel,
    $prePostingList
);

// Setter para utilizar caso esteja em homologação
$getDeliverySuspensionRequest->setSandbox(true);

$getDeliverySuspensionService = new GetDeliverySuspensionService();
$getDeliverySuspensionResponse = $getDeliverySuspensionService($getDeliverySuspensionRequest);

$getDeliverySuspension = $getDeliverySuspensionResponse->getData();

$data = $getDeliverySuspension['data'];

use Live\Sigep\AddressingLabel\Application\Service\GetAddressingLabelRequest;
use Live\Sigep\AddressingLabel\Application\Service\GetAddressingLabelService;
use Live\Sigep\AddressingLabel\Application\Service\GetAddressingLabelResponse;
use Live\Sigep\Address\Domain\Model\Address;
use Live\Sigep\ShippingLabel\Domain\Model\ShippingLabel;

$format = "1";
$receiverAddress = '';
$senderAddress = '';
$shippingLabel = '';
$weight = '';
$invoice = '';
$shippingType = '';
$orderId = '';
$receiverName = '';
$senderName = '';
$contract = '';
$postCard = '';
$serviceCode = '';
$declaredValue = '';
$logoUrl = '';
$groupingInformation = '00';
$additionalServices = [];
$variableDataIdentifier = '51';

$request = [];
$request[] = new GetAddressingLabelRequest(
    $format,
    $receiverAddress,
    $senderAddress,
    $shippingLabel,
    $weight,
    $invoice,
    $shippingType,
    $orderId,
    $receiverName,
    $senderName,
    $contract,
    $postCard,
    $serviceCode,
    $declaredValue,
    $logoUrl,
    $groupingInformation,
    $additionalServices,
    $variableDataIdentifier
);

$getAddressingLabelService = new GetAddressingLabelService();
$getAddressingLabelResponse = $getAddressingLabelService($request);

use Live\Sigep\PostList\Application\Service\GetPostageVoucherRequest;
use Live\Sigep\PostList\Application\Service\GetPostageVoucherService;
use Live\Sigep\PostList\Application\Service\GetPostageVoucherResponse;
use Live\Sigep\PrePostingList\Domain\Model\PrePostingList;

$prePostingList = '';
$contract = '';
$postCardServices = '';
$postDate = '';
$telephone = '';
$senderName = '';
$clientName = 'ECT';
$email = '';

$getPostageVoucherRequest = new GetPostageVoucherRequest(
    $prePostingList,
    $contract,
    $postCardServices,
    $postDate,
    $telephone,
    $senderName,
    $clientName,
    $email
);

$getPostageVoucherService = new GetPostageVoucherService();
$getPostageVoucherResponse = $getPostageVoucherService($getPostageVoucherRequest);

use Live\Sigep\PostList\Application\Service\GetPostListRequest;
use Live\Sigep\PostList\Application\Service\GetPostListService;
use Live\Sigep\PostList\Application\Service\GetPostListResponse;
use Live\Sigep\PostList\Domain\Model\PrePostingList;
use Live\Sigep\Address\Domain\Model\Address;
use Live\Sigep\PrePostingList\Domain\Model\PostalObject;

$prePostingList = '';
$senderAddress = '';
$senderName = '';
$contract = '';
$adminitrativeCode = '';
$postCardId = '';
$postCardServices = '';
$postalObjects = '';
$postDate = '';
$telephone = '';
$clientName = 'ECT';

$getPostListRequest = new GetPostListRequest(
    $prePostingList,
    $senderAddress,
    $senderName,
    $contract,
    $adminitrativeCode,
    $postCardId,
    $postCardServices,
    $postalObjects,
    $postDate,
    $telephone,
    $clientName
);

$getPostListService = new GetPostListService();
$getPostListResponse = $getPostListService($getPostListRequest);

use Live\Sigep\PostList\Application\Service\GetProofOfDeliveryRequest;
use Live\Sigep\PostList\Application\Service\GetProofOfDeliveryService;
use Live\Sigep\PostList\Application\Service\GetProofOfDeliveryResponse;
use Live\Sigep\PrePostingList\Domain\Model\PostalObject;
use Live\Sigep\Address\Domain\Model\Address;

$senderAddress = '';
$contract = '';
$senderName = '';
$postalObject = '';

$getProofOfDeliveryRequest = new GetProofOfDeliveryRequest(
    $senderAddress,
    $contract,
    $senderName,
    $postalObject
);

$getProofOfDeliveryService = new GetProofOfDeliveryService();
$getProofOfDeliveryResponse = $getProofOfDeliveryService($getProofOfDeliveryRequest);