ncsclient

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeReceipt

func EncodeReceipt(receipt Receipt) (string, error)

Types

type NCSClient

type NCSClient struct {
	Endpoint  string
	Transport http.RoundTripper
}

NCSClient is the Network Credit Service client.

func NewNCSClient

func NewNCSClient(endpoint string, transport http.RoundTripper) NCSClient

NewNCSClient returns a new NCS client with the NCS endpoint and a HTTP roundtripper.

func (*NCSClient) PostReceipt

func (c *NCSClient) PostReceipt(ctx context.Context, payload ReceiptPayload) error

PostReceipt sends receipts to Network Credit Service /receipt endpoint.

type Receipt

type Receipt struct {
	AppID            string    `json:"app_id"`
	ClientID         string    `json:"client_id"`
	SessionID        string    `json:"session_id"`
	HagallWalletAddr string    `json:"hagall_wallet_addr"`
	ParticipantID    int       `json:"participant_id"`
	CreatedAt        time.Time `json:"created_at"`
	SessionJoinedAt  time.Time `json:"session_joined_at"`
	BytesSent        int64     `json:"bytes_sent"`
	BytesReceived    int64     `json:"bytes_received"`
}

func DecodeReceipt

func DecodeReceipt(receiptEncoded string) (Receipt, error)

type ReceiptPayload

type ReceiptPayload struct {
	Receipt   string `json:"receipt"`
	Hash      []byte `json:"hash"`
	Signature []byte `json:"signature"`
}

func NewReceiptPayload

func NewReceiptPayload(receipt Receipt, privateKeyString string) (ReceiptPayload, error)

NewReceiptPayload returns a receipt payload signed with privateKeyString.

func NewReceiptPayloadFromParams

func NewReceiptPayloadFromParams(receipt string, hash []byte, signature []byte) ReceiptPayload

Jump to

Keyboard shortcuts

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