server

package
v0.0.0-...-26726ad Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OrderStatus

func OrderStatus(order database.Order) string

func Run

func Run(port, host, certFile, keyFile, email, telegram, bestchangeLink string, e *echo.Echo, p *pgxpool.Pool, d *database.Queries, b *bestchange.Client, mail *email.Mailer, bot *bot.Bot)

Types

type ApproveCardConfirmationRequest

type ApproveCardConfirmationRequest struct {
	ConfirmationID int64 `json:"confirmation_id"`
}

type Balance

type Balance struct {
	ID          int64   `json:"id"`
	Code        string  `json:"code"`
	Description string  `json:"description"`
	Address     string  `json:"address"`
	Balance     float64 `json:"balance"`
}

type Balances

type Balances struct {
	Balances []Balance `json:"balances"`
}

type Busy

type Busy struct {
	Busy bool `json:"busy"`
}

type CancelCardRequest

type CancelCardRequest struct {
	ConfirmationID int64 `json:"confirmation_id"`
}

type CancelOrderRequest

type CancelOrderRequest struct {
	OrderID int64 `json:"order_id"`
}

type CardConfirmationsResponse

type CardConfirmationsResponse struct {
	Confirmations []database.CardConfirmation `json:"confirmations"`
}

type ChatMessage

type ChatMessage struct {
	Outgoing bool   `json:"outgoing"`
	Message  string `json:"message"`
	Time     string `json:"time"`
}

type ChatMessages

type ChatMessages struct {
	Messages []ChatMessage `json:"messages"`
}

type ChatUUID

type ChatUUID struct {
	UUID string `json:"uuid"`
}

type CreateBalanceRequest

type CreateBalanceRequest struct {
	CurrencyID int64   `json:"currency_id"`
	Balance    float64 `json:"balance"`
	Address    string  `json:"address"`
}

type CreateExchangerRequest

type CreateExchangerRequest struct {
	Description        string  `json:"description"`
	Inmin              float64 `json:"inmin"`
	PaymentVerfication bool    `json:"payment_verification"`
	InCurrency         string  `json:"in_currency"`
	OutCurrency        string  `json:"out_currency"`
}

type CreateOrderRequest

type CreateOrderRequest struct {
	Email          string  `json:"email"`
	InCurrency     string  `json:"in_currency"`
	OutCurrency    string  `json:"out_currency"`
	Amount         float64 `json:"amount"`
	PaymentAddress string  `json:"payment_address"`
	Address        string  `json:"address"`
}

type CreateOrderResponse

