routes

package
v0.0.0-...-a6fb04e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: GPL-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SECRETKEY = []byte(cfg.SecretKey)

Functions

func AddClient

func AddClient(c *websocket.Conn)

Function to add a client to the list

func CheckTagStrings

func CheckTagStrings(db *gorm.DB, submittedList []string) ([]models.Tag, *string)

func CreatePaymentIntent

func CreatePaymentIntent(db *gorm.DB, user models.User, plan *models.SubscriptionPlan, paymentToken *string, coin *models.Coin, quantity int) (*models.Transaction, *utils.ErrorResponse)

func DecodeAccessToken

func DecodeAccessToken(token string, db *gorm.DB) (*models.User, *string)

func DecodeJSONBody

func DecodeJSONBody(c *fiber.Ctx, dst interface{}) (int, *utils.ErrorResponse)

func DecodeRefreshToken

func DecodeRefreshToken(token string) bool

func GenerateAccessToken

func GenerateAccessToken(userId uuid.UUID) string

func GenerateRefreshToken

func GenerateRefreshToken() string

func GenerateUsername

func GenerateUsername(db *gorm.DB, firstName string, lastName string, username *string) string

func GetBaseReferer

func GetBaseReferer(c *fiber.Ctx) string

func GetQueryValue

func GetQueryValue(c *fiber.Ctx, key string) *string

func GetUser

func GetUser(token string, db *gorm.DB) (*models.User, *string)

func HealthCheck

func HealthCheck(c *fiber.Ctx) error

@Summary HealthCheck @Description This endpoint checks the health of our application. @Tags HealthCheck @Success 200 {object} HealthCheckSchema @Router /healthcheck [get]

func IsAmongContractStatus

func IsAmongContractStatus(target string) bool

func IsAmongUserType

func IsAmongUserType(target string) bool

func IsValidPaymentStatus

func IsValidPaymentStatus(s string) bool

func PaginateQueryset

func PaginateQueryset(queryset interface{}, fiberCtx *fiber.Ctx, opts ...int) (*schemas.PaginatedResponseDataSchema, any, *utils.ErrorResponse)

func ParseUUID

func ParseUUID(input string) *uuid.UUID

func RegisterSocialUser

func RegisterSocialUser(db *gorm.DB, email string, name string, avatar *string) (*models.User, *utils.ErrorResponse)

func RemoveClient

func RemoveClient(c *websocket.Conn)

Function to remove a client from the list

func RequestUser

func RequestUser(c *fiber.Ctx) *models.User

func ResponseMessage

func ResponseMessage(message string) schemas.ResponseSchema

func ReturnError

func ReturnError(c *websocket.Conn, errType string, message string, code int, dataOpts ...*map[string]string)

func SendNotificationInSocket

func SendNotificationInSocket(fiberCtx *fiber.Ctx, notification models.Notification, statusOpts ...choices.NotificationStatus) error

func SetupRoutes

func SetupRoutes(app *fiber.App, db *gorm.DB, ws *internetcomputer.WalletService)

func UploadFile

func UploadFile(file *multipart.FileHeader, folder string) string

func ValidateAuth

func ValidateAuth(db *gorm.DB, token string) (*models.User, *string, *string)

func ValidateFormRequest

func ValidateFormRequest(c *fiber.Ctx, data interface{}) (*int, *utils.ErrorResponse)

func ValidateImage

func ValidateImage(c *fiber.Ctx, name string, required bool) (*multipart.FileHeader, *utils.ErrorResponse)

func ValidatePathParams

func ValidatePathParams(c *fiber.Ctx, pathParams map[string]string) (*int, *utils.ErrorResponse)

func ValidatePaymentStatus

func ValidatePaymentStatus(c *fiber.Ctx) (*string, *utils.ErrorResponse)

func ValidateRequest

func ValidateRequest(c *fiber.Ctx, data interface{}) (*int, *utils.ErrorResponse)

func ViewBook

func ViewBook(c *fiber.Ctx, db *gorm.DB, book models.Book) *models.Book

Types

type AccessTokenPayload

type AccessTokenPayload struct {
	UserId uuid.UUID `json:"user_id"`
	jwt.RegisteredClaims
}

type Endpoint

type Endpoint struct {
	DB *gorm.DB
}

func (Endpoint) AddChapter

