Ejemplo n.º 1
0
 def save_user_credentials_in_db(cls, user_credentials):
     """
     :param user_credentials: User's social network credentials for Meetup.
     :type user_credentials: dict
     - This overrides the SocialNetworkBase class method
         save_user_credentials_in_db() because in case of user credentials
         related to Eventbrite, we also need to create webhook.
     - It first saves the credentials in db, gets the Meetup Groups by calling
         import_meetup_groups()using Meetup's API and updates the record in db.
     **See Also**
     .. seealso:: save_user_credentials_in_db() function defined in
         SocialNetworkBase class inside social_network_service/base.py.
     .. seealso::POST method of end point ProcessAccessToken()
         defined in social network Rest API inside
         social_network_service/app/restful/social_network.py.
     """
     user_credentials_in_db = super(
         cls, cls).save_user_credentials_in_db(user_credentials)
     try:
         meetup = cls(
             user_id=user_credentials_in_db.user_id,
             social_network_id=user_credentials_in_db.social_network_id)
         meetup.import_meetup_groups()
     except Exception as e:
         UserSocialNetworkCredential.delete(user_credentials_in_db)
         raise
     return user_credentials_in_db
Ejemplo n.º 2
0
 def save_user_credentials_in_db(cls, user_credentials):
     """
     :param user_credentials: User's social network credentials for which
             we need to create webhook. Webhook is created to be updated
             about any RSVP on an event of Eventbrite.
     :type user_credentials: dict
     - This overrides the SocialNetworkBase class method
         save_user_credentials_in_db() because in case of user credentials
         related to Eventbrite, we also need to create webhook.
     - It first saves the credentials in db, gets the webhook id by calling
         create_webhook()using Eventbrite's API and updates the record in db.
     - This method is called from POST method of end point ProcessAccessToken()
         defined in social network Rest API inside
         social_network_service/app/restful/social_network.py.
     **See Also**
     .. seealso:: save_user_credentials_in_db() function defined in
         SocialNetworkBase class inside social_network_service/base.py.
     .. seealso::POST method of end point ProcessAccessToken()
         defined in social network Rest API inside
         social_network_service/app/restful/social_network.py.
     """
     user_credentials_in_db = super(
         Eventbrite,
         Eventbrite).save_user_credentials_in_db(user_credentials)
     try:
         Eventbrite.create_webhook(user_credentials_in_db)
     except Exception:
         UserSocialNetworkCredential.delete(user_credentials_in_db)
         raise
     return user_credentials_in_db
Ejemplo n.º 3
0
 def disconnect(cls, user_id, social_network):
     user_credentials = UserSocialNetworkCredential.get_by_user_and_social_network_id(user_id, social_network.id)
     if user_credentials:
         UserSocialNetworkCredential.delete(user_credentials)
     return user_credentials