Store $campaignId on cookies

@param $campaignId
436823
public function storeCampaignId($campaignId)
    {
        if (!preg_match('/^\{?[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}\}?$/', $campaignId)) {
            throw new \InvalidArgumentException('$campaignId should be a valid uuid');
        }

        $this->cookie->setCookie(CookieNames::CAMPAIGN_ID, $campaignId);
    }
39284
public function GetAgents($CampaignId, Request\GetAgents $GetAgents = null)
    {
        $uri = $this->getUri('/ccc/%s/agent', array($CampaignId));

        return $this->get($uri, $GetAgents);
    }
989892
private function processConfirmedCustomerAbandonedCart($storeId, $campaignId)
    {
        $ac1QuoteIdsWithConfirmedContacts = $this->abandonedCollectionFactory->create()
            ->getCollectionByConfirmedStatus($storeId)
            ->getColumnValues('quote_id');

        $quoteCollectionFromIds = $this->orderCollection->create()
            ->getStoreQuotesFromQuoteIds($ac1QuoteIdsWithConfirmedContacts, $storeId);
        return $this->createCustomerFirstAbandonedCart(
            $quoteCollectionFromIds,
            $storeId,
            $campaignId
        );
    }
1076103
public function getCampaignInfo($id)
    {
        if (empty($id)) {
            return $this->handleError('Empty campaign id');
        }

        $requestResult = $this->sendRequest('campaigns/' . $id);

        return $this->handleResult($requestResult);
    }
894657
private function createEntity($campaignId = 0)
    {
        $entity = new CacheEntity();
        $entity->setAddress1(trim(ucwords($this->contact->getAddress1())));
        $entity->setAddress2(trim(ucwords($this->contact->getAddress2())));
        $category = $this->contactSource->getCategory();
        if ($category) {
            $entity->setCategory($category->getId());
        }
        if ($campaignId) {
            $entity->setCampaign($campaignId);
        }
        $entity->setCity(trim(ucwords($this->contact->getCity())));
        $entity->setContact($this->contact->getId());
        $entity->setContactSource($this->contactSource->getId());
        $entity->setState(trim(ucwords($this->contact->getStage())));
        $entity->setCountry(trim(ucwords($this->contact->getCountry())));
        $entity->setZipcode(trim($this->contact->getZipcode()));
        $entity->setEmail(trim($this->contact->getEmail()));
        $phone = $this->contact->getPhone();
        if (!empty($phone)) {
            $entity->setPhone($phone);
        }
        $mobile = $this->contact->getMobile();
        if (!empty($mobile)) {
            $entity->setMobile($mobile);
        }
        // get the original / first utm source code for contact
        $utmSource = $this->utmSourceHelper->getFirstUtmSource($this->contact);
        if (!empty($utmSource)) {
            $entity->setUtmSource(trim($utmSource));
        }

        return $entity;
    }
1372278
public function store(Request $request, Response $response, $localeId)
	{
		$response->headers->setCookie(new Cookie($this->cookieName, $localeId));
	}
772035
public function logout($campaign_id = NULL) {
    $response = new AjaxResponse();

    // Logout member - clear Campaign ID from SESSION.
    MemberCampaign::logout($campaign_id);

    $logoutTitle = $this->t('Thank you!');
    $logoutMessage = $this->t('You were successfully logged out!');

    $response->addCommand(new OpenModalDialogCommand($logoutTitle, $logoutMessage, ['width' => 800]));

    // Close dialog and redirect ot Campaign main page.
    $response->addCommand(new InvokeCommand('#drupal-modal', 'closeDialog', ['<campaign-front>']));

    return $response;
  }
3499
private function initStoreProductData($productId, $storeId)
    {
        if (!array_key_exists($productId, $this->attributeData)) {
            $this->attributeData[$productId] = [];
        }

        if (!array_key_exists($storeId, $this->attributeData[$productId])) {
            $this->attributeData[$productId][$storeId] = [];
        }
    }