func (ep Endpoint) AddChapter(c *fiber.Ctx) error

@Summary Add A Chapter to a Book @Description `This endpoint allows a writer to add a chapter to his/her book` @Description `Chapter status: DRAFT, PUBLISHED, TRASH` @Tags Books @Param slug path string true "Book slug" @Param chapter body schemas.ChapterCreateSchema true "Chapter object" @Success 201 {object} schemas.ChapterResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug}/add-chapter [post] @Security BearerAuth

func (Endpoint) AddToWaitlist

func (ep Endpoint) AddToWaitlist(c *fiber.Ctx) error

@Summary Add to Waitlist @Description Adds a user to the waitlist. @Tags Waitlist @Accept json @Produce json @Param data body schemas.AddToWaitlist true "Waitlist data" @Success 200 {object} schemas.WaitlistResponseSchema "Successfully added to waitlist" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 404 {object} utils.ErrorResponse "Invalid Genre ID" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /waitlist [post] @Security BearerAuth

func (Endpoint) AdminAddBookGenre

func (ep Endpoint) AdminAddBookGenre(c *fiber.Ctx) error

@Summary Add Genre @Description Add a new genre to the app. @Tags Admin | Books @Accept json @Produce json @Param data body schemas.GenreAddSchema true "Genre" @Success 201 {object} schemas.ResponseSchema "Genre Added Successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/genres [post] @Security BearerAuth

func (Endpoint) AdminAddBookTag

func (ep Endpoint) AdminAddBookTag(c *fiber.Ctx) error

@Summary Add Tag @Description Add a new tag to the app. @Tags Admin | Books @Accept json @Produce json @Param data body schemas.TagsAddSchema true "Tag" @Success 201 {object} schemas.ResponseSchema "Tag added successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/tags [post] @Security BearerAuth

func (Endpoint) AdminDeleteBookGenre

func (ep Endpoint) AdminDeleteBookGenre(c *fiber.Ctx) error

@Summary Delete Genre @Description Delete a genre. @Tags Admin | Books @Accept json @Produce json @Param slug path string true "Genre slug" @Success 200 {object} schemas.ResponseSchema "Genre Deleted Successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/genres/{slug} [delete] @Security BearerAuth

func (Endpoint) AdminDeleteBookTag

func (ep Endpoint) AdminDeleteBookTag(c *fiber.Ctx) error

@Summary Delete Tag @Description Delete a tag from the app. @Tags Admin | Books @Accept json @Produce json @Param slug path string true "Tag slug" @Success 200 {object} schemas.ResponseSchema "Tag delete successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/tags/{slug} [delete] @Security BearerAuth

func (Endpoint) AdminGetBookContracts

func (ep Endpoint) AdminGetBookContracts(c *fiber.Ctx) error

@Summary List Book Contracts with Pagination @Description Retrieves a list of book contracts with support for pagination and optional filtering based on contract status. @Tags Admin | Books @Accept json @Produce json @Param page query int false "Current Page" default(1) @Param name query string false "Name of the author to filter by" @Param contract_status query string false "status of the contract to filter by" Enums(PENDING, APPROVED, DECLINED, UPDATED) @Success 200 {object} schemas.ContractsResponseSchema "Successfully retrieved list of book contracts" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/contracts [get] @Security BearerAuth

func (Endpoint) AdminGetBooks

func (ep Endpoint) AdminGetBooks(c *fiber.Ctx) error

@Summary List Books with Pagination @Description Retrieves a list of books with support for pagination and optional filtering based on book title. @Tags Admin | Books @Accept json @Produce json @Param page query int false "Current Page" default(1) @Param title query string false "Title of the book to filter by" @Success 200 {object} schemas.BooksResponseSchema "Successfully retrieved list of books" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books [get] @Security BearerAuth

func (Endpoint) AdminGetTransactions

func (ep Endpoint) AdminGetTransactions(c *fiber.Ctx) error

@Summary Latest Transactions with Pagination @Description Retrieves a list of current transactions with support for pagination and optional filtering based on username. @Tags Admin | Payments @Accept json @Produce json @Param username query string false "Username to filter by" @Param page query int false "Current page" default(1) @Success 200 {object} schemas.TransactionsResponseSchema "Successfully retrieved list of transactions" @Failure 400 {object} utils.ErrorResponse "Invalid query parameters" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/payments/transactions [get] @Security BearerAuth

