Access a given campaigndraft resource
@param string $CampaignId
@return array
355595
public function findByCampaignDraftId($CampaignId)
    {
        $response = $this->mailjet->get(Resources::$Campaigndraft,
            ['id' => $CampaignId]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftManager:findByCampaignDraftId() failed",
                $response);
        }

        return $response->getData();
    }
659799
public function getAllCampaigns(array $filters = null) {
        $response = $this->mailjet->get(Resources::$Campaign, ['filters' => $filters]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftManager:getAllCampaigns() failed", $response);
        }

        return $response->getData();
    }
1359864
public function getSourcesByCampaign($campaignId)
    {
        // WHERE campaign_settings REGEXP '\"campaignId\":\s*\"' . campaing_id . '\",';
        //       $where = 'l.'.$field.' REGEXP  :value';

        $q = $this->_em->getConnection()->createQueryBuilder()
            ->select('cs.*')
            ->from(MAUTIC_TABLE_PREFIX.'contactsource', 'cs');

        $where = 'REPLACE(cs.campaign_settings, " ", "") REGEXP  :regex';
        $q->where(
                $q->expr()->eq('cs.is_published', true),
                $q->expr()->andX($where)
        );

        $q->setParameter('regex', '"campaignId\":"'.$campaignId.'"');

        $results = $q->execute()->fetchAll();

        return $results;
    }
736755
public function GetAgentGroups($CampaignId, Request\GetAgentGroups $GetAgentGroups = null)
    {
        $uri = $this->getUri('/ccc/%s/agent-group', array($CampaignId));

        return $this->get($uri, $GetAgentGroups);
    }
687029
public function create(CampaignDraft $campaignDraft)
    {
        $response = $this->mailjet->post(Resources::$Campaigndraft,
            ['body' => $campaignDraft->format()]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftManager:create() failed", $response);
        }

        return $response->getData();
    }
778231
public function getCampaignRevenueDatatableData(Campaign $campaign, \DateTime $dateFrom, \DateTime $dateTo)
    {
        $response = [];

        $cache_dir = $this->dispatcher->getContainer()->getParameter('kernel.cache_dir');

        $unit             = $this->getTimeUnitFromDateRange($dateFrom, $dateTo);
        $chartQueryHelper = new ChartQuery($this->em->getConnection(), $dateFrom, $dateTo, $unit);
        $dbunit           = $chartQueryHelper->translateTimeUnit($unit);

        $results = $this->getRepository()->getCampaignRevenueData(
            $campaign,
            $dateFrom,
            $dateTo,
            $unit,
            $dbunit,
            $cache_dir
        );

        // Allow other bundles to alter the data before rendering
        $event = new ChartDataAlterEvent(
            'campaign.revenue.datatable',
            [
                'campaign' => $campaign,
                'dateFrom' => $dateFrom,
                'dateTo'   => $dateTo,
                'unit'     => $unit,
                'dbunit'   => $dbunit,
                'cacheDir' => $cache_dir,
            ], $results
        );
        $this->dispatcher->dispatch('mautic.contactledger.chartdata.alter', $event);
        $results = $event->getData();

        foreach ($results as $result) {
            $result['cost']    = self::formatDollar($result['cost']);
            $result['revenue'] = self::formatDollar($result['revenue']);
            $result['profit']  = self::formatDollar($result['profit']);
            $response[]        = $result;
        }

        return $response;
    }
1301319
private function getPublishedCampaigns($campaignId = null)
    {
        if (!$this->publishedCampaigns) {
            foreach ($this->campaignModel->getPublishedCampaigns(true) as $campaign) {
                $this->publishedCampaigns[$campaign['id']] = $campaign['name'];
            }
        }

        if ($campaignId) {
            return isset($this->publishedCampaigns[$campaignId]) ? $this->publishedCampaigns[$campaignId] : null;
        } else {
            return $this->publishedCampaigns;
        }
    }
534952
private function getActivities($campaignId) {
    $activities = [];

    $categories = $this->getCategories($campaignId);

    foreach (array_keys($categories) as $categoryId) {
      $topTerm = $this->taxonomyStorage->load($categoryId);

      $terms = $this->taxonomyStorage->loadTree($topTerm->getVocabularyId(), $categoryId, 1, TRUE);
      /** @var \Drupal\taxonomy\Entity\Term $term */
      foreach ($terms as $term) {
        if (!$term->field_enable_activities_counter->value) {
          continue;
        }
        $activities[$term->id()] = $term->getName();
      }
    }
    asort($activities);

    return $activities;
  }
117521
public function getCampaigns() {

        return $this->createQueryBuilder('campaign')
            ->where('campaign.status != :statusBackgroundProcess')
            ->setParameter('statusBackgroundProcess', Action::STATUS_BACKGROUND_PROCESS)
            ->orderBy('campaign.startDate', 'DESC')
            ->getQuery()
            ->getResult();
    }
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;
    }
1038177
public function removeSchedule($CampaignId)
    {
        $response = $this->mailjet->delete(Resources::$CampaigndraftSchedule,
            ['id' => $CampaignId]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftManager:removeSchedule failed",
                $response);
        }

        return $response->getData();
    }
631054
private static List<CampaignFeed> getCampaignFeeds(AdWordsServicesInterface adWordsServices,
      AdWordsSession session, Feed feed, int placeholderType) throws RemoteException {
    // Get the CampaignFeedService.
    CampaignFeedServiceInterface campaignFeedService =
        adWordsServices.get(session, CampaignFeedServiceInterface.class);

    String query = String.format(
        "SELECT CampaignId, MatchingFunction, PlaceholderTypes WHERE Status = 'ENABLED' "
        + "AND FeedId = %d AND PlaceholderTypes CONTAINS_ANY [%d]", feed.getId(), placeholderType);

    List<CampaignFeed> campaignFeeds = new ArrayList<>();
    int offset = 0;
    CampaignFeedPage campaignFeedPage;

    do {
      String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
      campaignFeedPage = campaignFeedService.query(pageQuery);
      if (campaignFeedPage.getEntries() != null) {
        campaignFeeds.addAll(Arrays.asList(campaignFeedPage.getEntries()));
      }
      offset += PAGE_SIZE;
    } while (offset < campaignFeedPage.getTotalNumEntries());

    return campaignFeeds;
  }
1088954
public function toChannels($channels, $campaignId, $meta = [])
	{
		$data = ['channel_uids' => $channels, 'meta' => $meta];

		return $this->request->send('POST', "channels/campaigns/$campaignId", $data);
	}
657910
public function getAllCampaignDrafts(array $filters = null)
    {
        $response = $this->mailjet->get(Resources::$Campaigndraft,
            ['filters' => $filters]);
        if (!$response->success()) {
            $this->throwError("CampaignDraftService :getAllCampaignDrafts() failed",
                $response);
        }

        return $response->getData();
    }
849955
public function cancel($campaignId)
    {
        $endpoint = $this->endpoint . '/' . $campaignId . '/actions/cancel';

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

        return $response['body'];
    }
1076103
public function getCampaignInfo($id)
    {
        if (empty($id)) {
            return $this->handleError('Empty campaign id');
        }

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

        return $this->handleResult($requestResult);
    }
1291763
public function AddAgents($CampaignId, Request\AddAgents $AddAgents = null)
    {
        $uri = $this->getUri('/ccc/%s/agent', array($CampaignId));

        return $this->post($uri, $AddAgents);
    }