1039723
private static function createCampaignWithBiddingStrategy(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $biddingStrategyId,
        $sharedBudgetId
    ) {
        $campaignService = $adWordsServices->get($session, CampaignService::class);

        // Create campaign with some properties set.
        $campaign = new Campaign();
        $campaign->setName('Interplanetary Cruise #' . uniqid());

        // Set the budget.
        $campaign->setBudget(new Budget());
        $campaign->getBudget()->setBudgetId($sharedBudgetId);
        $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

        // Set the campaign's bidding strategy.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->setBiddingStrategyId($biddingStrategyId);

        $campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Set network targeting (recommended).
        $networkSetting = new NetworkSetting();
        $networkSetting->setTargetGoogleSearch(true);
        $networkSetting->setTargetSearchNetwork(true);
        $networkSetting->setTargetContentNetwork(true);
        $campaign->setNetworkSetting($networkSetting);

        // Recommendation: Set the campaign to PAUSED when creating it to stop
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve.
        $campaign->setStatus(CampaignStatus::PAUSED);

        // Create a campaign operation.
        $operation = new CampaignOperation();
        $operation->setOperand($campaign);
        $operation->setOperator(Operator::ADD);

        // Create the campaign on the server and print out some information for the
        // campaign.
        $result = $campaignService->mutate([$operation]);
        $newCampaign = $result->getValue()[0];
        printf(
            "Campaign with name '%s', ID %d and bidding scheme ID %d was created.\n",
            $newCampaign->getName(),
            $newCampaign->getId(),
            $newCampaign->getBiddingStrategyConfiguration()->getBiddingStrategyId()
        );
    }
57032
private function logEvent(int $productId, int $storeId): void
    {
        $pageData = [];
        $pageData['store_id']           = $storeId;
        $pageData['cart']['product_id'] = $productId;

        $eventData = ['page' => $pageData, 'session' => $this->getSessionData()];

        $this->service->addEvent($eventData);
    }
1195142
public function getSchedule($CampaignId)
    {
        $response = $this->mailjet->get(Resources::$CampaigndraftSchedule,
            ['id' => $CampaignId]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftService:getSchedule failed",
                $response);
        }

        return $response->getData();
    }
603439
public function send($campaignId, $settingsData = [])
    {
        $endpoint = $this->endpoint . '/' . $campaignId . '/actions/send';

        $response = $this->restClient->post($endpoint, $settingsData);

        return $response['body'];
    }
577401
public static function findMemberCampaign($membershipID, $campaignID) {
    $connection = \Drupal::service('database');
    /** @var \Drupal\Core\Database\Query\Select $query */
    $query = $connection->select('openy_campaign_member', 'm');
    $query->condition('m.membership_id', $membershipID);
    $query->join('openy_campaign_member_campaign', 'mc', 'm.id = mc.member');
    $query->condition('mc.campaign', $campaignID);
    $query->fields('mc', ['id']);
    $memberCampaignRes = $query->execute()->fetchField();

    return (!empty($memberCampaignRes)) ? $memberCampaignRes : FALSE;
  }
207980
public function RemoveAgent($CampaignId, $Id, Request\RemoveAgent $RemoveAgent = null)
    {
        $uri = $this->getUri('/ccc/%s/agent/%s', array($CampaignId, $Id));

        return $this->delete($uri, $RemoveAgent);
    }
55516
public function getCampaignSettingsById($campaignId)
    {
        $results = [];
        if (
            $campaignId
            && isset($this->campaignSettings)
            && isset($this->campaignSettings->campaigns)
            && is_array($this->campaignSettings->campaigns)
        ) {
            // Note, there may be multiple matches for the same campaignId for future mapping purposes, so we aggregate.
            foreach ($this->campaignSettings->campaigns as $id => $campaign) {
                if (isset($campaign->campaignId) && $campaign->campaignId == $campaignId) {
                    $results[$id] = $campaign;
                }
            }
        }

        return $results;
    }
809869
public function setSessionId(string $sessionId): void
    {
        if (empty($sessionId)) {
            throw new RuntimeException('CSRF middleware failed. SessionId not found!');
        }

        $this->sessionId = $sessionId;
    }
445217
public function setCookie($id)
    {
        array_push($this->siteIds, 1);

        $this->session->set(self::SESSION_KEY, $this->siteIds);
    }