zboxapi

package
v1.18.10 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Provides functions and types to communicate with the 0box API (an off-chain service that provides functionality for the applications out of the scope of the chain transactions).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJsonResponse = errors.New("zbox-srv: invalid json response")
)

Functions

func GetLogger added in v1.11.0

func GetLogger() *logger.Logger

Types

type Client

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

func NewClient

func NewClient() *Client

NewClient create a zbox api client with wallet info

func (*Client) CreateJwtToken

func (c *Client) CreateJwtToken(ctx context.Context, userID, accessToken string) (string, error)

CreateJwtToken create a jwt token with jwt session id and otp

func (*Client) CreateSharedInfo added in v1.11.0

func (c *Client) CreateSharedInfo(ctx context.Context, phoneNumber, token string, s SharedInfo) error

func (*Client) DeleteSharedInfo added in v1.11.0

func (c *Client) DeleteSharedInfo(ctx context.Context, phoneNumber, token, authTicket string, lookupHash string) error

func (*Client) GetCsrfToken

func (c *Client) GetCsrfToken(ctx context.Context) (string, error)

GetCsrfToken obtain a fresh csrf token from 0box api server

func (*Client) GetFreeStorage added in v1.11.0

func (c *Client) GetFreeStorage(ctx context.Context, phoneNumber, token string) (*FreeMarker, error)

func (*Client) GetSharedByMe added in v1.11.0

func (c *Client) GetSharedByMe(ctx context.Context, phoneNumber, token string) ([]SharedInfoSent, error)

func (*Client) GetSharedByPublic added in v1.11.0

func (c *Client) GetSharedByPublic(ctx context.Context, phoneNumber, token string) ([]SharedInfoSent, error)

func (*Client) GetSharedToMe added in v1.11.0

func (c *Client) GetSharedToMe(ctx context.Context, phoneNumber, token string) ([]SharedInfoReceived, error)

func (*Client) RefreshJwtToken

func (c *Client) RefreshJwtToken(ctx context.Context, userID string, token string) (string, error)

RefreshJwtToken refresh jwt token

func (*Client) SetRequest added in v1.8.12

func (c *Client) SetRequest(baseUrl, appType string)

SetRequest set base url and app type of zbox api request

func (*Client) SetWallet

func (c *Client) SetWallet(clientID, clientPrivateKey, clientPublicKey string)

type CsrfTokenResponse

type CsrfTokenResponse struct {
	Token string `json:"csrf_token"`
}

type ErrorResponse

type ErrorResponse struct {
	Error json.RawMessage `json:"error"`
}

type FreeMarker added in v1.11.0

type FreeMarker struct {
	Assigner   string  `json:"assigner"`
	Recipient  string  `json:"recipient"`
	FreeTokens float64 `json:"free_tokens"`
	Nonce      int64   `json:"nonce"`
	Signature  string  `json:"signature"`
}

type FreeStorageResponse added in v1.11.0

type FreeStorageResponse struct {
	Data      string `json:"marker"`
	FundingID int    `json:"funding_id"`
}

func (*FreeStorageResponse) ToMarker added in v1.11.0

func (fs *FreeStorageResponse) ToMarker() (*FreeMarker, error)

type JsonResult added in v1.11.0

type JsonResult[T any] struct {
	Message string `json:"message"`
	Error   string `json:"error"`
	Data    []T    `json:"data"`
}

type JwtTokenResponse added in v1.8.17

type JwtTokenResponse struct {
	Token string `json:"jwt_token"`
}

type MarkerData added in v1.11.0

type MarkerData struct {
	Marker             string `json:"marker"`
	RecipientPublicKey string `json:"recipient_public_key"`
}

type SharedInfo added in v1.11.0

type SharedInfo struct {
	AuthTicket    string `json:"auth_ticket"`
	Message       string `json:"message"`
	ShareInfoType string `json:"share_info_type"`
	Link          string `json:"link"`
}

type SharedInfoReceived added in v1.11.0

type SharedInfoReceived struct {
	AuthTicket    string `json:"auth_ticket"`
	Message       string `json:"message"`
	ShareInfoType string `json:"share_info_type"`
	ClientID      string `json:"client_id"`
	Receiver      string `json:"receiver_client_id"`
	LookupHash    string `json:"lookup_hash"`
	SenderName    string `json:"sender_name"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

type SharedInfoSent added in v1.11.0

type SharedInfoSent struct {
	AuthTicket    string `json:"auth_ticket"`
	Message       string `json:"message"`
	ShareInfoType string `json:"share_info_type"`
	Receiver      string `json:"receiver_client_id"`
	Link          string `json:"link"`
	ReceiverName  string `json:"receiver_name"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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