MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //home/artinside/sites.artinside.com.br/paliar/source/Support/FreteFrenet.php
<?php


namespace Source\Support;


use Anam\Phpcart\Cart;
use Frenet\ApiFactory;

class FreteFrenet
{
    private $frete;
    private $result;


    public function __construct(string $zipCodeOrigin, string $zipCodeDestination, float $invoiceValue)
    {
       $this->frete = ApiFactory::create(FRENET_TOKEN)
           ->shipping()
           ->quote()
           ->setRecipientCountry('BR')
           ->setSellerPostcode($zipCodeOrigin)
           ->setRecipientPostcode($zipCodeDestination)
           ->setShipmentInvoiceValue($invoiceValue);
       return $this;

    }

    private function setItems(){
        $cart = new Cart(CARRINHO);
        if($cart->count() < 1){
            return false;
        }
        foreach ($cart->getItems() as $item) {
            $this->frete->addShippingItem($item->id, $item->quantity, $item->weight, $item->depth, $item->height, $item->width, "General");
        }
        return $this->frete;
    }

    public function getServices()
    {
        $this->setItems();
        $this->result = $this->frete->execute();
        return $this->result->getShippingServices();

    }




}