View Source
const (
	// ErrInexistentEvent is returned when attempting to retrieve a non existing event
	ErrInexistentEvent InexistentEventErr = "inexistent event"
	// ErrInexistentPayment is returned when attempting to retrieve a non existing payment
	ErrInexistentPayment InexistentPaymentErr = "inexistent payment"


This section is empty.


This section is empty.


type API

type API interface {
	RetrieveEvents(ctx context.Context, ppvQuery PPVEventQuery, user *security.JWTUser) ([]PPVEventAndSubscription, error)
	CreateEvent(ctx context.Context, ppvEvent *models.PayPerViewEvent) error
	RetrieveEvent(ctx context.Context, eventID int64, user *security.JWTUser) (PPVEventAndSubscription, error)
	UpdateEvent(ctx context.Context, ppvEvent *models.PayPerViewEvent) error
	ProcessPayment(ctx context.Context, paymentData PPVEventPayment, payment *models.Payment) error
	RetrievePaymentStatus(ctx context.Context, eventID int64, user security.JWTUser) (models.PaymentSlice, error)
	RegisterSubscription(ctx context.Context, payment PPVEventPayment) (*models.Payment, error)
	RegisterUnsubscription(ctx context.Context, payment PPVEventPayment) (*models.Payment, error)

API is an event API interface

func NewAPI

func NewAPI(logger *log.Logger, db *sql.DB, deployer *eth.SmartContractDeployer) API

NewAPI creates a new authentication API

type APIFactory

type APIFactory func(logger *log.Logger, db *sql.DB, deployer *eth.SmartContractDeployer) API

APIFactory is a function capable of creating an Event API

type Handler

type Handler struct {

	// contains filtered or unexported fields


Handler is a group of handlers within a route.

func NewHandler

func NewHandler(logger *log.Logger, db *sql.DB, deployer *eth.SmartContractDeployer) Handler

NewHandler creates a handler for the game route

func (Handler) Routes

func (h Handler) Routes(e *echo.Group, jwtMiddleware echo.MiddlewareFunc, jwtOptionalMiddleware echo.MiddlewareFunc)

Routes initializes all the routes with their http handlers

type InexistentEventErr

type InexistentEventErr string

InexistentEventErr is returned when attempting to retrieve a non existing event

func (InexistentEventErr) Error

func (e InexistentEventErr) Error() string

type InexistentPaymentErr

type InexistentPaymentErr string

InexistentPaymentErr is returned when attempting to retrieve a non existing payment

func (InexistentPaymentErr) Error

func (e InexistentPaymentErr) Error() string

type PPVEvent

type PPVEvent struct {
	ID          int64           `json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	EventType   string          `json:"eventType"`
	Start       time.Time       `json:"start"`
	End         time.Time       `json:"end"`
	PriceETH    int64           `json:"priceETH"`
	PriceBTC    int64           `json:"priceBTC"`
	PriceXMR    int64           `json:"priceXMR"`
	CreatedAt   time.Time       `json:"createdAt"`
	UpdatedAt   *time.Time      `json:"updatedAt,omitempty"`
	Payment     *models.Payment `json:"payment,omitempty"`

PPVEvent has all the information of a pay per view event

type PPVEventAndSubscription

type PPVEventAndSubscription struct {
	Payments []models.Payment `json:"payments"`

PPVEventAndSubscription an event containing the user payments

type PPVEventPayment

type PPVEventPayment struct {
	EventID        int64                         `json:"eventID"`
	Price          int64                         `json:"price"`
	CryptoCurrency cryptocurrency.CryptoCurrency `json:"cryptoCurrency"`
	PaymentID      string                        `json:"paymentID"`
	WalletAddress  string                        `json:"walletAddress"`
	BlockHash      string                        `json:"blockHash"`
	BlockNumber    string                        `json:"blockNumber"`
	TxHash         string                        `json:"txHash"`
	TxNumber       string                        `json:"txNumber"`
	Status         string                        `json:"status"`
	User           security.JWTUser

PPVEventPayment contains the information to process a payment

type PPVEventQuery

type PPVEventQuery struct {
	ID    int64
	Query string    `json:"query,omitempty" validate:"lte=256"`
	From  time.Time `json:"from,omitempty"`
	To    time.Time `json:"to,omitempty" validate:"gtfield=From|eqfield=From"`

PPVEventQuery contains all the data to query a PPVEvent

type ProspectEvent

type ProspectEvent struct {
	Name            string    `json:"name" validate:"required,gt=0,lte=200"`
	Description     string    `json:"description" validate:"required,gt=0,lte=1500"`
	EventType       string    `json:"eventType" validate:"required,gt=0,lte=200"`
	Start           time.Time `json:"start" validate:"required"`
	End             time.Time `json:"end" validate:"required"`
	PriceETH        int64     `json:"priceETH" validate:"required"`
	PriceBTC        int64     `json:"priceBTC" validate:"required"`
	PriceXMR        int64     `json:"priceXMR" validate:"required"`
	EthContractAddr string    `json:"ethContractAddr"`

ProspectEvent contains the information to create an pay per view event