22from pubnub .endpoints .endpoint import Endpoint
33from pubnub .enums import HttpMethod , PNOperationType
44from pubnub .models .consumer .presence import PNGetStateResult
5+ from pubnub .endpoints .validators import UUIDValidatorMixin
56
67
7- class GetState (Endpoint ):
8+ class GetState (Endpoint , UUIDValidatorMixin ):
89 # /v2/presence/sub-key/<subscribe_key>/channel/<channel>/uuid/<uuid>/data?state=<state>
910 GET_STATE_PATH = "/v2/presence/sub-key/%s/channel/%s/uuid/%s"
1011
1112 def __init__ (self , pubnub ):
1213 Endpoint .__init__ (self , pubnub )
1314 self ._channels = []
1415 self ._groups = []
16+ self ._uuid = self .pubnub .uuid
1517
1618 def channels (self , channels ):
1719 utils .extend_list (self ._channels , channels )
1820 return self
1921
22+ def uuid (self , uuid ):
23+ self ._uuid = uuid
24+ return self
25+
2026 def channel_groups (self , channel_groups ):
2127 utils .extend_list (self ._groups , channel_groups )
2228 return self
@@ -33,16 +39,16 @@ def build_path(self):
3339 return GetState .GET_STATE_PATH % (
3440 self .pubnub .config .subscribe_key ,
3541 utils .join_channels (self ._channels ),
36- utils .url_encode (self .pubnub . uuid )
42+ utils .url_encode (self ._uuid )
3743 )
3844
3945 def http_method (self ):
4046 return HttpMethod .GET
4147
4248 def validate_params (self ):
4349 self .validate_subscribe_key ()
44-
4550 self .validate_channels_and_groups ()
51+ self .validate_uuid ()
4652
4753 def create_response (self , envelope ):
4854 if len (self ._channels ) == 1 and len (self ._groups ) == 0 :
0 commit comments