@@ -533,6 +533,35 @@ def get_content_decisions(self, user_id, content_id, timeout=None):
533533 except requests .exceptions .RequestException as e :
534534 raise ApiException (str (e ))
535535
536+ def get_session_decisions (self , user_id , session_id , timeout = None ):
537+ """Gets the decisions for a user's session.
538+
539+ Args:
540+ user_id: The ID of a user.
541+ session_id: The ID of a session.
542+
543+ Returns:
544+ A sift.client.Response object if the call succeeded.
545+ Otherwise, raises an ApiException.
546+
547+ """
548+ if not isinstance (user_id , self .UNICODE_STRING ) or len (user_id .strip ()) == 0 :
549+ raise ApiException ("user_id must be a string" )
550+ if not isinstance (session_id , self .UNICODE_STRING ) or len (session_id .strip ()) == 0 :
551+ raise ApiException ("session_id must be a string" )
552+
553+ if timeout is None :
554+ timeout = self .timeout
555+
556+ try :
557+ return Response (requests .get (
558+ self ._session_decisions_url (self .account_id , user_id , session_id ),
559+ auth = requests .auth .HTTPBasicAuth (self .api_key , '' ),
560+ headers = {'User-Agent' : self ._user_agent ()},
561+ timeout = timeout ))
562+
563+ except requests .exceptions .RequestException as e :
564+ raise ApiException (str (e ))
536565
537566 def apply_session_decision (self , user_id , session_id , properties , timeout = None ):
538567 """Apply decision to session
@@ -638,6 +667,9 @@ def _user_decisions_url(self, account_id, user_id):
638667 def _order_decisions_url (self , account_id , order_id ):
639668 return API3_URL + '/v3/accounts/%s/orders/%s/decisions' % (account_id , order_id )
640669
670+ def _session_decisions_url (self , account_id , user_id , session_id ):
671+ return API3_URL + '/v3/accounts/%s/users/%s/sessions/%s/decisions' % (account_id , user_id , session_id )
672+
641673 def _content_decisions_url (self , account_id , user_id , content_id ):
642674 return API3_URL + '/v3/accounts/%s/users/%s/content/%s/decisions' % (account_id , user_id , content_id )
643675
0 commit comments