api

package
v0.0.0-...-5458032 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.15.0 DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.15.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type AffiliateCode

type AffiliateCode struct {
	// Address address of the wallet that requested the affiliate code
	Address string `db:"address" json:"address"`

	// Code affiliate code generated for the requesting wallet address
	Code string `db:"code" json:"code"`

	// Ts date/time at which the affiliate code was added
	Ts time.Time `db:"created_at" json:"ts"`
}

AffiliateCode defines model for affiliate_code.

type Alive200Response

type Alive200Response struct {
}

func (Alive200Response) VisitAliveResponse

func (response Alive200Response) VisitAliveResponse(w http.ResponseWriter) error

type AliveRequestObject

type AliveRequestObject struct {
}

type AliveResponseObject

type AliveResponseObject interface {
	VisitAliveResponse(w http.ResponseWriter) error
}

type ConnectWallet200JSONResponse

type ConnectWallet200JSONResponse UserDataResult

func (ConnectWallet200JSONResponse) VisitConnectWalletResponse

func (response ConnectWallet200JSONResponse) VisitConnectWalletResponse(w http.ResponseWriter) error

type ConnectWallet400JSONResponse

type ConnectWallet400JSONResponse Error

func (ConnectWallet400JSONResponse) VisitConnectWalletResponse

func (response ConnectWallet400JSONResponse) VisitConnectWalletResponse(w http.ResponseWriter) error

type ConnectWallet5XXJSONResponse

type ConnectWallet5XXJSONResponse struct {
	Body       Error
	StatusCode int
}

func (ConnectWallet5XXJSONResponse) VisitConnectWalletResponse

func (response ConnectWallet5XXJSONResponse) VisitConnectWalletResponse(w http.ResponseWriter) error

type ConnectWalletJSONRequestBody

type ConnectWalletJSONRequestBody = ConnectionRequest

ConnectWalletJSONRequestBody defines body for ConnectWallet for application/json ContentType.

type ConnectWalletRequestObject

type ConnectWalletRequestObject struct {
	Body *ConnectWalletJSONRequestBody
}

type ConnectWalletResponseObject

type ConnectWalletResponseObject interface {
	VisitConnectWalletResponse(w http.ResponseWriter) error
}

type ConnectionRequest

type ConnectionRequest struct {
	// Address address of the wallet that connected
	Address string `db:"address" json:"address"`

	// Code affiliate code, pass `none` if there's no code in the URL
	Code string `db:"code" json:"code"`
}

ConnectionRequest defines model for connection_request.

type DelphiKey

type DelphiKey = string

DelphiKey defines model for delphi_key.

type DelphiSignature

type DelphiSignature = string

DelphiSignature defines model for delphi_signature.

type DelphiTs

type DelphiTs = string

DelphiTs defines model for delphi_ts.

type Donation

type Donation struct {
	// Amount amount donated
	Amount string `db:"amount" json:"amount"`

	// Asset asset donated
	Asset DonationAsset `db:"asset" json:"asset"`

	// Price token price at the time of donation
	Price string `db:"price" json:"price"`

	// Status ethereum blockchain status of the donation
	Status DonationStatus `db:"status" json:"status"`

	// Tokens amount of tokens corresponding to the donated amount
	Tokens string    `db:"tokens" json:"tokens"`
	Ts     time.Time `db:"block_time" json:"ts"`

	// TxHash transaction hash for the donation in question
	TxHash string `db:"tx_hash" json:"tx_hash"`

	// UsdAmount optional USD amount, omitted in case of USD stable coins
	UsdAmount *string `db:"usd_amount" json:"usd_amount,omitempty"`
}

Donation defines model for donation.

type DonationAsset

type DonationAsset string

DonationAsset asset donated

const (
	DonationAssetEth  DonationAsset = "eth"
	DonationAssetUsdc DonationAsset = "usdc"
	DonationAssetUsdt DonationAsset = "usdt"
)