func (Endpoint) AdminGetUsers

func (ep Endpoint) AdminGetUsers(c *fiber.Ctx) error

@Summary List Users with Pagination @Description Retrieves a list of user profiles with support for pagination and optional filtering based on user account type. @Tags Admin | Users @Accept json @Produce json @Param account_type query string false "Type of user to filter by" Enums(READER, WRITER, ADMIN) @Param page query int false "Current page" default(1) @Success 200 {object} schemas.UserProfilesResponseSchema "Successfully retrieved list of user profiles" @Failure 400 {object} utils.ErrorResponse "Invalid query parameters" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/users [get] @Security BearerAuth

func (Endpoint) AdminGetWaitlist

func (ep Endpoint) AdminGetWaitlist(c *fiber.Ctx) error

func (Endpoint) AdminMiddleware

func (ep Endpoint) AdminMiddleware(c *fiber.Ctx) error

func (Endpoint) AdminUpdateBookGenre

func (ep Endpoint) AdminUpdateBookGenre(c *fiber.Ctx) error

@Summary Update Genre @Description Update a genre. @Tags Admin | Books @Accept json @Produce json @Param slug path string true "Genre slug" @Param data body schemas.GenreAddSchema true "Genre" @Success 200 {object} schemas.ResponseSchema "Genre Updated Successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/genres/{slug} [put] @Security BearerAuth

func (Endpoint) AdminUpdateBookTag

func (ep Endpoint) AdminUpdateBookTag(c *fiber.Ctx) error

@Summary Update Tag @Description Update a tag to the app. @Tags Admin | Books @Accept json @Produce json @Param slug path string true "Tag slug" @Param data body schemas.TagsAddSchema true "Tag" @Success 200 {object} schemas.ResponseSchema "Tag updated successfully" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/books/tags/{slug} [put] @Security BearerAuth

func (Endpoint) AdminUpdateUser

func (ep Endpoint) AdminUpdateUser(c *fiber.Ctx) error

@Summary Update User Role @Description Updates the account type of a specified user. @Tags Admin | Users @Accept json @Produce json @Param username path string true "Username" default(username) @Param data body schemas.UpdateUserRoleSchema true "User role update data" @Success 200 {object} schemas.UserProfileResponseSchema "Successfully updated user details" @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 404 {object} utils.ErrorResponse "User not found" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/users/{username} [put] @Security BearerAuth

func (Endpoint) AllUserTransactions

func (ep Endpoint) AllUserTransactions(c *fiber.Ctx) error

@Summary View Current Transactions @Description This endpoint returns all transactions of a user @Tags Wallet @Param page query int false "Current Page" default(1) @Param payment_status query string false "Payment Status" @Success 200 {object} schemas.TransactionsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /wallet/transactions [get] @Security BearerAuth

func (Endpoint) AuthMiddleware

func (ep Endpoint) AuthMiddleware(c *fiber.Ctx) error

func (Endpoint) AuthOrGuestMiddleware

func (ep Endpoint) AuthOrGuestMiddleware(c *fiber.Ctx) error

func (Endpoint) AuthorMiddleware

func (ep Endpoint) AuthorMiddleware(c *fiber.Ctx) error

func (Endpoint) AvailableCoins

func (ep Endpoint) AvailableCoins(c *fiber.Ctx) error

@Summary View Available Coins @Description This endpoint returns all available coins for sale @Tags Wallet @Success 200 {object} schemas.CoinsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /wallet/coins [get]

func (Endpoint) BookSubscription

func (ep Endpoint) BookSubscription(c *fiber.Ctx) error

@Summary Subscribe @Description This endpoint allows a user to create a subscription for books @Tags Wallet @Param subscription body schemas.CreateSubscriptionSchema true "Payment object" @Success 200 {object} schemas.PaymentResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /wallet/subscription [post] @Security BearerAuth

func (Endpoint) BuyABook

func (ep Endpoint) BuyABook(c *fiber.Ctx) error

@Summary Buy An Entire Book @Description This endpoint allows a user to buy an entire book @Tags Books @Param slug path string true "Book slug" @Success 201 {object} schemas.BookResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug}/buy [get] @Security BearerAuth

func (Endpoint) BuyAChapter

