-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.py
More file actions
29 lines (21 loc) · 861 Bytes
/
example.py
File metadata and controls
29 lines (21 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
"""Example usage of the Pushpad Python client."""
import pushpad
TOKEN = "5374d7dfeffa2eb49965624ba7596a09"
PROJECT_ID = 123
client = pushpad.Pushpad(auth_token=TOKEN, project_id=PROJECT_ID)
print(f"HMAC signature for 'user1': {client.signature_for('user1')}")
created = client.notifications.create(
body="Hello world!",
title="Website Name",
target_url="https://example.com",
uids=["user1", "user2", "user3"],
tags=["segment1", "segment2"],
)
print(f"Notification accepted with id: {created.id}")
latest = client.notifications.all(page=1)
print(f"Latest notifications: {latest}")
subscriptions = client.subscriptions.all(per_page=5)
print(f"First page of subscriptions: {subscriptions}")
count = client.subscriptions.count(tags=["segment1 && !optout"])
print(f"Subscribers in the filtered segment: {count}")