Last active
August 29, 2015 14:16
-
-
Save nightscape/1d32e23cacb79abc2ec5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.appsscript.adwords._ | |
import com.google.appsscript.base.Logger | |
import com.google.appsscript.spreadsheet._ | |
object ScalaJSExample extends js.JSApp{ | |
def main(): Unit = { | |
val adsIterator = AdWordsApp.ads() | |
.withCondition("ApprovalStatus = DISAPPROVED") | |
.get() | |
// Erstellt eine neue Tabelle, auf die nur Sie zugreifen können. | |
val spreadsheet = SpreadsheetApp.create("Disapproved ads") | |
// Verwendet das Standardblatt. | |
val sheet = spreadsheet.getActiveSheet() | |
// Trägt eine Überschrift ein. | |
sheet.getRange("A1").setValue("Campaign") | |
sheet.getRange("B1").setValue("Ad group") | |
sheet.getRange("C1").setValue("Ad") | |
sheet.getRange("D1").setValue("Approval status") | |
// Schreibt den Inhalt des Berichts. | |
adsIterator.zipWithIndex.foreach { case(ad, row) => | |
Logger.log(s"Adding invalid ad $ad as row $row to spreadsheet") | |
val adType = ad.getType() | |
val adText = if(adType == "TEXT_AD") | |
ad.getHeadline() + "\n" + | |
ad.getDescription1() + "\n" + | |
ad.getDescription2() | |
else | |
"[" + adType + "]" | |
sheet.getRange("A" + row).setValue(ad.getCampaign().getName()) | |
sheet.getRange("B" + row).setValue(ad.getAdGroup().getName()) | |
sheet.getRange("C" + row).setValue(adText) | |
sheet.getRange("D" + row).setValue(ad.getApprovalStatus()) | |
} | |
Logger.log("Report ready! Visit the following URL to see it:") | |
Logger.log("https://docs.google.com/spreadsheet/ccc?key=" + spreadsheet.getId()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment