handler

package
v0.0.0-...-5b6618e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAssetDir = "./assets"

Functions

func AssignAdminToOrganization

func AssignAdminToOrganization(c echo.Context) error

AssignAdminToOrganization godoc

@Summary		Add admin to organization
@Description	Assign organization to an admin. Just super admins can do it.
@Tags			organization
@Accept			json
@Produce		json
@Param			org_id	path		string	true	"Organization Path"
@Param			user_id	path		string	true	"User ID"
@Success		200		{object}	util.Response
@Failure		400		{object}	util.ResponseError
@Failure		500		{object}	util.ResponseError

@Router			/organization/hire-admin/{org_id}/{user_id} [POST]

func CreateAdmin

func CreateAdmin(c echo.Context) error

CreateAdmin godoc

@Summary		Create new admin
@Description	Just super admins can create a new admin
@Tags			admin
@Accept			json
@Produce		json
@Param			username	body		string	true	"Username"
@Param			password	body		string	true	"Password"
@Param			email		body		string	true	"Email"
@Success		200			{object}	util.Response
@Failure		400			{object}	util.Response
@Failure		409			{object}	util.ResponseError"
@Failure		500			{object}	util.ResponseError"

@Router			/admin/new [POST]

func CreateOrganization

func CreateOrganization(c echo.Context) error

CreateOrganization godoc

@Summary		Create Organization
@Description	Super admins can create organization
@Tags			organization
@Accept			json
@Produce		json

@Param			name			body		string	false	"Name"
@Param			address			body		string	false	"Address"
@Param			phone_number	body		string	false	"Phone number"
@Param			website_url		body		string	false	"Website URL"

@Success		200				{object}	util.Response
@Failure		400				{object}	util.ResponseError
@Failure		409				{object}	util.ResponseError"
@Failure		500				{object}	util.ResponseError"

@Router			/organization/new [POST]

func DeleteOrganization

func DeleteOrganization(c echo.Context) error

DeleteOrganization godoc

@Summary		Delete Organization
@Description	Super admin can delete an organization.
@Tags			organization
@Accept			json
@Produce		json
@Param			id	path		string	true	"Organization ID"
@Success		200	{object}	util.Response
@Failure		400	{object}	util.ResponseError
@Failure		404	{object}	util.ResponseError
@Failure		500	{object}	util.ResponseError

@Router			/organization/{id} [DELETE]

func DeleteUser

func DeleteUser(c echo.Context) error

DeleteUser godoc

@Summary		Delete a user or admin
@Description	Super admin can delete users and admins.
@Description	Super admin can'n remove super admins/
@Description	Admins can't remove another admins or users.
@Tags			user
@Accept			json
@Produce		json
@Param			id	path		int	true	"User ID"
@Success		200	{object}	util.Response
@Failure		400	{object}	util.ResponseError
@Failure		409	{object}	util.ResponseError"
@Failure		500	{object}	util.ResponseError"

@Router			/user/{id} [DELETE]

func EditOrganization

func EditOrganization(c echo.Context) error

EditOrganization godoc

@Summary		Edit organization
@Description	Admins can edit organizations information.
@Tags			organization
@Accept			json
@Produce		json
@Param			name			body		string	false	"Name"
@Param			address			body		string	false	"Address"
@Param			phone_number	body		string	false	"Phone number"
@Param			website_url		body		string	false	"Website URL"
@Success		200				{object}	util.Response
@Failure		400				{object}	util.ResponseError
@Failure		401				{object}	util.ResponseError
@Failure		404				{object}	util.ResponseError
@Failure		500				{object}	util.ResponseError

@Router			/organization/{id} [PUT]

func EditUser

func EditUser(c echo.Context) error

EditUser godoc

@Summary		Edit uer
@Description	Super admin can edit every normal admin.
@Description	User and admin can edit hisself. But cannot change his role.
@Tags			user
@Accept			json
@Produce		json
@Param			id			path		int		true	"User ID"
@Param			username	body		string	false	"Username"
@Param			password	body		string	false	"Password"
@Param			email		body		string	false	"Email"
@Param			role		body		string	false	"User role (super_admin|admin|user)"
@Success		200			{object}	util.Response
@Failure		400			{object}	util.ResponseError
@Failure		409			{object}	util.ResponseError"
@Failure		500			{object}	util.ResponseError"

@Router			/admin/{id} [PUT]

func GetAllOrganizations

func GetAllOrganizations(c echo.Context) error

GetAllOrganizations godoc

@Summary		List all organizations
@Description	Response every registred organization.
@Tags			organization
@Accept			json
@Produce		json
@Success		200	{object}	util.Response
@Failure		400	{object}	util.ResponseError