Defines values for DonationAsset.

type DonationData

type DonationData struct {
	// Prices an array of prices
	Prices []Price `json:"prices"`

	// ReceivingAddress receiving address for donations
	ReceivingAddress string             `json:"receiving_address"`
	Stats            DonationStats      `json:"stats"`
	Status           DonationDataStatus `json:"status"`
}

DonationData defines model for donation_data.

type DonationData200JSONResponse

type DonationData200JSONResponse DonationData

func (DonationData200JSONResponse) VisitDonationDataResponse

func (response DonationData200JSONResponse) VisitDonationDataResponse(w http.ResponseWriter) error

type DonationData400JSONResponse

type DonationData400JSONResponse Error

func (DonationData400JSONResponse) VisitDonationDataResponse

func (response DonationData400JSONResponse) VisitDonationDataResponse(w http.ResponseWriter) error

type DonationData5XXJSONResponse

type DonationData5XXJSONResponse struct {
	Body       Error
	StatusCode int
}

func (DonationData5XXJSONResponse) VisitDonationDataResponse

func (response DonationData5XXJSONResponse) VisitDonationDataResponse(w http.ResponseWriter) error

type DonationDataRequestObject

type DonationDataRequestObject struct {
}

type DonationDataResponseObject

type DonationDataResponseObject interface {
	VisitDonationDataResponse(w http.ResponseWriter) error
}

type DonationDataStatus

type DonationDataStatus string

DonationDataStatus defines model for DonationData.Status.

const (
	Closed DonationDataStatus = "closed"
	Open   DonationDataStatus = "open"
	Paused DonationDataStatus = "paused"
)

Defines values for DonationDataStatus.

type DonationStats

type DonationStats struct {
	// Tokens number of tokens claimable by donors
	Tokens string `db:"tokens" json:"tokens"`

	// Total total funds raised in USD
	Total string `db:"total" json:"total"`
}

DonationStats defines model for donation_stats.

type DonationStatus

type DonationStatus string

DonationStatus ethereum blockchain status of the donation

const (
	Confirmed   DonationStatus = "confirmed"
	Failed      DonationStatus = "failed"
	Unconfirmed DonationStatus = "unconfirmed"
)

Defines values for DonationStatus.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

type Error struct {
	// Code error code
	Code int `json:"code"`

	// Message error message
	Message string `json:"message"`
}

Error defines model for error.

type GenerateCode200JSONResponse

type GenerateCode200JSONResponse AffiliateCode

func (GenerateCode200JSONResponse) VisitGenerateCodeResponse

func (response GenerateCode200JSONResponse) VisitGenerateCodeResponse(w http.ResponseWriter) error

type GenerateCode400JSONResponse

type GenerateCode400JSONResponse Error

func (GenerateCode400JSONResponse) VisitGenerateCodeResponse

func (response GenerateCode400JSONResponse) VisitGenerateCodeResponse(w http.ResponseWriter) error

type GenerateCode401Response

type GenerateCode401Response struct {
}

func (GenerateCode401Response) VisitGenerateCodeResponse

func (response GenerateCode401Response) VisitGenerateCodeResponse(w http.ResponseWriter) error

type GenerateCode5XXJSONResponse

type GenerateCode5XXJSONResponse struct {
	Body       Error
	StatusCode int
}

func (GenerateCode5XXJSONResponse) VisitGenerateCodeResponse

func (response GenerateCode5XXJSONResponse) VisitGenerateCodeResponse(w http.ResponseWriter) error

type GenerateCodeParams

type GenerateCodeParams struct {
	// DelphiKey a key/address (public)
	DelphiKey DelphiKey `json:"delphi-key"`

	// DelphiTs caller timestamp (number of seconds since Unix epoch) -- included
	// to prevent replay attacks; must not be older than 5 seconds
	DelphiTs DelphiTs `json:"delphi-ts"`

	// DelphiSignature signature over a string like: `affiliate code, 2023-10-23
	// 18:45:19+00:00`.  The message is constructed from the words that make
	// up the path of the REST API endpoint called. *Important*: please use
	// UTC timestamps only.
	DelphiSignature DelphiSignature `json:"delphi-signature"`
}

