-
Notifications
You must be signed in to change notification settings - Fork 0
Diagram
Phillweston edited this page May 7, 2024
·
4 revisions
- Last Modified: 2024-04-28
- Author: Phill Weston
This document provides a detailed description of the diagram of REST API endpoints for the Lotso-Twitter-Auth service. The service is responsible for authenticating users via Twitter and performing various actions such as retweeting, liking, and bookmarking tweets.
-
GET /start-auth: Start the Twitter authentication process
sequenceDiagram participant Client as Client participant Server as Server participant Twitter as Twitter API Client->>Server: GET /start-auth Server->>Twitter: Request OAuth token Twitter-->>Server: OAuth token Server->>Client: Redirect to Twitter authentication page
-
GET /twitter-callback: Callback URL for Twitter authentication
sequenceDiagram participant Client as Client participant Server as Server participant Twitter as Twitter API Client->>Server: GET /twitter-callback Server->>Twitter: Request OAuth access token Twitter-->>Server: OAuth access token Server->>Server: Store tokens in session Server->>Client: Set session_id cookie Server->>Client: Redirect to /auth-success.html
-
GET /check-auth-status: Check if the user is authenticated
sequenceDiagram participant Client as Client participant Server as Server Client->>Server: GET /check-auth-status Server->>Server: Check if session exists alt Session exists and has access token Server->>Client: { isAuthenticated: true } else Session does not exist or does not have access token Server->>Client: { isAuthenticated: false } end
-
GET /retweet: Retweet the tweet
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /retweet Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfRetweeted() Utils->>Twitter: Check if tweet has been retweeted Twitter-->>Utils: Retweet status Utils-->>Server: Retweet status alt Tweet has not been retweeted Server->>Utils: retweetTweet() Utils->>Twitter: Retweet the tweet Twitter-->>Utils: Retweet response Utils-->>Server: Retweet response Server->>Client: Retweet response else Tweet has been retweeted Server->>Client: Message: 'Tweet has been retweeted before' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /like: Like the target tweet
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /like Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfLiked() Utils->>Twitter: Check if tweet has been liked Twitter-->>Utils: Like status Utils-->>Server: Like status alt Tweet has not been liked Server->>Utils: likeTweet() Utils->>Twitter: Like the tweet Twitter-->>Utils: Like response Utils-->>Server: Like response Server->>Client: Like response else Tweet has been liked Server->>Client: Message: 'Tweet has been liked before' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /bookmark: Bookmark the tweet
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /bookmark Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfBookmarked() Utils->>Twitter: Check if tweet has been bookmarked Twitter-->>Utils: Bookmark status Utils-->>Server: Bookmark status alt Tweet has not been bookmarked Server->>Utils: bookmarkTweet() Utils->>Twitter: Bookmark the tweet Twitter-->>Utils: Bookmark response Utils-->>Server: Bookmark response Server->>Client: Bookmark response else Tweet has been bookmarked Server->>Client: Message: 'Tweet has been bookmarked before' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /follow-us: Follow the target user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /follow-us Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: fetchUserId() Utils->>Twitter: Request target user ID Twitter-->>Utils: Target user ID Utils-->>Server: Target user ID Server->>Utils: followUser() Utils->>Twitter: Follow the user Twitter-->>Utils: Follow response Utils-->>Server: Follow response Server->>Client: Follow response else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-retweet: Check if the tweet has been retweeted
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /check-retweet Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfRetweeted() Utils->>Twitter: Check if tweet has been retweeted Twitter-->>Utils: Retweet status Utils-->>Server: Retweet status Server->>Client: Retweet status else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-follow: Check if target user is followed by the user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /check-follow Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: fetchUserId() Utils->>Twitter: Request target user ID Twitter-->>Utils: Target user ID Utils-->>Server: Target user ID Server->>Utils: checkIfFollowed() Utils->>Twitter: Check if user is followed Twitter-->>Utils: Follow status Utils-->>Server: Follow status Server->>Client: Follow status else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-like: Check if the tweet has been liked
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /check-like Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfLiked() Utils->>Twitter: Check if tweet has been liked Twitter-->>Utils: Like status Utils-->>Server: Like status Server->>Client: Like status else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-bookmark: Check if the tweet has been bookmarked
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Twitter as Twitter API Client->>Server: GET /check-bookmark Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfBookmarked() Utils->>Twitter: Check if tweet has been bookmarked Twitter-->>Utils: Bookmark status Utils-->>Server: Bookmark status Server->>Client: Bookmark status else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-airdrop: Check the airdrop status for the user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Airdrop as Airdrop System Client->>Server: GET /check-airdrop Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: checkIfClaimedAirdrop() Utils->>Airdrop: Check if airdrop has been claimed Airdrop-->>Utils: Airdrop claim status Utils-->>Server: Airdrop claim status Server->>Client: Airdrop claim status else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /log-airdrop: Log the airdrop for the user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Airdrop as Airdrop System Client->>Server: GET /log-airdrop Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Server: Check if address is provided in query alt Address is provided Server->>Utils: getUserTwitterId() Utils->>Twitter: Request user ID Twitter-->>Utils: User ID Utils-->>Server: User ID Server->>Utils: logUserAirdrop() Utils->>Airdrop: Log airdrop for user Airdrop-->>Utils: Airdrop log status Utils-->>Server: Airdrop log status Server->>Client: Airdrop log status else Address is not provided Server->>Client: Error message: 'Address is required' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-airdrop-amount: Check the airdrop amount for the user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Airdrop as Airdrop System Client->>Server: GET /check-airdrop-amount Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Server: Check if address and step are provided in query alt Address and step are provided Server->>Utils: checkIfPurchased() Utils->>Airdrop: Check if user has purchased Airdrop-->>Utils: Purchase status Utils-->>Server: Purchase status alt User has not purchased Server->>Server: Check if promotion code is provided alt Promotion code is provided Server->>Utils: usePromotionCode() Utils->>Airdrop: Apply promotion code Airdrop-->>Utils: Promotion code status Utils-->>Server: Promotion code status Server->>Airdrop: POST /set_airdrop Airdrop-->>Server: Airdrop set response Server->>Client: Airdrop set response else Promotion code is not provided Server->>Client: Error message: 'Promotion code is required' end else User has purchased Server->>Airdrop: POST /set_airdrop Airdrop-->>Server: Airdrop set response Server->>Client: Airdrop set response end else Address or step are not provided Server->>Client: Error message: 'Address and step are required' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /generate-promotion-code: Generate promotion code for the parent user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils Client->>Server: GET /generate-promotion-code Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Server: Check if address is provided in query alt Address is provided Server->>Utils: getUserTwitterId() Utils-->>Server: User ID Server->>Utils: checkIfFinished() Utils-->>Server: Check result alt User has completed all required steps Server->>Utils: generatePromotionCode() Utils-->>Server: Promotion code alt Promotion code is generated Server->>Client: Promotion code else Failed to generate promotion code Server->>Client: Error message: 'Failed to generate promotion code' end else User has not completed all required steps Server->>Client: Check result end else Address is not provided Server->>Client: Error message: 'Address is required' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /send-airdrop-parent: Send airdrop to the parent user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils participant Airdrop as Airdrop System Client->>Server: GET /send-airdrop-parent Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Server: Check if address is provided in query alt Address is provided Server->>Utils: rewardParentUser() Utils-->>Server: Parent address Server->>Utils: checkRewardParentUser() Utils-->>Server: Append amount and reward status alt Reward is available Server->>Airdrop: POST /append_airdrop Airdrop-->>Server: Airdrop append response Server->>Utils: appendRewardParentUser() Utils-->>Server: Total reward amount Server->>Client: Airdrop append response else Reward is not available Server->>Client: Reward status end else Address is not provided Server->>Client: Error message: 'Address is required' end else Session does not exist or does not have access tokens Server->>Client: Error message end
-
GET /check-purchase: Check if the user has purchased the $Lotso 1st generation token
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils Client->>Server: GET /check-purchase Server->>Server: Check if session exists and has access tokens alt Session exists and has access tokens Server->>Server: Check if address is provided in query alt Address is provided Server->>Utils: checkIfPurchased() Utils-->>Server: Purchase status Server->>Client: Purchase status else Address is not provided Server->>Client: Error message: 'Address is required' end else Session does not exist or does not have access tokens Server->>Client: Error message: 'Authentication required' end
-
GET /subscription-info: Log the subscription information for the user
sequenceDiagram participant Client as Client participant Server as Server participant Utils as Utils Client->>Server: GET /subscription-info Server->>Server: Check if email is provided in query alt Email is provided Server->>Utils: logSubscriptionInfo() Utils-->>Server: Log status alt Log is successful Server->>Client: Log status else Log is not successful Server->>Client: Error message: 'Failed to log subscription info' end else Email is not provided Server->>Client: Error message: 'Email is required' end
-
GET /v1/info/recipient_info: Get the number and amount of recipients for the airdrop
sequenceDiagram participant Client as Client participant Server as Server participant API as Airdrop Server Client->>Server: GET /v1/info/recipient_info Note over Server: Endpoint hit: /v1/info/recipient_info Server->>API: fetch(recipientCheckAddress) API-->>Server: Returns JSON data alt Successful API Call Server-->>Client: Returns JSON data (status 200) else Failed API Call Note over Server: Failed to get recipients count Server-->>Client: Returns error message (status 500) end