func (ep Endpoint) BuyAChapter(c *fiber.Ctx) error

@Summary Buy A Chapter Of A Book @Description `This endpoint allows a user to buy the next chapter of a book.` @Description `It happens in sequence. 1, 2, 3, 4 etc. That means if a user has bought chapter 2 before. This endpoint will buy chapter 3` @Tags Books @Param slug path string true "Book slug" @Success 201 {object} schemas.BookResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug}/buy-chapter [get] @Security BearerAuth

func (Endpoint) BuyCoins

func (ep Endpoint) BuyCoins(c *fiber.Ctx) error

@Summary Buy Coins @Description This endpoint allows a user to buy coins @Tags Wallet @Param coin body schemas.BuyCoinSchema true "Payment object" @Success 200 {object} schemas.PaymentResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /wallet/coins [post] @Security BearerAuth

func (Endpoint) ClaimGift

func (ep Endpoint) ClaimGift(c *fiber.Ctx) error

@Summary Claim Gift @Description This endpoint allows a writer to claim a gift @Tags Gifts @Param id path string true "ID of the sent gift (uuid)" @Success 200 {object} schemas.SentGiftResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /gifts/sent/{id}/claim [get] @Security BearerAuth

func (Endpoint) ConvertCoinsToLanterns

func (ep Endpoint) ConvertCoinsToLanterns(c *fiber.Ctx) error

@Summary Convert Coins To Lanterns @Description This endpoint allows a user to convert coins to lanterns @Tags Books @Param amount path int true "Amount to convert" @Success 200 {object} schemas.ResponseSchema @Failure 404 {object} utils.ErrorResponse @Failure 400 {object} utils.ErrorResponse @Router /books/lanterns-generation/{amount} [get] @Security BearerAuth

func (Endpoint) CreateBook

func (ep Endpoint) CreateBook(c *fiber.Ctx) error

@Summary Create A Book @Description This endpoint allows a writer to create a book @Tags Books @Param book formData schemas.BookCreateSchema true "Book object" @Param cover_image formData file true "Cover Image to upload" @Success 201 {object} schemas.BookResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books [post] @Security BearerAuth

func (Endpoint) DeleteBook

func (ep Endpoint) DeleteBook(c *fiber.Ctx) error

@Summary Delete A Book @Description This endpoint allows a writer to delete a book @Tags Books @Param slug path string true "Book slug" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug} [delete] @Security BearerAuth

func (Endpoint) DeleteBookReview

func (ep Endpoint) DeleteBookReview(c *fiber.Ctx) error

@Summary Delete Book Review @Description `This endpoint allows a user to delete his/her book review.` @Tags Books @Param id path string true "Review id (uuid)" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/{id} [delete] @Security BearerAuth

func (Endpoint) DeleteChapter

func (ep Endpoint) DeleteChapter(c *fiber.Ctx) error

@Summary Delete A Chapter @Description This endpoint allows a writer to delete a chapter from a book @Tags Books @Param slug path string true "Chapter slug" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/chapter/{slug} [delete] @Security BearerAuth

func (Endpoint) DeleteReply

func (ep Endpoint) DeleteReply(c *fiber.Ctx) error

@Summary Delete A Reply @Description `This endpoint allows a user to delete his/her reply` @Tags Books @Param id path string true "Reply id (uuid)" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/replies/{id} [delete] @Security BearerAuth

func (Endpoint) EditBookReview

func (ep Endpoint) EditBookReview(c *fiber.Ctx) error

@Summary Edit Book Review @Description `This endpoint allows a user to edit his/her book review.` @Tags Books @Param id path string true "Review id (uuid)" @Param review body schemas.ReviewBookSchema true "Review object" @Success 200 {object} schemas.ReviewResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/{id} [put] @Security BearerAuth

func (Endpoint) EditReply

func (ep Endpoint) EditReply(c *fiber.Ctx) error

@Summary Edit A Reply @Description `This endpoint allows a user to edit his/her reply` @Tags Books @Param id path string true "Reply id (uuid)" @Param review body schemas.ReplyReviewSchema true "Reply object" @Success 200 {object} schemas.ReplyResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/replies/{id} [put] @Security BearerAuth

func (Endpoint) FacebookLogin

func (ep Endpoint) FacebookLogin(c *fiber.Ctx) error

