-
-
Save nightscape/80c073dd26792f5de7d8 to your computer and use it in GitHub Desktop.
Scala.jsFiddle gist
This file contains 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._ | |
/** | |
* This is an example app for Apps Scaripped using Google Spreadsheet | |
*/ | |
object AppsScarippedMain extends js.JSApp{ | |
def main(): Unit = { | |
val adsIterator = AdWordsApp.ads() | |
.withCondition("ApprovalStatus = DISAPPROVED") | |
.get() | |
// Creates a new spreadsheet | |
val spreadsheet = SpreadsheetApp.create("Disapproved ads") | |
// Uses the standard sheet | |
val sheet = spreadsheet.getActiveSheet() | |
// Enters a header row | |
sheet.getRange("A1").setValue("Campaign") | |
sheet.getRange("B1").setValue("Ad group") | |
sheet.getRange("C1").setValue("Ad") | |
sheet.getRange("D1").setValue("Approval status") | |
// Writes the report content | |
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") | |
List(ad.getHeadline(), ad.getDescription1(), ad.getDescription2()).mkString("\n") | |
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! Now please visit the following URL to see the awesomeness:") | |
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