@@ -20,7 +20,7 @@ Alternatively, install from source with:
2020python -m pip install .
2121```
2222
23- ## Usage
23+ ## Setup
2424
2525``` python
2626import os
@@ -29,25 +29,92 @@ from activitysmith import ActivitySmith
2929activitysmith = ActivitySmith(
3030 api_key = os.environ[" ACTIVITYSMITH_API_KEY" ],
3131)
32+ ```
33+
34+ ## Usage
3235
33- # Push Notifications
34- activitysmith.notifications.send(
36+ ### Send a Push Notification
37+
38+ ``` python
39+ response = activitysmith.notifications.send(
3540 {
36- # See PushNotificationRequest for fields
41+ " title" : " Build Failed" ,
42+ " message" : " CI pipeline failed on main branch" ,
3743 }
3844)
3945
40- # Live Activities
41- activitysmith.live_activities.start(
46+ print (response.success)
47+ print (response.devices_notified)
48+ ```
49+
50+ ### Start a Live Activity
51+
52+ ``` python
53+ start = activitysmith.live_activities.start(
4254 {
43- # See LiveActivityStartRequest for fields
55+ " content_state" : {
56+ " title" : " ActivitySmith API Deployment" ,
57+ " subtitle" : " start" ,
58+ " number_of_steps" : 4 ,
59+ " current_step" : 1 ,
60+ " type" : " segmented_progress" ,
61+ " color" : " yellow" ,
62+ }
4463 }
4564)
65+
66+ activity_id = start.activity_id
4667```
4768
48- ## API Surface
69+ ### Update a Live Activity
70+
71+ ``` python
72+ update = activitysmith.live_activities.update(
73+ {
74+ " activity_id" : activity_id,
75+ " content_state" : {
76+ " title" : " ActivitySmith API Deployment" ,
77+ " subtitle" : " npm i & pm2" ,
78+ " current_step" : 3 ,
79+ }
80+ }
81+ )
82+
83+ print (update.devices_notified)
84+ ```
85+
86+ ### End a Live Activity
87+
88+ ``` python
89+ end = activitysmith.live_activities.end(
90+ {
91+ " activity_id" : activity_id,
92+ " content_state" : {
93+ " title" : " ActivitySmith API Deployment" ,
94+ " subtitle" : " done" ,
95+ " current_step" : 4 ,
96+ " auto_dismiss_minutes" : 3 ,
97+ }
98+ }
99+ )
100+
101+ print (end.success)
102+ ```
103+
104+ ## Error Handling
49105
50- The client exposes grouped resources:
106+ ``` python
107+ try :
108+ activitysmith.notifications.send(
109+ {
110+ " title" : " Build Failed" ,
111+ }
112+ )
113+ except Exception as err:
114+ print (" Request failed:" , err)
115+ ```
116+
117+ ## API Surface
51118
52119- ` activitysmith.live_activities `
53120- ` activitysmith.notifications `
0 commit comments