@Summary Login a user via facebook @Description `This endpoint generates new access and refresh tokens for authentication via facebook` @Description `Pass in token gotten from facebook client authentication here in payload to retrieve tokens for authorization` @Tags Auth @Param user body schemas.SocialLoginSchema true "User login" @Success 201 {object} schemas.LoginResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /auth/facebook [post]

func (Endpoint) FollowUser

func (ep Endpoint) FollowUser(c *fiber.Ctx) error

@Summary Toggle Follow Status @Description `This endpoint allows a user to follow or unfollow a writer`. @Tags Profiles @Param username path string true "Username of the user to follow or unfollow" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse "Returns an error for invalid request parameters." @Failure 403 {object} utils.ErrorResponse "Returns an error when trying to follow a user that isn't a writer" @Failure 404 {object} utils.ErrorResponse "Returns an error when either the user to follow or the follower user does not exist." @Failure 500 {object} utils.ErrorResponse "Returns an error when there is an internal server error or a transaction fails." @Router /profiles/profile/{username}/follow [get] @Security BearerAuth

func (Endpoint) GetAllBookGenres

func (ep Endpoint) GetAllBookGenres(c *fiber.Ctx) error

@Summary View Available Book Genres @Description This endpoint views available book genres @Tags Books @Success 200 {object} schemas.GenresResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/genres [get]

func (Endpoint) GetAllBookTags

func (ep Endpoint) GetAllBookTags(c *fiber.Ctx) error

@Summary View Available Book Tags @Description This endpoint views available book tags @Tags Books @Success 200 {object} schemas.TagsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/tags [get]

func (Endpoint) GetAllGifts

func (ep Endpoint) GetAllGifts(c *fiber.Ctx) error

@Summary View All Available Gifts @Description This endpoint shows a user gifts that can be sent @Tags Gifts @Success 200 {object} schemas.GiftsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /gifts [get]

func (Endpoint) GetAllSentGifts

func (ep Endpoint) GetAllSentGifts(c *fiber.Ctx) error

@Summary View All Gifts Sent To A Writer @Description This endpoint allows a writer to view all gifts that was sent to him/her @Tags Gifts @Param page query int false "Current Page" default(1) @Param claimed query string false "Filter by claimed value: CLAIMED or NOT_CLAIMED " @Success 200 {object} schemas.SentGiftsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /gifts/sent [get] @Security BearerAuth

func (Endpoint) GetBookChapters

func (ep Endpoint) GetBookChapters(c *fiber.Ctx) error

@Summary View Book Chapters @Description `This endpoint views chapters of a book` @Description `A Guest user will view just the first chapter` @Description `An Authenticated user will view all the chapters he has bought` @Description `The owner will view all chapters of the book` @Tags Books @Param slug path string true "Get Chapter by Book Slug" @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ChaptersResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug}/chapters [get] @Security BearerAuth

func (Endpoint) GetBoughtBooks

func (ep Endpoint) GetBoughtBooks(c *fiber.Ctx) error

@Summary View Bought Books @Description This endpoint returns all books in which a user has bought at least a chapter @Tags Books @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.BooksResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/bought [get] @Security BearerAuth

func (Endpoint) GetLatestAuthorBooks

func (ep Endpoint) GetLatestAuthorBooks(c *fiber.Ctx) error

@Summary View Latest Books By A Particular Author @Description This endpoint views a latest books by an author @Tags Books @Param page query int false "Current Page" default(1) @Param username path string true "Filter by Author Username" @Param genre_slug query string false "Filter by Genre slug" @Param tag_slug query string false "Filter by Tag slug" @Success 200 {object} schemas.BooksResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/author/{username} [get]

func (Endpoint) GetLatestBooks

func (ep Endpoint) GetLatestBooks(c *fiber.Ctx) error

@Summary View Latest Books @Description This endpoint views a latest books @Tags Books @Param page query int false "Current Page" default(1) @Param genre_slug query string false "Filter by Genre slug" @Param tag_slug query string false "Filter by Tag slug" @Success 200 {object} schemas.BooksResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books [get]

func (Endpoint) GetNotifications

func (ep Endpoint) GetNotifications(c *fiber.Ctx) error