GenerateCodeParams defines parameters for GenerateCode.

type GenerateCodeRequestObject

type GenerateCodeRequestObject struct {
	Params GenerateCodeParams
}

type GenerateCodeResponseObject

type GenerateCodeResponseObject interface {
	VisitGenerateCodeResponse(w http.ResponseWriter) error
}

type Price

type Price struct {
	Asset PriceAsset `db:"asset" json:"asset"`

	// Price asset price in USD
	Price string    `db:"price" json:"price"`
	Ts    time.Time `db:"created_at" json:"ts"`
}

Price defines model for price.

type PriceAsset

type PriceAsset string

PriceAsset defines model for Price.Asset.

const (
	PriceAssetEth   PriceAsset = "eth"
	PriceAssetTruth PriceAsset = "truth"
)

Defines values for PriceAsset.

type Ready200Response

type Ready200Response struct {
}

func (Ready200Response) VisitReadyResponse

func (response Ready200Response) VisitReadyResponse(w http.ResponseWriter) error

type Ready503Response

type Ready503Response struct {
}

func (Ready503Response) VisitReadyResponse

func (response Ready503Response) VisitReadyResponse(w http.ResponseWriter) error

type ReadyRequestObject

type ReadyRequestObject struct {
}

type ReadyResponseObject

type ReadyResponseObject interface {
	VisitReadyResponse(w http.ResponseWriter) error
}

type ServerInterface

type ServerInterface interface {
	// generate new affiliate code
	// (POST /affiliate/code)
	GenerateCode(ctx echo.Context, params GenerateCodeParams) error
	// get general donation data
	// (GET /donation/data)
	DonationData(ctx echo.Context) error
	// is the service alive?
	// (GET /live)
	Alive(ctx echo.Context) error
	// is the service alive and ready to do work?
	// (GET /ready)
	Ready(ctx echo.Context) error
	// get the donation data for the wallet address in question
	// (GET /user/data/{address})
	UserData(ctx echo.Context, address string) error
	// what is the version of this service?
	// (GET /version)
	Version(ctx echo.Context) error
	// associate a wallet address with an affiliate code
	// (POST /wallet/connection)
	ConnectWallet(ctx echo.Context) error
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) Alive

func (w *ServerInterfaceWrapper) Alive(ctx echo.Context) error

Alive converts echo context to params.

func (*ServerInterfaceWrapper) ConnectWallet

func (w *ServerInterfaceWrapper) ConnectWallet(ctx echo.Context) error

ConnectWallet converts echo context to params.

func (*ServerInterfaceWrapper) DonationData

func (w *ServerInterfaceWrapper) DonationData(ctx echo.Context) error

DonationData converts echo context to params.

func (*ServerInterfaceWrapper) GenerateCode

func (w *ServerInterfaceWrapper) GenerateCode(ctx echo.Context) error

GenerateCode converts echo context to params.

func (*ServerInterfaceWrapper) Ready

func (w *ServerInterfaceWrapper) Ready(ctx echo.Context) error

Ready converts echo context to params.

func (*ServerInterfaceWrapper) UserData

func (w *ServerInterfaceWrapper) UserData(ctx echo.Context) error

UserData converts echo context to params.

func (*ServerInterfaceWrapper) Version

func (w *ServerInterfaceWrapper) Version(ctx echo.Context) error

Version converts echo context to params.

type StrictHandlerFunc

type StrictHandlerFunc = strictecho.StrictEchoHandlerFunc

type StrictMiddlewareFunc

type StrictMiddlewareFunc = strictecho.StrictEchoMiddlewareFunc

type StrictServerInterface