@Router			/organization/all [GET]

func GetAllTickets

func GetAllTickets(c echo.Context) error

GetAllTickets godoc

@Summary		Get tickets by priviledge
@Description	If you are a user you can see your tickets about an organization.
@Description	If you are an admin you can see tickets of all users for allorganizations.
@Tags			ticket
@Accept			json
@Produce		json
@Param			org_id	path		int	true	"Organization ID"
@Success		200		{object}	util.Response
@Failure		400		{object}	util.ResponseError

@Router			/ticket/{org_id} [GET]

func GetUser

func GetUser(c echo.Context) error

GetUser godoc

@Summary		Fetch user by ID
@Description	Fetch user by ID
@Tags			user
@Accept			json
@Produce		json
@Success		200	{object}	util.Response
@Failure		409	{object}	util.ResponseError"
@Failure		500	{object}	util.ResponseError"
@Failure		400	{object}	util.ResponseError

@Router			/user/{id} [GET]

func GetUserProfile

func GetUserProfile(c echo.Context) error

GetUserProfile godoc

@Summary		Get user profile
@Description	Fetch information of loggedin user
@Tags			user
@Accept			json
@Produce		json
@Success		200	{object}	util.Response
@Failure		400	{object}	util.ResponseError
@Failure		409	{object}	util.ResponseError"
@Failure		500	{object}	util.ResponseError"

@Router			/user/profile [GET]

func Login

func Login(c echo.Context) error

Login godoc

@Summary		Login user
@Description	Check user&pass and util.Response JWT Token
@Tags			user
@Accept			json
@Produce		json
@Param			password	body		string	true	"Password"
@Param			email		body		string	true	"Email"
@Success		200			{object}	util.Response
@Failure		400			{object}	util.ResponseError
@Failure		401			{object}	util.ResponseError

@Router			/login [POST]

func PromoteAdmin

func PromoteAdmin(c echo.Context) error

PromoteAdmin godoc

@Summary		Promote admin to super user
@Description	Super admin can convert an admin to super admin.
@Tags			admin
@Accept			json
@Produce		json
@Param			id	path		int	true	"User ID"
@Success		200	{object}	util.Response
@Failure		400	{object}	util.ResponseError

@Router			/admin/promote/{id} [POST]

func Register

func Register(c echo.Context) error

Register godoc

@Summary		Register user
@Description	Create user on database based on body.
@Tags			user
@Accept			json
@Produce		json
@Param			username	body		string	true	"Username"
@Param			password	body		string	true	"Password"
@Param			email		body		string	true	"Email"
@Success		200			{object}	util.Response
@Failure		400			{object}	util.ResponseError"
@Failure		409			{object}	util.ResponseError"
@Failure		500			{object}	util.ResponseError"

@Router			/register [POST]

func ReplyToTicket

func ReplyToTicket(c echo.Context) error

ReplyToTicket godoc

@Summary		Admin can reply to a ticket
@Description	Admins can reply to his organization tickets.
@Description	Super Admins can reply to every ticket.
@Tags			organization
@Accept			json
@Produce		json
@Param			id		path		int	true	"Ticket ID"
@Param			subject	body		int	true	"Email subject"
@Param			body	body		int	true	"Email body"
@Success		200		{object}	util.Response
@Failure		400		{object}	util.ResponseError

@Router			/ticket/{id}/mail [POST]

func SendTicket

func SendTicket(c echo.Context) error

SendTicket godoc

@Summary		Create and send ticket to organization
@Description	Just admins can reply it though email.
@Tags			ticket
@Accept			json
@Produce		json
@Param			org_id			path		int		true	"Organization ID"
@Param			title			body		string	true	"Title"
@Param			body			body		string	true	"Body"
@Param			attachment_url	body		string	false	"Attachment Url"
@Param			website_url		body		string	false	"website Url"
@Success		200				{object}	util.Response
@Failure		400				{object}	util.ResponseError

@Router			/ticket/:org_id [POST]

func SetDB

func SetDB(externalDb *gorm.DB)

func UploadAsset

func UploadAsset(c echo.Context) error

UploadAsset godoc

@Summary		Upload asset for tickets
@Description	Users can upload asset and attach it's url to their tickets
@Tags			ticket
@Accept			json
@Produce		json
@Param			is_image	query		string	false	"flag for check images"
@Param			asset		formData	string	true	"asset"
@Success		200			{object}	util.Response
@Failure		400			{object}	util.ResponseError
@Failure		500			{object}	util.ResponseError

@Router			/ticket/assets [POST]

Types

This section is empty.

Jump to

Keyboard shortcuts

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