@Summary View Notifications @Description This endpoint allows a user to view his/her notificatios @Tags Profiles @Success 200 {object} schemas.NotificationsResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /profiles/notifications [get] @Security BearerAuth

func (Endpoint) GetProfile

func (ep Endpoint) GetProfile(c *fiber.Ctx) error

@Summary View User Profile @Description This endpoint views a user profile @Tags Profiles @Param username path string true "Username of user" @Success 200 {object} schemas.UserProfileResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /profiles/profile/{username} [get]

func (Endpoint) GetReviewReplies

func (ep Endpoint) GetReviewReplies(c *fiber.Ctx) error

@Summary Get Review Replies @Description `This endpoint returns replies of a book review.` @Tags Books @Param id path string true "Review id (uuid)" @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.RepliesResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/{id}/replies [get]

func (Endpoint) GetSingleBook

func (ep Endpoint) GetSingleBook(c *fiber.Ctx) error

@Summary View Single Book @Description This endpoint views a single book @Tags Books @Param page query int false "Current Page (for reviews pagination)" default(1) @Param slug path string true "Book slug" @Success 200 {object} schemas.BookDetailResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug} [get]

func (Endpoint) GetSiteDetails

func (ep Endpoint) GetSiteDetails(c *fiber.Ctx) error

@Summary Retrieve site details @Description This endpoint retrieves few details of the site/application. @Tags General @Success 200 {object} schemas.SiteDetailResponseSchema @Router /general/site-detail [get]

func (Endpoint) GetSubscriptionPlans

func (ep Endpoint) GetSubscriptionPlans(c *fiber.Ctx) error

@Summary List Available Subscription Plans @Description Retrieves a list of available subscription plans. @Tags Wallet @Accept json @Produce json @Success 200 {object} schemas.SubscriptionPlansResponseSchema "Successfully retrieved list of plans" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /wallet/plans [get]

func (Endpoint) GoogleLogin

func (ep Endpoint) GoogleLogin(c *fiber.Ctx) error

@Summary Login a user via google @Description `This endpoint generates new access and refresh tokens for authentication via google` @Description `Pass in token gotten from gsi client authentication here in payload to retrieve tokens for authorization` @Tags Auth @Param user body schemas.SocialLoginSchema true "User login" @Success 201 {object} schemas.LoginResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /auth/google [post]

func (Endpoint) Login

func (ep Endpoint) Login(c *fiber.Ctx) error

@Summary Login a user @Description This endpoint generates new access and refresh tokens for authentication @Tags Auth @Param user body schemas.LoginSchema true "User login" @Success 201 {object} schemas.LoginResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /auth/login [post]

func (Endpoint) Logout

func (ep Endpoint) Logout(c *fiber.Ctx) error

@Summary Logout a user @Description This endpoint logs a user out from our application @Tags Auth @Success 200 {object} schemas.ResponseSchema @Failure 401 {object} utils.ErrorResponse @Router /auth/logout [get] @Security BearerAuth

func (Endpoint) NotificationSocket

func (ep Endpoint) NotificationSocket(c *websocket.Conn)

func (Endpoint) ReadNotification

func (ep Endpoint) ReadNotification(c *fiber.Ctx) error

@Summary Read Notification @Description This endpoint allows a user to read his/her notification. @Tags Profiles @Param notification body schemas.ReadNotificationSchema true "Notification Read object" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /profiles/notifications/read [post] @Security BearerAuth

func (Endpoint) Refresh

func (ep Endpoint) Refresh(c *fiber.Ctx) error

@Summary Refresh tokens @Description This endpoint refresh tokens by generating new access and refresh tokens for a user @Tags Auth @Param refresh body schemas.RefreshTokenSchema true "Refresh token" @Success 201 {object} schemas.LoginResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /auth/refresh [post]

func (Endpoint) Register

func (ep Endpoint) Register(c *fiber.Ctx) error

@Summary Register a new user @Description `This endpoint registers new users into our application.` @Tags Auth @Param user body schemas.RegisterUser true "User data" @Success 201 {object} schemas.RegisterResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/register [post]

func (Endpoint) ReplyReview

func (ep Endpoint) ReplyReview(c *fiber.Ctx) error

@Summary Reply A Review @Description `This endpoint allows a user to reply a book review.` @Tags Books @Param id path string true "Review id (uuid)" @Param review body schemas.ReplyReviewSchema true "Reply object" @Success 201 {object} schemas.ReplyResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/review/{id}/replies [post] @Security BearerAuth