type StrictServerInterface interface {
	// generate new affiliate code
	// (POST /affiliate/code)
	GenerateCode(ctx context.Context, request GenerateCodeRequestObject) (GenerateCodeResponseObject, error)
	// get general donation data
	// (GET /donation/data)
	DonationData(ctx context.Context, request DonationDataRequestObject) (DonationDataResponseObject, error)
	// is the service alive?
	// (GET /live)
	Alive(ctx context.Context, request AliveRequestObject) (AliveResponseObject, error)
	// is the service alive and ready to do work?
	// (GET /ready)
	Ready(ctx context.Context, request ReadyRequestObject) (ReadyResponseObject, error)
	// get the donation data for the wallet address in question
	// (GET /user/data/{address})
	UserData(ctx context.Context, request UserDataRequestObject) (UserDataResponseObject, error)
	// what is the version of this service?
	// (GET /version)
	Version(ctx context.Context, request VersionRequestObject) (VersionResponseObject, error)
	// associate a wallet address with an affiliate code
	// (POST /wallet/connection)
	ConnectWallet(ctx context.Context, request ConnectWalletRequestObject) (ConnectWalletResponseObject, error)
}

StrictServerInterface represents all server handlers.

type UserData

type UserData struct {
	// AffiliateCode affiliate code generated for this wallet address
	AffiliateCode *string `db:"us_code" json:"affiliate_code,omitempty"`

	// Reward staking rewards the user is eligible to claim
	Reward string `db:"us_reward" json:"reward"`

	// Staked number of tokens the user staked; must be <= `tokens`
	Staked string         `db:"us_staked" json:"staked"`
	Status UserDataStatus `db:"us_status" json:"status"`

	// Tokens number of tokens the user is eligible to claim
	Tokens string `db:"us_tokens" json:"tokens"`

	// Total total funds donated by this address in USD
	Total string `db:"us_total" json:"total"`

	// Ts date/time at which the staking status was last modified
	Ts *time.Time `db:"us_modified_at" json:"ts,omitempty"`
}

UserData defines model for user_data.

type UserData200JSONResponse

type UserData200JSONResponse UserDataResult

func (UserData200JSONResponse) VisitUserDataResponse

func (response UserData200JSONResponse) VisitUserDataResponse(w http.ResponseWriter) error

type UserData400JSONResponse

type UserData400JSONResponse Error

func (UserData400JSONResponse) VisitUserDataResponse

func (response UserData400JSONResponse) VisitUserDataResponse(w http.ResponseWriter) error

type UserData5XXJSONResponse

type UserData5XXJSONResponse struct {
	Body       Error
	StatusCode int
}

func (UserData5XXJSONResponse) VisitUserDataResponse

func (response UserData5XXJSONResponse) VisitUserDataResponse(w http.ResponseWriter) error

type UserDataRequestObject

type UserDataRequestObject struct {
	Address string `json:"address"`
}

type UserDataResponseObject

type UserDataResponseObject interface {
	VisitUserDataResponse(w http.ResponseWriter) error
}

type UserDataResult

type UserDataResult struct {
	// Donations an array of donations
	Donations []Donation `json:"donations"`
	UserData  UserData   `json:"user_data"`
}

UserDataResult defines model for user_data_result.

type UserDataStatus

type UserDataStatus string

UserDataStatus defines model for UserData.Status.

const (
	None      UserDataStatus = "none"
	Staking   UserDataStatus = "staking"
	Unstaking UserDataStatus = "unstaking"
)

Defines values for UserDataStatus.

type Version200JSONResponse

type Version200JSONResponse string

func (Version200JSONResponse) VisitVersionResponse

func (response Version200JSONResponse) VisitVersionResponse(w http.ResponseWriter) error

type VersionRequestObject

type VersionRequestObject struct {
}

type VersionResponseObject

type VersionResponseObject interface {
	VisitVersionResponse(w http.ResponseWriter) error
}

Jump to

Keyboard shortcuts

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