/**
  * @param $cartId
  * @param $productId
  * @param $variantId
  * @param $quantity
  * @return Cart|null
  */
 public function addLineItem($cartId, $productId, $variantId, $quantity, $currency, $country)
 {
     $cart = null;
     if (!is_null($cartId)) {
         $cart = $this->getCart($cartId);
     }
     if (is_null($cart)) {
         $lineItems = LineItemDraftCollection::of()->add(LineItemDraft::of()->setProductId($productId)->setVariantId($variantId)->setQuantity($quantity));
         $cart = $this->createCart($currency, $country, $lineItems);
     } else {
         $cartUpdateRequest = CartUpdateRequest::ofIdAndVersion($cart->getId(), $cart->getVersion());
         $cartUpdateRequest->addAction(CartAddLineItemAction::ofProductIdVariantIdAndQuantity($productId, $variantId, $quantity));
         $this->profiler->enter($profile = new Profile('addLineItem'));
         $cartResponse = $cartUpdateRequest->executeWithClient($this->client);
         if ($cartResponse->isError()) {
             var_dump((string) $cartResponse->getBody());
             exit;
         }
         $this->profiler->leave($profile);
         $cart = $cartUpdateRequest->mapResponse($cartResponse);
     }
     return $cart;
 }
 /**
  * @param $cartId
  * @param $productId
  * @param $variantId
  * @param $quantity
  * @return Cart|null
  */
 public function addLineItem($locale, $cartId, $productId, $variantId, $quantity, $currency, $country, $customerId = null)
 {
     $cart = null;
     if (!is_null($cartId)) {
         $cart = $this->getCart($locale, $cartId, $customerId);
     }
     if (is_null($cart)) {
         $lineItems = LineItemDraftCollection::of()->add(LineItemDraft::of()->setProductId($productId)->setVariantId($variantId)->setQuantity($quantity));
         $cart = $this->createCart($locale, $currency, $country, $lineItems, $customerId);
     } else {
         $client = $this->getClient();
         $cartUpdateRequest = CartUpdateRequest::ofIdAndVersion($cart->getId(), $cart->getVersion());
         $cartUpdateRequest->addAction(CartAddLineItemAction::ofProductIdVariantIdAndQuantity($productId, $variantId, $quantity));
         $cartResponse = $cartUpdateRequest->executeWithClient($client);
         if ($cartResponse->isError()) {
             throw new \InvalidArgumentException();
         }
         $cart = $cartUpdateRequest->mapFromResponse($cartResponse, $this->getMapper($locale));
         $this->session->set(self::CART_ITEM_COUNT, $cart->getLineItemCount());
     }
     return $cart;
 }