Created
November 27, 2018 00:47
-
-
Save MightySCollins/9c3bf6ff290478a1732a222126806705 to your computer and use it in GitHub Desktop.
Simple script to bulk mark zendesk tickets as spam
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 requests | |
import time | |
from itertools import islice, chain, repeat | |
SUBDOMAIN = "" | |
EMAIL = "" | |
TOKEN = "" | |
MIN = 1 | |
MAX = 1000 | |
def chunk_pad(it, size, padval=None): | |
it = chain(iter(it), repeat(padval)) | |
return iter(lambda: tuple(islice(it, size)), (padval,) * size) | |
for chunk in chunk_pad(range(MIN, MAX), 100): | |
ids = ",".join([str(i) for i in chunk if i is not None]) | |
url = f"https://{SUBDOMAIN}.zendesk.com/api/v2/tickets/mark_many_as_spam.json?ids={ids}" | |
response = requests.put( | |
url, | |
params={"ids": ids}, | |
headers={"Content-Type": "application/json"}, auth=(f"{EMAIL}/token", TOKEN)) | |
print(response.json()) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment