models

package
v0.0.0-...-c72b0ab Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DistributeSubscriberLimit      = 300
	ExpiredDistributedMessageLimit = 100
	PendingDistributedMessageLimit = 20
)
View Source
const (
	MessageStatePending = "pending"
	MessageStateSuccess = "success"
)
View Source
const (
	PacketStateInitial  = "INITIAL"
	PacketStatePaid     = "PAID"
	PacketStateExpired  = "EXPIRED"
	PacketStateRefunded = "REFUNDED"
)
View Source
const (
	PaymentStatePending = "pending"
	PaymentStatePaid    = "paid"
)
View Source
const (
	MessageQueueCheckpoint = "service-message-checkpoint"
)

Variables

This section is empty.

Functions

func CleanUpExpiredDistributedMessages

func CleanUpExpiredDistributedMessages(ctx context.Context, ids []string) error

func ExpiredDistributedMessageIds

func ExpiredDistributedMessageIds(ctx context.Context) ([]string, error)

func ListExpiredPackets

func ListExpiredPackets(ctx context.Context, limit int) ([]string, error)

func ReadProperty

func ReadProperty(ctx context.Context, key string) (string, error)

func ReadPropertyAsOffset

func ReadPropertyAsOffset(ctx context.Context, key string) (time.Time, error)

func SendParticipantTransfer

func SendParticipantTransfer(ctx context.Context, packetId, userId string, amount string) error

func SubscribersCount

func SubscribersCount(ctx context.Context) (int64, error)

func UniqueConversationId

func UniqueConversationId(userId, recipientId string) string

func WriteProperty

func WriteProperty(ctx context.Context, key, value string) error

Types

type Asset

type Asset struct {
	AssetId  string
	Symbol   string
	Name     string
	IconURL  string
	PriceBTC string
	PriceUSD string
	Balance  string
}

type Blacklist

type Blacklist struct {
	UserId string
}

type DistributedMessage

type DistributedMessage struct {
	MessageId      string
	ConversationId string
	RecipientId    string
	UserId         string
	Category       string
	Data           []byte
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func PendingDistributedMessages

func PendingDistributedMessages(ctx context.Context, limit int64) ([]*DistributedMessage, error)

type Message

type Message struct {
	MessageId        string
	UserId           string
	Category         string
	Data             []byte
	CreatedAt        time.Time
	UpdatedAt        time.Time
	State            string
	LastDistributeAt time.Time
}

func CreateMessage

func CreateMessage(ctx context.Context, messageId, userId, category string, data []byte, createdAt, updatedAt time.Time) (*Message, error)

func PendingMessages

func PendingMessages(ctx context.Context, limit int64) ([]*Message, error)

func (*Message) Distribute

func (message *Message) Distribute(ctx context.Context) error

type Packet

type Packet struct {
	PacketId        string
	UserId          string
	AssetId         string
	Amount          string
	Greeting        string
	TotalCount      int64
	RemainingCount  int64
	RemainingAmount string
	State           string
	CreatedAt       time.Time

	User         *User
	Asset        *Asset
	Participants []*Participant
}

func PayPacket

func PayPacket(ctx context.Context, packetId string, assetId, amount string) (*Packet, error)

func ReadPackageWithRelation

func ReadPackageWithRelation(ctx context.Context, packetId string) (*Packet, error)

func RefundPacket

func RefundPacket(ctx context.Context, packetId string) (*Packet, error)

func SendPacketRefundTransfer

func SendPacketRefundTransfer(ctx context.Context, packetId string) (*Packet, error)

func ShowPacket

func ShowPacket(ctx context.Context, packetId string) (*Packet, error)

func (*Packet) GetParticipants

func (packet *Packet) GetParticipants(ctx context.Context) error

type Participant

type Participant struct {
	PacketId  string
	UserId    string
	Amount    string
	CreatedAt time.Time

	FullName  string
	AvatarURL string
}

func ListPendingParticipants

func ListPendingParticipants(ctx context.Context, limit int) ([]*Participant, error)

type Property

type Property struct {
	Key       string
	Value     string
	UpdatedAt time.Time
}

type User

type User struct {
	UserId         string
	IdentityNumber int64
	FullName       string
	AccessToken    string
	AvatarURL      string
	TraceId        string
	State          string
	SubscribedAt   time.Time

	AuthenticationToken string
}

func AuthenticateUserByOAuth

func AuthenticateUserByOAuth(ctx context.Context, authorizationCode string) (*User, error)

func AuthenticateUserByToken

func AuthenticateUserByToken(ctx context.Context, authenticationToken string) (*User, error)

func FindUser

func FindUser(ctx context.Context, userId string) (*User, error)

func Subscribers

func Subscribers(ctx context.Context, offset time.Time, num int64) ([]*User, error)

func (*User) ClaimPacket

func (current *User) ClaimPacket(ctx context.Context, packetId string) (*Packet, error)

func (*User) CreateBlacklist

func (user *User) CreateBlacklist(ctx context.Context, userId string) (*Blacklist, error)

func (*User) CreatePacket

func (current *User) CreatePacket(ctx context.Context, assetId string, amount number.Decimal, totalCount int64, greeting string) (*Packet, error)

func (*User) DeleteUser

func (user *User) DeleteUser(ctx context.Context, id string) error

func (*User) GetRole

func (user *User) GetRole() string

func (*User) ListAssets

func (current *User) ListAssets(ctx context.Context) ([]*Asset, error)

func (*User) Payment

func (user *User) Payment(ctx context.Context) error

func (*User) Prepare

func (current *User) Prepare(ctx context.Context) (int, error)

func (*User) ShowAsset

func (current *User) ShowAsset(ctx context.Context, assetId string) (*Asset, error)

func (*User) Subscribe

func (user *User) Subscribe(ctx context.Context) error

func (*User) Unsubscribe

func (user *User) Unsubscribe(ctx context.Context) error

func (*User) UpdateProfile

func (user *User) UpdateProfile(ctx context.Context, fullName string) error

Jump to

Keyboard shortcuts

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