제외 게재위치 목록

제외 게재위치 목록에 있는 모든 게재위치 가져오기

function getPlacementsFromExcludedPlacementList(name) {
  const excludedPlacementListIterator =
      AdsApp.excludedPlacementLists()
          .withCondition(`shared_set.name = '${name}'`)
          .get();

  if (!excludedPlacementListIterator.hasNext()) {
    throw new Error(`No excluded placement list with name '${name}' found.`);
  }

  const excludedPlacementList = excludedPlacementListIterator.next();
  return excludedPlacementList.excludedPlacements().get();
}

제외 게재위치 목록에 게재위치 추가

function addPlacementToList(url, name) {
  const excludedPlacementListIterator =
      AdsApp.excludedPlacementLists()
          .withCondition(`shared_set.name = '${name}'`)
          .get();

  if (!excludedPlacementListIterator.hasNext()) {
    throw new Error(`No excluded placement list with name '${name}' found.`);
  }
  const excludedPlacementList = excludedPlacementListIterator.next();
  excludedPlacementList.addExcludedPlacement(url);
}