|
15 | 15 | pnconfig.non_subscribe_request_timeout = 60 |
16 | 16 | pnconfig.connect_timeout = 14 |
17 | 17 | pnconfig.reconnect_policy |
18 | | -print(pnconfig.subscribe_key) |
19 | 18 |
|
20 | 19 | pubnub = PubNub(pnconfig) |
21 | 20 |
|
22 | 21 | space_id = 'blah' |
23 | 22 | user_id = 'jason-id' |
| 23 | +user_id_2 = 'freddy-id' |
24 | 24 |
|
25 | 25 | create_space = pubnub.create_space( |
26 | 26 | space_id=space_id, |
|
67 | 67 | users = pubnub.fetch_user(user_id=user_id, sync=True) |
68 | 68 | print(f"fetch_user: {users.result.__dict__}") |
69 | 69 |
|
70 | | -membership = pubnub.add_memberships(user_id=user_id, spaces=Space(space_id=space_id, custom={"a": "b"}), sync=True) |
| 70 | +membership = pubnub.add_memberships(user_id=user_id, spaces=[Space(space_id=space_id, custom={"a": "b"})], sync=True) |
71 | 71 | print(f"add_memberships (user_id): {membership.result.__dict__}") |
72 | 72 |
|
73 | 73 | memberships = pubnub.fetch_memberships(user_id=user_id, include_custom=True, sync=True) |
74 | 74 | print(f"fetch_memberships (user_id): {memberships.result.__dict__}") |
75 | 75 |
|
76 | 76 | print("-------") |
77 | 77 |
|
78 | | -membership = pubnub.update_memberships(user_id=user_id, spaces=Space(space_id=space_id, custom={"c": "d"}), sync=True) |
| 78 | +membership = pubnub.update_memberships(user_id=user_id, spaces=[Space(space_id=space_id, custom={"c": "d"})], sync=True) |
79 | 79 | print(f"add_memberships (user_id): {membership.result.__dict__}") |
80 | 80 |
|
81 | 81 | memberships = pubnub.fetch_memberships(user_id=user_id, include_custom=True, sync=True) |
|
93 | 93 |
|
94 | 94 | print("-------") |
95 | 95 |
|
96 | | -membership = pubnub.remove_memberships(user_id=user_id, spaces=Space(space_id=space_id), sync=True) |
| 96 | +membership = pubnub.remove_memberships(user_id=user_id, spaces=[Space(space_id=space_id)], sync=True) |
97 | 97 | print(f"remove_memberships (user_id): {membership.result.__dict__}") |
98 | 98 |
|
99 | 99 | memberships = pubnub.fetch_memberships(user_id=user_id, include_custom=True, sync=True) |
100 | 100 | print(f"fetch_memberships (user_id): {memberships.result.__dict__}") |
101 | 101 |
|
102 | 102 | print("-------") |
103 | 103 |
|
104 | | -membership = pubnub.add_memberships(space_id=space_id, users=[User(user_id=user_id, custom={"1": "2"})], sync=True) |
| 104 | +membership = pubnub.add_memberships( |
| 105 | + space_id=space_id, |
| 106 | + users=[User(user_id=user_id, custom={"Kikiki": "Mamama"})], |
| 107 | + sync=True |
| 108 | +) |
105 | 109 | print(f"add_memberships (space_id): {membership.result.__dict__}") |
106 | 110 |
|
| 111 | +membership = pubnub.update_memberships(space_id=space_id, users=[ |
| 112 | + User(user_id=user_id_2, custom={"1-2": "Freddy's comming"}), |
| 113 | + User(user_id='ghostface', custom={"question": "Favourite scary movie?"}) |
| 114 | +], sync=True) |
| 115 | +print(f"update_memberships (space_id): {membership.result.__dict__}") |
| 116 | + |
| 117 | +print("-------") |
| 118 | + |
107 | 119 | memberships = pubnub.fetch_memberships(space_id=space_id, include_custom=True, sync=True) |
108 | 120 | print(f"fetch_memberships (space_id): {memberships.result.__dict__}") |
0 commit comments