type CreateOrderResponse struct {
	InAmount        float64 `json:"in_amount"`
	OutAmount       float64 `json:"out_amount"`
	TransferAddress string  `json:"transfer_address"`
	OrderNumber     int64   `json:"order_number"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type Currencies

type Currencies struct {
	Currencies []database.Currency `json:"currencies"`
}

type CurrentRateResponse

type CurrentRateResponse struct {
	Amount    float64 `json:"amount"`
	Rate      float64 `json:"rate"`
	MinAmount float64 `json:"min_amount"`
}

type Endpoints

type Endpoints struct {
	// contains filtered or unexported fields
}

func (*Endpoints) ApproveCard

func (e *Endpoints) ApproveCard(c echo.Context) error

ApproveCard godoc

@Summary	Mark user credit card as approved
@Param		status	body	ApproveCardConfirmationRequest	true	"Approve card request"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/approve-card [post]

func (*Endpoints) BcExport

func (e *Endpoints) BcExport(c echo.Context) error

BcExport

@Summary	Export to bestchange.
@Success	200	{object}	rates
@tags		users
@Router		/bcexport [get]
func (e *Endpoints) BcLink(c echo.Context) error

BcExport

@Summary	Export to bestchange.
@Success	200
@tags		users
@Router		/bclink [get]

func (*Endpoints) CancelCard

func (e *Endpoints) CancelCard(c echo.Context) error

ApproveCard godoc

@Summary	Remove user's card request
@Param		status	body	CancelCardRequest	true	"Remove confirmation id"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/cancel-card [delete]

func (*Endpoints) CancelOrder

func (e *Endpoints) CancelOrder(c echo.Context) error

CancelOrder godoc

@Summary	Cancel user order and mark it as cancelled
@Param		status	body	CancelOrderRequest	true	"Cancel order parameters"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/cancel-order [post]

func (*Endpoints) CardConfirmations

func (e *Endpoints) CardConfirmations(c echo.Context) error

CardConfirmations godoc

@Summary	Get user's card confirmations
@Param		email	query		string	true	"Email"
@Success	200		{object}	CardConfirmationsResponse
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/card-confirmations [get]

func (*Endpoints) ChangeBusy

func (e *Endpoints) ChangeBusy(c echo.Context) error

ChangeBusy godoc

@Summary	Change busy status for admin operator
@Param		status	body	Busy	true	"Busy status"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/change-busy [post]

func (*Endpoints) CheckIfAdmin

func (e *Endpoints) CheckIfAdmin(c echo.Context) error

CheckIfAdmin godoc

@Summary	Check if user is an admin
@Success	200
@Security	ApiKeyAuth
@tags		admin
@Router		/admin/check-if-admin [post]

func (*Endpoints) ConfirmPayment

func (e *Endpoints) ConfirmPayment(c echo.Context) error

ConfirmPayment godoc

@Summary	Confirm that payment operation is approved and provide check
@Param		order_id	query		string	true	"Order id"
@Param		file		formData	file	true	"File with operation check"
@Success	200
@tags		users
@Router		/confirm-payment [post]

func (*Endpoints) CreateBalance

func (e *Endpoints) CreateBalance(c echo.Context) error

CreateBalance godoc

@Summary	Create new operator balance
@Param		status	body	CreateBalanceRequest	true	"Create balance parameters"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/create-balance [post]

func (*Endpoints) CreateCurrency

func (e *Endpoints) CreateCurrency(c echo.Context) error

CreateCurrency godoc

@Summary	Create new currency in exchanger
@Param		status	body	database.CreateCurrencyParams	true	"Create currency params"
@Success	200
@Security	ApiKeyAuth
@tags		admin
@Router		/admin/create-currency [post]

func (*Endpoints) CreateExchanger

func (e *Endpoints) CreateExchanger(c echo.Context) error

CreateExchanger godoc

@Summary	Create new exchanger with provided currencies
@Param		status	body	CreateExchangerRequest	true	"Create exchanger parameters"
@Success	200
@Security	ApiKeyAuth
@tags		admin
@Router		/admin/create-exchanger [post]

func (*Endpoints) CreateOrder

func (e *Endpoints) CreateOrder(c echo.Context) error

ListExchangers godoc

@Summary	Create order to exchange specific currency
@Param		status	body		CreateOrderRequest	true	"Request parameters"
@Success	200		{object}	CreateOrderResponse
@tags		users
@Router		/create-order [post]

func (*Endpoints) CreateUser

func (e *Endpoints) CreateUser(c echo.Context) error

CreateUser godoc

@Summary	Create new user request
@Param		status	body	CreateUserRequest	true	"Create user request"
@Success	200
@tags		users
@Router		/create-user [post]

func (*Endpoints) CurrentRate

func (e *Endpoints) CurrentRate(c echo.Context) error

CurrentRate godoc

@Summary	Current rate at specific currency
@Param		currency_in		path		string	true	"Currency in"
@Param		currency_out	path		string	true	"Currency out"
@Param		amount			path		int		true	"Amount in"
@Success	200				{object}	CurrentRateResponse
@tags		users
@Router		/current-rate [get]

func (*Endpoints) ExecuteOrder

func (e *Endpoints) ExecuteOrder(c echo.Context) error

ExecuteOrder godoc

@Summary	Execute order and change operator balances, update busy
@Param		status	body	ExecuteOrderRequest	true	"Execute order parameters"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/execute-order [post]

func (*Endpoints) FinishedOrders

func (e *Endpoints) FinishedOrders(c echo.Context) error

FinishedOrders godoc

@Summary	Get finished orders bound to specific operator
@Success	200	{object}	Orders
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/finished-orders [get]

func (*Endpoints) GetCardConfirmations

func (e *Endpoints) GetCardConfirmations(c echo.Context) error

GetCardConfirmations godoc

@Summary	Get user credit card approval images with parameters
@Success	200	{object}	GetCardConfirmationsResponse
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/get-card-confirmations [get]

func (*Endpoints) GetChatMessages

func (e *Endpoints) GetChatMessages(c echo.Context) error

GetChatMessages

@Summary	Send message that will be read by operators.
@Param		uuid	path		string	true	"UUID sent by email"
@Success	200		{object}	ChatMessages
@tags		users
@Router		/get-chat-messages/{uuid} [get]

func (*Endpoints) GetOrders

func (e *Endpoints) GetOrders(c echo.Context) error

GetOrders godoc

@Summary	Get active orders bound to specific operator
@Success	200	{object}	Orders
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/get-orders [get]

func (*Endpoints) GetUnresolvedChats

func (e *Endpoints) GetUnresolvedChats(c echo.Context) error

GetUnresolvedChats godoc

@Summary	Get unresolved chat objects
@Success	200	{object}	UnresolvedChats
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/unresolved-chats [get]

func (*Endpoints) Info

func (e *Endpoints) Info(c echo.Context) error

Info godoc

@Summary	Get info about the running instance.
@Success	200	{object}	OrderStatusResponse
@tags		users
@Router		/info [get]

func (*Endpoints) ListBalances

func (e *Endpoints) ListBalances(c echo.Context) error

ListBalances godoc

@Summary	List operator currency balances
@Success	200	{object}	Balances
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/list-balances [get]

func (*Endpoints) ListCurrencies

func (e *Endpoints) ListCurrencies(c echo.Context) error

ListCurrencies godoc

@Summary	Verify user email address
@Success	200	{object}	Currencies
@tags		users
@Router		/list-currencies [get]

func (*Endpoints) ListExchangers

func (e *Endpoints) ListExchangers(c echo.Context) error

ListExchangers godoc

@Summary	List existing exchangers
@Success	200	{object}	Exchangers
@tags		users
@Router		/list-exchangers [get]

func (*Endpoints) ListOrders

func (e *Endpoints) ListOrders(c echo.Context) error

ListOrders godoc

@Summary	List user's orders
@Success	200	{object}	UserOrdersResponse
@Security	ApiKeyAuth
@tags		users
@Router		/user/list-orders [get]

func (*Endpoints) Login

func (e *Endpoints) Login(c echo.Context) error

Login godoc

@Summary	Login and get auth key
@Param		email		header		string	true	"Email"
@Param		password	header		string	true	"Password"
@Success	200			{string}	string	token
@tags		users
@Router		/login [post]

func (*Endpoints) OrderSearch

func (e *Endpoints) OrderSearch(c echo.Context) error

CardConfirmations godoc

@Summary	Get user's card confirmations
@Param		email	query		string	true	"Email"
@Success	200		{object}	Orders
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/order-search [get]

func (*Endpoints) OrderStatus

func (e *Endpoints) OrderStatus(c echo.Context) error

OrderStatus godoc

@Summary	Check order status and return info about order
@Param		Orderid	header		string	true	"orderid"
@Success	200		{object}	OrderStatusResponse
@tags		users
@Router		/order-status [get]

func (*Endpoints) RemoveBalance

func (e *Endpoints) RemoveBalance(c echo.Context) error

RemoveBalance godoc

@Summary	Remove operators balance
@Param		status	body	RemoveBalanceRequest	true	"Balance id"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/admin/remove-balance [delete]

func (*Endpoints) RemoveCurrency

func (e *Endpoints) RemoveCurrency(c echo.Context) error

RemoveCurrency godoc

@Summary	Remove currency from currency list
@Param		status	body	RemoveCurrencyRequest	true	"Remove currency parameter"
@Success	200
@Security	ApiKeyAuth
@tags		admin
@Router		/admin/remove-currency [delete]

func (*Endpoints) RemoveExchanger

func (e *Endpoints) RemoveExchanger(c echo.Context) error

RemoveExchanger godoc

@Summary	Remove existing exchanger from API
@Param		status	body	RemoveExchangerRequest	true	"Remove exchanger parameters"
@Success	200
@Security	ApiKeyAuth
@tags		admin
@Router		/admin/remove-exchanger [delete]

func (*Endpoints) ResolveChat

func (e *Endpoints) ResolveChat(c echo.Context) error

ResolveChat godoc

@Summary	Resolve chat
@Param		status	body	ChatUUID	true	"Chat UUID"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/resolve-chat [post]

func (*Endpoints) SelfInfo

func (e *Endpoints) SelfInfo(c echo.Context) error

ListOrders godoc

@Summary	Get user's self info
@Success	200	{object}	SelfInfoResponse
@Security	ApiKeyAuth
@tags		users
@Router		/user/self-info [get]

func (*Endpoints) SendChatMessage

func (e *Endpoints) SendChatMessage(c echo.Context) error

SendChatMessage

@Summary	Send message that will be read by operators.
@Param		status	body	SendChatMessageRequest	true	"Request parameters"
@Success	200
@tags		users
@Router		/send-chat-message [post]

func (*Endpoints) UpdateBalance

func (e *Endpoints) UpdateBalance(c echo.Context) error

UpdateBalance godoc

@Summary	Update operator currency balance
@Param		status	body	UpdateBalanceRequest	true	"Update balance parameters"
@Success	200
@Security	ApiKeyAuth
@tags		operator
@Router		/operator/update-balance [post]

func (*Endpoints) ValidateCard

func (e *Endpoints) ValidateCard(c echo.Context) error

ValidateCard godoc

@Summary	Create validate card request
@Param		email		query		string	true	"Email"
@Param		currency	query		string	true	"Currency"
@Param		addr		query		string	true	"Address"
@Param		file		formData	file	true	"Approve file"
@Success	200
@tags		users
@Router		/validate-card [post]

func (*Endpoints) VerifyEmail

func (e *Endpoints) VerifyEmail(c echo.Context) error

VerifyEmail godoc

@Summary	Verify user email address
@Param		uuid	path	string	true	"UUID sent by email"
@Success	200
@tags		users
@Router		/verify/{uuid} [get]

type Exchangers

type Exchangers struct {
	Exchangers []database.Exchanger `json:"exchangers"`
}

type ExecuteOrderRequest

type ExecuteOrderRequest struct {
	OrderID int64 `json:"order_id"`
}

type GetCardConfirmationsResponse

type GetCardConfirmationsResponse struct {
	CardConfirmations []database.CardConfirmation `json:"card_confirmations"`
}

type InfoResponse

type InfoResponse struct {
	Host     string `json:"host"`
	Email    string `json:"email"`
	Telegram string `json:"telegram"`
}

type Item

type Item struct {
	From      string  `xml:"from"`
	To        string  `xml:"to"`
	In        float64 `xml:"in"`
	Out       float64 `xml:"out"`
	Amount    float64 `xml:"amount"`
	MinAmount float64 `xml:"minamount"`
	MaxAmount float64 `xml:"maxamount"`
}

type Order

type Order struct {
	ID             int64   `json:"id"`
	CurrencyIn     string  `json:"currin"`
	Email          string  `json:"email"`
	AmountIn       float64 `json:"amountin"`
	CurrOut        string  `json:"currout"`
	AmountOut      float64 `json:"amountout"`
	Address        string  `json:"address"`
	ApprovePicture []byte  `json:"approvepic"`
	Status         string  `json:"status"`
}

type OrderStatusResponse

type OrderStatusResponse struct {
	Status string `json:"status"`
}

type Orders

type Orders struct {
	Orders []Order `json:"orders"`
}

type RemoveBalanceRequest

type RemoveBalanceRequest struct {
	ID int64 `json:"id"`
}

type RemoveCurrencyRequest

type RemoveCurrencyRequest struct {
	Code string `json:"code"`
}

type RemoveExchangerRequest

type RemoveExchangerRequest struct {
	ID int64 `json:"id"`
}

type SelfInfoResponse

type SelfInfoResponse struct {
	Email string `json:"email"`
	Busy  bool   `json:"busy"`
}

type SendChatMessageRequest

type SendChatMessageRequest struct {
	UUID     string `json:"uuid"`
	Message  string `json:"message"`
	Outgoing bool   `json:"outgoing"`
}

type UnresolvedChats

type UnresolvedChats struct {
	Chats []database.Chat `json:"chats"`
}

type UpdateBalanceRequest

type UpdateBalanceRequest struct {
	BalanceID    int64   `json:"balance_id"`
	CurrencyCode string  `json:"currency_code"`
	Balance      float64 `json:"balance"`
	Address      string  `json:"address"`
}

type UserOrder

type UserOrder struct {
	ID          int64   `json:"id"`
	InCurrency  string  `json:"in_currency"`
	InAmount    float64 `json:"in_amount"`
	RecvAddr    string  `json:"recv_addr"`
	OutCurrency string  `json:"out_currency"`
	OutAmount   float64 `json:"out_amount"`
	OutAddr     string  `json:"out_addr"`
	Status      string  `json:"status"`
}

type UserOrdersResponse

type UserOrdersResponse struct {
	UserOrders []UserOrder `json:"orders"`
}

type ValidateCardRequest

type ValidateCardRequest struct {
	Email      string `json:"email"`
	CurrencyID int64  `json:"currency_id"`
}

Jump to

Keyboard shortcuts

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