Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit e57181a

Browse files
author
Josh Wolff
committed
Updating API wrapper with pushTitle and individualFollowers
1 parent b7ae4d3 commit e57181a

File tree

5 files changed

+151
-95
lines changed

5 files changed

+151
-95
lines changed

.idea/workspace.xml

Lines changed: 52 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Above we see a push notification sent to the main channel. Here, "Josh Wolff" is
5151
<img src="https://github.com/spontit/spontit-api-python-wrapper/raw/master/images/topic_push.png" />
5252
</p>
5353

54-
Above we see a push notification to a channel (separate from the main channel). Josh owns this channel, but as you can see, it looks like its own account. "Dem 2020 Polls" is the channel name, the non-bold text is the message, and the image is the image set for the channel (see step 10 above).
54+
Above we see a push notification to a channel (separate from the main channel). Josh owns this channel, but as you can see, it looks like its own account. "Dem 2020 Polls" is the channel name, the non-bold text is the message, and the image is the image set for the channel (see step 10 above). You can also change the push title with the pushTitle attribute.
5555

5656
#### Note on Our Development Priorities
5757

1.53 KB
Binary file not shown.

spontit/examples/examples.py

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,64 @@ def simple_push_example(self):
1919
Sends a simple push notification.
2020
:return: the result of the call to push
2121
"""
22-
return self.__resource.push("Hello!")
22+
response = self.__resource.push("Hello!")
23+
print(response)
24+
return response
25+
26+
def simple_push_to_specific_followers_example(self):
27+
"""
28+
Sends a push notification to specifically you. You can specify which followers should receive the notification
29+
as shown below. To list your followers, see the list_followers_example().
30+
:return:
31+
"""
32+
followers = [self.__resource.user_id]
33+
response = self.__resource.push(
34+
"Hello to myself!",
35+
body="No one else can see this until I specifically share it with them, by either sharing"
36+
" the link or tagging them in the comments.",
37+
push_to_followers=followers
38+
)
39+
print(response)
40+
return response
41+
42+
def list_followers_example(self):
43+
"""
44+
Lists all your followers.
45+
:return:
46+
"""
47+
response = self.__resource.list_followers()
48+
print(response)
49+
return response
50+
51+
def specific_followers_and_channel_example(self):
52+
"""
53+
Sends a push notification to a specific user following the channel. The user must be following the channel in
54+
order to receive it. You can specify which followers should receive the notification as shown below. To list
55+
your followers, see the list_followers_for_channel_example().
56+
:return:
57+
"""
58+
# Create the channel if it is not yet created.
59+
self.__resource.create_channel("Test channel")
60+
followers = [self.__resource.user_id]
61+
response = self.__resource.push(
62+
f"Hello to {followers[0]}",
63+
channel_name="Test channel",
64+
push_to_followers=followers
65+
)
66+
print(response)
67+
return response
68+
69+
def list_followers_for_channel_example(self):
70+
"""
71+
Lists all your followers for this particular channel.
72+
:return:
73+
"""
74+
self.__resource.create_channel("Test channel")
75+
response = self.__resource.list_followers(
76+
channel_name="Test channel"
77+
)
78+
print(response)
79+
return response
2380

2481
def scheduled_push(self):
2582
"""
@@ -47,25 +104,13 @@ def expire_one_hour_after_schedule(self):
47104
schedule_time_stamp=int(time.time()) + 3600,
48105
expiration=SpontitResource.Expiration(days=0, hours=1, minutes=0))
49106

50-
def rate_limit_example(self):
51-
"""
52-
Spontit currently only supports sending one push notification per second.
53-
This function throttles that limit as an example of what you can expect if you exceed that limit.
54-
:return: the final response of the 10 calls to push.
55-
"""
56-
response_received = None
57-
for _ in range(10):
58-
response_received = self.simple_push_example()
59-
print(response_received)
60-
return response_received
61-
62107
def subtitle_body_example(self):
63108
"""
64109
Sends a push notification with a subtitle and a body.
65110
:return: the result of the call to push
66111
"""
67112
return self.__resource.push("Hello!",
68-
subtitle="An API Notice",
113+
ios_subtitle="An API Notice",
69114
body="This is a body. You can write up to 500 characters "
70115
"in the body. The body does not show up in the push "
71116
"notification. The body only appears once the user "
@@ -106,6 +151,7 @@ def post_a_link_ex_3(self):
106151
:return: the result of the call to push
107152
"""
108153
return self.__resource.push("Please rate Spontit in the App Store!",
154+
push_title="Spontit Rating Request",
109155
link="https://itunes.apple.com/app/id1448318683?action=write-review",
110156
should_open_link_in_app=False)
111157

@@ -133,6 +179,7 @@ def post_an_ios_deep_link_ex_3(self):
133179
:return: the result of the call to push
134180
"""
135181
return self.__resource.push("Please rate Spontit in the App Store!",
182+
push_title="Spontit Rating Request",
136183
ios_deep_link="itms-apps://itunes.apple.com/app/id1448318683?action=write-review")
137184

138185
def create_new_channel(self):
@@ -264,8 +311,11 @@ def do_everything(self):
264311
self.simple_push_example,
265312
self.scheduled_push,
266313
self.immediate_expiration_push,
314+
self.simple_push_to_specific_followers_example,
315+
self.list_followers_example,
316+
self.list_followers_for_channel_example,
317+
self.specific_followers_and_channel_example,
267318
self.expire_one_hour_after_schedule,
268-
self.rate_limit_example,
269319
self.subtitle_body_example,
270320
self.post_a_link_ex_1,
271321
self.post_a_link_ex_2,

0 commit comments

Comments
 (0)