src/Helper/Monetico/Request/OrderContext.php line 41

  1. <?php
  2. namespace App\Helper\Monetico\Request;
  3. /**
  4.  * Represents the "contexte_commande" field content.
  5.  * See technical documentation for a full explanation of each field and the format to use
  6.  */
  7. class OrderContext implements \JsonSerializable
  8. {
  9.     /**
  10.      * @var OrderContextBilling
  11.      */
  12.     private $orderContextBilling;
  13.     /**
  14.      * @var ?OrderContextClient
  15.      */
  16.     private $orderContextClient;
  17.     /**
  18.      * @var ?OrderContextShipping
  19.      */
  20.     private $orderContextShipping;
  21.     /**
  22.      * @var ?OrderContextShoppingCart
  23.      */
  24.     private $orderContextShoppingCart;
  25.     /**
  26.      * OrderContext constructor.
  27.      *
  28.      * @param ?OrderContextBilling $billing
  29.      */
  30.     public function __construct($billing)
  31.     {
  32.         $this->setOrderContextBilling($billing);
  33.     }
  34.     public function jsonSerialize()
  35.     {
  36.         return array_filter([
  37.             'billing' => $this->getOrderContextBilling(),
  38.             'client' => $this->getOrderContextClient(),
  39.             'shipping' => $this->getOrderContextShipping(),
  40.             'shoppingCart' => $this->getOrderContextShoppingCart()
  41.         ], function ($value) {
  42.             return !is_null($value);
  43.         });
  44.     }
  45.     /**
  46.      * @return OrderContextBilling
  47.      */
  48.     public function getOrderContextBilling(): OrderContextBilling
  49.     {
  50.         return $this->orderContextBilling;
  51.     }
  52.     /**
  53.      * @param OrderContextBilling $orderContextBilling
  54.      */
  55.     public function setOrderContextBilling(OrderContextBilling $orderContextBilling): void
  56.     {
  57.         $this->orderContextBilling $orderContextBilling;
  58.     }
  59.     /**
  60.      * @return OrderContextClient|null
  61.      */
  62.     public function getOrderContextClient(): ?OrderContextClient
  63.     {
  64.         return $this->orderContextClient;
  65.     }
  66.     /**
  67.      * @param OrderContextClient|null $orderContextClient
  68.      */
  69.     public function setOrderContextClient(?OrderContextClient $orderContextClient): void
  70.     {
  71.         $this->orderContextClient $orderContextClient;
  72.     }
  73.     /**
  74.      * @return OrderContextShipping|null
  75.      */
  76.     public function getOrderContextShipping(): ?OrderContextShipping
  77.     {
  78.         return $this->orderContextShipping;
  79.     }
  80.     /**
  81.      * @param OrderContextShipping|null $orderContextShipping
  82.      */
  83.     public function setOrderContextShipping(?OrderContextShipping $orderContextShipping): void
  84.     {
  85.         $this->orderContextShipping $orderContextShipping;
  86.     }
  87.     /**
  88.      * @return OrderContextShoppingCart|null
  89.      */
  90.     public function getOrderContextShoppingCart(): ?OrderContextShoppingCart
  91.     {
  92.         return $this->orderContextShoppingCart;
  93.     }
  94.     /**
  95.      * @param OrderContextShoppingCart|null $orderContextShoppingCart
  96.      */
  97.     public function setOrderContextShoppingCart(?OrderContextShoppingCart $orderContextShoppingCart): void
  98.     {
  99.         $this->orderContextShoppingCart $orderContextShoppingCart;
  100.     }
  101. }
  102. ?>