func (Endpoint) ResendVerificationEmail

func (ep Endpoint) ResendVerificationEmail(c *fiber.Ctx) error

@Summary Resend Verification Email @Description `This endpoint resends new otp to the user's email.` @Tags Auth @Param email body schemas.EmailRequestSchema true "Email data" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/resend-verification-email [post]

func (Endpoint) ReviewBook

func (ep Endpoint) ReviewBook(c *fiber.Ctx) error

@Summary Review A Book @Description `This endpoint allows a user to review a book.` @Description `The author cannot review his own book.` @Description `Only the reader who has bought the book can review the book.` @Description `A reader cannot add multiple reviews to a book.` @Tags Books @Param slug path string true "Book slug" @Param review body schemas.ReviewBookSchema true "Review object" @Success 201 {object} schemas.ReviewResponseSchema @Failure 404 {object} utils.ErrorResponse @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug} [post] @Security BearerAuth

func (Endpoint) SendGift

func (ep Endpoint) SendGift(c *fiber.Ctx) error

@Summary Send Gift @Description This endpoint allows a user to send a gift @Tags Gifts @Param username path string true "Username of the writer" @Param gift_slug path string true "Slug of the gift being sent" @Success 201 {object} schemas.SentGiftResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /gifts/{username}/{gift_slug}/send/ [get] @Security BearerAuth

func (Endpoint) SendPasswordResetOtp

func (ep Endpoint) SendPasswordResetOtp(c *fiber.Ctx) error

@Summary Send Password Reset Link @Description `This endpoint sends new password reset link to the user's email.` @Tags Auth @Param email body schemas.EmailRequestSchema true "Email object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /auth/send-password-reset-otp [post]

func (Endpoint) SetContract

func (ep Endpoint) SetContract(c *fiber.Ctx) error

@Summary Set Contract @Description `This endpoint allows a user to create/update a contract for his/her book` @Tags Books @Param slug path string true "Book slug" @Param contract formData schemas.ContractCreateSchema true "Contract object" @Param id_front_image formData file false "Front Image of your id" @Param id_back_image formData file false "Back Image of your id" @Success 200 {object} schemas.ContractResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /books/book/{slug}/set-contract [post] @Security BearerAuth

func (Endpoint) SetNewPassword

func (ep Endpoint) SetNewPassword(c *fiber.Ctx) error

@Summary Set New Password @Description `This endpoint verifies the password reset token and set new password.` @Tags Auth @Param email body schemas.SetNewPasswordSchema true "Password reset object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /auth/set-new-password [post]

func (Endpoint) Subscribe

func (ep Endpoint) Subscribe(c *fiber.Ctx) error

@Summary Add a subscriber @Description This endpoint creates a newsletter subscriber in our application @Tags General @Param subscriber body models.Subscriber true "Subscriber object" @Success 201 {object} schemas.SubscriberResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /general/subscribe [post]

func (Endpoint) ToggleUserActivation

func (ep Endpoint) ToggleUserActivation(c *fiber.Ctx) error

@Summary Reactivate/Deactivate User @Description Allows the admin to deactivate/reactivate a user. @Tags Admin | Users @Param username path string true "Username" default(username) @Accept json @Produce json @Failure 400 {object} utils.ErrorResponse "Invalid request data" @Failure 404 {object} utils.ErrorResponse "User not found" @Failure 500 {object} utils.ErrorResponse "Internal server error" @Router /admin/users/{username}/toggle-activation [get] @Security BearerAuth

func (Endpoint) UpdateBook

func (ep Endpoint) UpdateBook(c *fiber.Ctx) error

@Summary Update A Book @Description This endpoint allows a writer to update a book @Tags Books @Param slug path string true "Book slug" @Param book formData schemas.BookCreateSchema true "Book object" @Param cover_image formData file false "Cover Image to upload" @Success 200 {object} schemas.BookResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug} [put] @Security BearerAuth

func (Endpoint) UpdateChapter

func (ep Endpoint) UpdateChapter(c *fiber.Ctx) error

@Summary Update A Chapter of a Book @Description `This endpoint allows a writer to update a chapter in his/her book` @Description `Chapter status: DRAFT, PUBLISHED, TRASH` @Tags Books @Param slug path string true "Chapter slug" @Param chapter body schemas.ChapterCreateSchema true "Chapter object" @Success 200 {object} schemas.ChapterResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /books/book/chapter/{slug} [put] @Security BearerAuth

func (Endpoint) UpdatePassword

func (ep Endpoint) UpdatePassword(c *fiber.Ctx) error

@Summary Update User Password @Description This endpoint updates a user's password @Tags Profiles @Param profile body schemas.UpdatePasswordSchema true "Password object" @Success 200 {object} schemas.ResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /profiles/update-password [put] @Security BearerAuth

func (Endpoint) UpdateProfile

func (ep Endpoint) UpdateProfile(c *fiber.Ctx) error

@Summary Update User Profile @Description This endpoint updates a user's profile @Tags Profiles @Param profile body schemas.UpdateUserProfileSchema true "Profile object" @Success 200 {object} schemas.UserProfileResponseSchema @Failure 400 {object} utils.ErrorResponse @Router /profiles/update [patch] @Security BearerAuth

func (Endpoint) UpdateSubscriptionPlan

func (ep Endpoint) UpdateSubscriptionPlan(c *fiber.Ctx) error

@Summary Update A Plan Amount @Description This endpoint allows an admin to change the amount of a plan @Tags Wallet @Param plan body schemas.SubscriptionPlanSchema true "Plan data" @Success 200 {object} schemas.SubscriptionPlanResponseSchema @Failure 400 {object} utils.ErrorResponse @Failure 422 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /wallet/plans [put] @Security BearerAuth

func (Endpoint) VerifyEmail

func (ep Endpoint) VerifyEmail(c *fiber.Ctx) error

@Summary Verify a user's email @Description `This endpoint verifies a user's email.` @Tags Auth @Param verify_email body schemas.VerifyEmailRequestSchema true "Verify Email object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/verify-email [post]

func (Endpoint) VerifyPasswordResetToken

func (ep Endpoint) VerifyPasswordResetToken(c *fiber.Ctx) error

@Summary Check Password Reset Token Validity @Description `This endpoint checks the validity of a password reset token.` @Tags Auth @Param token_string path string true "Token string" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /auth/verify-password-reset-token/{token_string} [get]

func (Endpoint) VerifyPayment

func (ep Endpoint) VerifyPayment(c *fiber.Ctx) error

func (Endpoint) VoteBook

func (ep Endpoint) VoteBook(c *fiber.Ctx) error

@Summary Vote A Book @Description This endpoint allows a user to vote a book @Tags Books @Param slug path string true "Book slug" @Success 200 {object} schemas.ResponseSchema @Failure 404 {object} utils.ErrorResponse @Failure 400 {object} utils.ErrorResponse @Router /books/book/{slug}/vote [get] @Security BearerAuth

type ErrorResp

type ErrorResp struct {
	Status  string             `json:"status"`
	Code    int                `json:"code"`
	Type    string             `json:"type"`
	Message string             `json:"message"`
	Data    *map[string]string `json:"data,omitempty"`
}

type FacebookPayload

type FacebookPayload struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

FACEBOOK

func ConvertFacebookToken

func ConvertFacebookToken(accessToken string) (*FacebookPayload, *utils.ErrorResponse)

type GooglePayload

type GooglePayload struct {
	SUB           string `json:"sub"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	Locale        string `json:"locale"`
}

Social Auth GOOGLE

func ConvertGoogleToken

func ConvertGoogleToken(accessToken string) (*GooglePayload, *utils.ErrorResponse)

type HealthCheckSchema

type HealthCheckSchema struct {
	Success string `json:"success" example:"pong"`
}

type RefreshTokenPayload

type RefreshTokenPayload struct {
	Data string `json:"data"`
	jwt.RegisteredClaims
}

type SocketNotificationSchema

type SocketNotificationSchema struct {
	schemas.NotificationSchema
	Status choices.NotificationStatus `json:"status"`
}

func (SocketNotificationSchema) Init

type WalletService

type WalletService struct {
	WS *internetcomputer.WalletService
	DB *gorm.DB
}

func (WalletService) GetOnChainBalance

func (ws WalletService) GetOnChainBalance(c *fiber.Ctx) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL