api

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	DetailFull    = "full"
	DetailPreview = "preview"
)
View Source
const (
	DetailUser     = "user"
	DetailPassword = "password"
)

Variables

View Source
var (
	Unsuccessful = Reply{Success: false}
	NotFound     = Reply{Success: false, Error: "resource not found"}
	NotAllowed   = Reply{Success: false, Error: "method not allowed"}
)
View Source
var (
	ErrInvalidTimestamp     = errors.New("payload timestamp has invalid string format")
	ErrInvalidRejection     = errors.New("envelope does not contain a rejection/repair error")
	ErrParsingIVMS101Person = errors.New("unable to parse IVMS101 person record as json or protocol buffers")
	ErrUnknownEncoding      = errors.New("could not detect data encoding please specify and try again")
)

Functions

func ContextWithRequestID

func ContextWithRequestID(parent context.Context, requestID string) context.Context

Adds a request ID to the context which is sent with the request in the X-Request-ID header.

func EndpointTravelAddress added in v0.14.0

func EndpointTravelAddress(endpoint, protocol string) (string, error)

func ErrorStatus

func ErrorStatus(err error) int

ErrorStatus returns the HTTP status code from an error or 500 if the error is not a StatusError.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) (string, bool)

Extracts a request ID from the context.

func ValidationError

func ValidationError(err error, errs ...*FieldError) error

Types

type APIAuthentication

type APIAuthentication struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

func (*APIAuthentication) Validate

func (r *APIAuthentication) Validate() (err error)

type APIKey added in v0.24.1

type APIKey struct {
	ID          ulid.ULID  `json:"id,omitempty"`
	Description string     `json:"description"`
	ClientID    string     `json:"client_id"`
	Secret      string     `json:"client_secret,omitempty"`
	LastSeen    *time.Time `json:"last_seen,omitempty"`
	Permissions []string   `json:"permissions"`
	Created     time.Time  `json:"created,omitempty"`
	Modified    time.Time  `json:"modified,omitempty"`
}

func NewAPIKey added in v0.24.1

func NewAPIKey(model *models.APIKey) (out *APIKey, err error)

func (*APIKey) Model added in v0.24.1

func (k *APIKey) Model() (model *models.APIKey, err error)

func (*APIKey) Validate added in v0.24.1

func (k *APIKey) Validate(create bool) (err error)

type APIKeyList added in v0.24.1

type APIKeyList struct {
	Page    *PageQuery `json:"page"`
	APIKeys []*APIKey  `json:"api_keys"`
}

func NewAPIKeyList added in v0.24.1

func NewAPIKeyList(page *models.APIKeyPage) (out *APIKeyList, err error)

type APIv1

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

APIv1 implements the v1 Client interface for making requests to the TRISA SHN.

func (*APIv1) APIKeyDetail added in v0.24.1

func (s *APIv1) APIKeyDetail(ctx context.Context, keyID ulid.ULID) (out *APIKey, err error)

func (*APIv1) Accept added in v0.14.0

func (s *APIv1) Accept(ctx context.Context, transactionID uuid.UUID, in *Envelope) (out *Envelope, err error)

func (*APIv1) AcceptPreview added in v0.24.0

func (s *APIv1) AcceptPreview(ctx context.Context, transactionID uuid.UUID) (out *Envelope, err error)

func (*APIv1) AccountDetail

func (s *APIv1) AccountDetail(ctx context.Context, id ulid.ULID) (out *Account, err error)

func (*APIv1) Authenticate

func (s *APIv1) Authenticate(ctx context.Context, in *APIAuthentication) (out *LoginReply, err error)

func (*APIv1) CounterpartyDetail

func (s *APIv1) CounterpartyDetail(ctx context.Context, id ulid.ULID) (out *Counterparty, err error)

func (*APIv1) Create

func (s *APIv1) Create(ctx context.Context, endpoint string, in, out interface{}) (err error)

func (*APIv1) CreateAPIKey added in v0.24.1

func (s *APIv1) CreateAPIKey(ctx context.Context, in *APIKey) (out *APIKey, err error)

func (*APIv1) CreateAccount

func (s *APIv1) CreateAccount(ctx context.Context, in *Account) (out *Account, err error)

func (*APIv1) CreateCounterparty

func (s *APIv1) CreateCounterparty(ctx context.Context, in *Counterparty) (out *Counterparty, err error)

func (*APIv1) CreateCryptoAddress

func (s *APIv1) CreateCryptoAddress(ctx context.Context, accountID ulid.ULID, in *CryptoAddress) (out *CryptoAddress, err error)

func (*APIv1) CreateTransaction

func (s *APIv1) CreateTransaction(ctx context.Context, in *Transaction) (out *Transaction, err error)

func (*APIv1) CreateUser added in v0.18.0

func (s *APIv1) CreateUser(ctx context.Context, in *User) (out *User, err error)

func (*APIv1) CryptoAddressDetail

func (s *APIv1) CryptoAddressDetail(ctx context.Context, accountID, cryptoAddressID ulid.ULID) (out *CryptoAddress, err error)

func (*APIv1) DecodeTravelAddress added in v0.12.0

func (s *APIv1) DecodeTravelAddress(ctx context.Context, in *TravelAddress) (out *TravelAddress, err error)

func (*APIv1) DecryptedEnvelopeDetail

func (s *APIv1) DecryptedEnvelopeDetail(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) (out *Envelope, err error)

func (*APIv1) Delete

func (s *APIv1) Delete(ctx context.Context, endpoint string) (err error)

func (*APIv1) DeleteAPIKey added in v0.24.1

func (s *APIv1) DeleteAPIKey(ctx context.Context, keyID ulid.ULID) error

func (*APIv1) DeleteAccount

func (s *APIv1) DeleteAccount(ctx context.Context, id ulid.ULID) (err error)

func (*APIv1) DeleteCounterparty

func (s *APIv1) DeleteCounterparty(ctx context.Context, id ulid.ULID) (err error)

func (*APIv1) DeleteCryptoAddress

func (s *APIv1) DeleteCryptoAddress(ctx context.Context, accountID, cryptoAddressID ulid.ULID) (err error)

func (*APIv1) DeleteSecureEnvelope

func (s *APIv1) DeleteSecureEnvelope(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) error

func (*APIv1) DeleteTransaction

func (s *APIv1) DeleteTransaction(ctx context.Context, id uuid.UUID) (err error)

func (*APIv1) DeleteUser added in v0.18.0

func (s *APIv1) DeleteUser(ctx context.Context, id ulid.ULID) error

func (*APIv1) Detail

func (s *APIv1) Detail(ctx context.Context, endpoint string, out interface{}) (err error)

func (*APIv1) Do

func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)

Do executes an http request against the server, performs error checking, and deserializes the response data into the specified struct.

func (*APIv1) EncodeTravelAddress added in v0.12.0

func (s *APIv1) EncodeTravelAddress(ctx context.Context, in *TravelAddress) (out *TravelAddress, err error)

func (*APIv1) Export added in v0.14.0

func (s *APIv1) Export(ctx context.Context, w io.Writer) (err error)

func (*APIv1) LatestPayloadEnvelope added in v0.24.0

func (s *APIv1) LatestPayloadEnvelope(ctx context.Context, transactionID uuid.UUID) (out *Envelope, err error)

func (*APIv1) List

func (s *APIv1) List(ctx context.Context, endpoint string, in *PageQuery, out interface{}) (err error)

func (*APIv1) ListAPIKeys added in v0.24.1

func (s *APIv1) ListAPIKeys(ctx context.Context, in *PageQuery) (out *APIKeyList, err error)

func (*APIv1) ListAccounts

func (s *APIv1) ListAccounts(ctx context.Context, in *PageQuery) (out *AccountsList, err error)

func (*APIv1) ListCounterparties

func (s *APIv1) ListCounterparties(ctx context.Context, in *PageQuery) (out *CounterpartyList, err error)

func (*APIv1) ListCryptoAddresses

func (s *APIv1) ListCryptoAddresses(ctx context.Context, accountID ulid.ULID, in *PageQuery) (out *CryptoAddressList, err error)

func (*APIv1) ListSecureEnvelopes

func (s *APIv1) ListSecureEnvelopes(ctx context.Context, transactionID uuid.UUID, in *EnvelopeListQuery) (out *EnvelopesList, err error)

func (*APIv1) ListTransactions

func (s *APIv1) ListTransactions(ctx context.Context, in *PageQuery) (out *TransactionsList, err error)

func (*APIv1) ListUsers added in v0.18.0

func (s *APIv1) ListUsers(ctx context.Context, in *PageQuery) (out *UserList, err error)

func (*APIv1) Login

func (s *APIv1) Login(ctx context.Context, in *LoginRequest) (out *LoginReply, err error)

func (*APIv1) NewRequest

func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)

func (*APIv1) Prepare added in v0.14.0

func (s *APIv1) Prepare(ctx context.Context, in *Prepare) (out *Prepared, err error)

func (*APIv1) Reauthenticate

func (s *APIv1) Reauthenticate(ctx context.Context, in *ReauthenticateRequest) (out *LoginReply, err error)

func (*APIv1) Reject added in v0.14.0

func (s *APIv1) Reject(ctx context.Context, transactionID uuid.UUID, in *Rejection) (out *Envelope, err error)

func (*APIv1) Repair added in v0.24.0

func (s *APIv1) Repair(ctx context.Context, transactionID uuid.UUID, in *Envelope) (out *Envelope, err error)

func (*APIv1) RepairPreview added in v0.24.0

func (s *APIv1) RepairPreview(ctx context.Context, transactionID uuid.UUID) (out *Repair, err error)

func (*APIv1) SearchCounterparties added in v0.23.0

func (s *APIv1) SearchCounterparties(ctx context.Context, in *SearchQuery) (out *CounterpartyList, err error)

func (*APIv1) SecureEnvelopeDetail

func (s *APIv1) SecureEnvelopeDetail(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) (out *SecureEnvelope, err error)

func (*APIv1) SendEnvelope added in v0.14.0

func (s *APIv1) SendEnvelope(ctx context.Context, transactionID uuid.UUID, in *Envelope) (out *Envelope, err error)

func (*APIv1) SendPrepared added in v0.14.0

func (s *APIv1) SendPrepared(ctx context.Context, in *Prepared) (out *Transaction, err error)

func (*APIv1) Status

func (s *APIv1) Status(ctx context.Context) (out *StatusReply, err error)

func (*APIv1) TransactionDetail

func (s *APIv1) TransactionDetail(ctx context.Context, id uuid.UUID) (out *Transaction, err error)

func (*APIv1) Update

func (s *APIv1) Update(ctx context.Context, endpoint string, in, out interface{}) (err error)

func (*APIv1) UpdateAPIKey added in v0.24.1

func (s *APIv1) UpdateAPIKey(ctx context.Context, in *APIKey) (out *APIKey, err error)

func (*APIv1) UpdateAccount

func (s *APIv1) UpdateAccount(ctx context.Context, in *Account) (out *Account, err error)

func (*APIv1) UpdateCounterparty

func (s *APIv1) UpdateCounterparty(ctx context.Context, in *Counterparty) (out *Counterparty, err error)

func (*APIv1) UpdateCryptoAddress

func (s *APIv1) UpdateCryptoAddress(ctx context.Context, accountID ulid.ULID, in *CryptoAddress) (out *CryptoAddress, err error)

func (*APIv1) UpdateTransaction

func (s *APIv1) UpdateTransaction(ctx context.Context, in *Transaction) (out *Transaction, err error)

func (*APIv1) UpdateUser added in v0.18.0

func (s *APIv1) UpdateUser(ctx context.Context, in *User) (out *User, err error)

func (*APIv1) UserDetail added in v0.18.0

func (s *APIv1) UserDetail(ctx context.Context, id ulid.ULID) (out *User, err error)

func (*APIv1) WaitForReady

func (s *APIv1) WaitForReady(ctx context.Context) (err error)

Wait for ready polls the node's status endpoint until it responds with an 200 response, retrying with exponential backoff or until the context deadline is expired. If the user does not supply a context with a deadline, then a default deadline of 5 minutes is used so that this method does not block indefinitely. If the node API service is ready (e.g. responds to a status request) then no error is returned, otherwise an error is returned if the node never responds.

NOTE: if the node returns a 503 Service Unavailable because it is in maintenance mode, this method will continue to wait until the deadline for the node to exit from maintenance mode and be ready again.

type Account

type Account struct {
	ID              ulid.ULID        `json:"id,omitempty"`
	CustomerID      string           `json:"customer_id"`
	FirstName       string           `json:"first_name"`
	LastName        string           `json:"last_name"`
	TravelAddress   string           `json:"travel_address,omitempty"`
	IVMSRecord      string           `json:"ivms101,omitempty"`
	CryptoAddresses []*CryptoAddress `json:"crypto_addresses,omitempty"`
	Created         time.Time        `json:"created,omitempty"`
	Modified        time.Time        `json:"modified,omitempty"`
	// contains filtered or unexported fields
}

func NewAccount

func NewAccount(model *models.Account, encoding *EncodingQuery) (out *Account, err error)

func (*Account) IVMS101 added in v0.25.0

func (a *Account) IVMS101() (p *ivms101.Person, err error)

func (*Account) Model

func (a *Account) Model() (model *models.Account, err error)

func (*Account) SetEncoding added in v0.26.0

func (a *Account) SetEncoding(encoding *EncodingQuery)

func (*Account) Validate added in v0.25.0

func (a *Account) Validate(create bool) (err error)

type AccountsList

type AccountsList struct {
	Page     *PageQuery `json:"page"`
	Accounts []*Account `json:"accounts"`
}

func NewAccountList

func NewAccountList(page *models.AccountsPage) (out *AccountsList, err error)

type Client

type Client interface {
	Status(context.Context) (*StatusReply, error)
	Login(context.Context, *LoginRequest) (*LoginReply, error)
	Authenticate(context.Context, *APIAuthentication) (*LoginReply, error)
	Reauthenticate(context.Context, *ReauthenticateRequest) (*LoginReply, error)

	// Transactions Resource
	ListTransactions(context.Context, *PageQuery) (*TransactionsList, error)
	CreateTransaction(context.Context, *Transaction) (*Transaction, error)
	TransactionDetail(context.Context, uuid.UUID) (*Transaction, error)
	UpdateTransaction(context.Context, *Transaction) (*Transaction, error)
	DeleteTransaction(context.Context, uuid.UUID) error

	// Transaction Actions
	Prepare(context.Context, *Prepare) (*Prepared, error)
	SendPrepared(context.Context, *Prepared) (*Transaction, error)
	Export(context.Context, io.Writer) error

	// Transaction Detail Actions
	SendEnvelope(ctx context.Context, transactionID uuid.UUID, in *Envelope) (*Envelope, error)
	LatestPayloadEnvelope(ctx context.Context, transactionID uuid.UUID) (*Envelope, error)
	AcceptPreview(ctx context.Context, transactionID uuid.UUID) (*Envelope, error)
	Accept(ctx context.Context, transactionID uuid.UUID, in *Envelope) (*Envelope, error)
	Reject(ctx context.Context, transactionID uuid.UUID, in *Rejection) (*Envelope, error)
	RepairPreview(ctx context.Context, transactionID uuid.UUID) (*Repair, error)
	Repair(ctx context.Context, transactionID uuid.UUID, in *Envelope) (*Envelope, error)

	// SecureEnvelopes Resource
	ListSecureEnvelopes(ctx context.Context, transactionID uuid.UUID, in *EnvelopeListQuery) (*EnvelopesList, error)
	SecureEnvelopeDetail(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) (*SecureEnvelope, error)
	DecryptedEnvelopeDetail(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) (*Envelope, error)
	DeleteSecureEnvelope(ctx context.Context, transactionID uuid.UUID, envID ulid.ULID) error

	// Accounts Resource
	ListAccounts(context.Context, *PageQuery) (*AccountsList, error)
	CreateAccount(context.Context, *Account) (*Account, error)
	AccountDetail(context.Context, ulid.ULID) (*Account, error)
	UpdateAccount(context.Context, *Account) (*Account, error)
	DeleteAccount(context.Context, ulid.ULID) error

	// CryptoAddress Resource
	ListCryptoAddresses(ctx context.Context, accountID ulid.ULID, in *PageQuery) (*CryptoAddressList, error)
	CreateCryptoAddress(ctx context.Context, accountID ulid.ULID, in *CryptoAddress) (*CryptoAddress, error)
	CryptoAddressDetail(ctx context.Context, accountID, cryptoAddressID ulid.ULID) (*CryptoAddress, error)
	UpdateCryptoAddress(ctx context.Context, accountID ulid.ULID, in *CryptoAddress) (*CryptoAddress, error)
	DeleteCryptoAddress(ctx context.Context, accountID, cryptoAddressID ulid.ULID) error

	// Counterparty Resource
	SearchCounterparties(context.Context, *SearchQuery) (*CounterpartyList, error)
	ListCounterparties(context.Context, *PageQuery) (*CounterpartyList, error)
	CreateCounterparty(context.Context, *Counterparty) (*Counterparty, error)
	CounterpartyDetail(context.Context, ulid.ULID) (*Counterparty, error)
	UpdateCounterparty(context.Context, *Counterparty) (*Counterparty, error)
	DeleteCounterparty(context.Context, ulid.ULID) error

	// Users Resource
	ListUsers(context.Context, *PageQuery) (*UserList, error)
	CreateUser(context.Context, *User) (*User, error)
	UserDetail(context.Context, ulid.ULID) (*User, error)
	UpdateUser(context.Context, *User) (*User, error)
	DeleteUser(context.Context, ulid.ULID) error

	// APIKey Resource
	ListAPIKeys(context.Context, *PageQuery) (*APIKeyList, error)
	CreateAPIKey(context.Context, *APIKey) (*APIKey, error)
	APIKeyDetail(context.Context, ulid.ULID) (*APIKey, error)
	UpdateAPIKey(context.Context, *APIKey) (*APIKey, error)
	DeleteAPIKey(context.Context, ulid.ULID) error

	// Utilities
	EncodeTravelAddress(context.Context, *TravelAddress) (*TravelAddress, error)
	DecodeTravelAddress(context.Context, *TravelAddress) (*TravelAddress, error)
}

Client defines the service interface for interacting with the TRISA self-hosted node internal API (e.g. the API that users can integrate with).

func New

func New(endpoint string, opts ...ClientOption) (_ Client, err error)

New creates a new APIv1 client that implements the Client interface.

type ClientOption

type ClientOption func(c *APIv1) error

ClientOption allows us to configure the APIv1 client when it is created.

func WithClient

func WithClient(client *http.Client) ClientOption

type Counterparty

type Counterparty struct {
	ID                  ulid.ULID `json:"id,omitempty"`
	Source              string    `json:"source,omitempty"`
	DirectoryID         string    `json:"directory_id,omitempty"`
	RegisteredDirectory string    `json:"registered_directory,omitempty"`
	Protocol            string    `json:"protocol"`
	CommonName          string    `json:"common_name,omitempty"`
	Endpoint            string    `json:"endpoint"`
	TravelAddress       string    `json:"travel_address,omitempty"`
	Name                string    `json:"name"`
	Website             string    `json:"website,omitempty"`
	Country             string    `json:"country"`
	BusinessCategory    string    `json:"business_category,omitempty"`
	VASPCategories      []string  `json:"vasp_categories,omitempty"`
	VerifiedOn          time.Time `json:"verified_on,omitempty"`
	IVMSRecord          string    `json:"ivms101,omitempty"`
	Created             time.Time `json:"created,omitempty"`
	Modified            time.Time `json:"modified,omitempty"`
	// contains filtered or unexported fields
}

func NewCounterparty

func NewCounterparty(model *models.Counterparty, encoding *EncodingQuery) (out *Counterparty, err error)

func (*Counterparty) IVMS101 added in v0.25.0

func (c *Counterparty) IVMS101() (p *ivms101.LegalPerson, err error)

func (*Counterparty) Model

func (c *Counterparty) Model() (model *models.Counterparty, err error)

func (*Counterparty) SetEncoding added in v0.26.0

func (c *Counterparty) SetEncoding(encoding *EncodingQuery)

func (*Counterparty) Validate

func (c *Counterparty) Validate() (err error)

type CounterpartyList

type CounterpartyList struct {
	Page           *PageQuery      `json:"page"`
	Counterparties []*Counterparty `json:"counterparties"`
}

func NewCounterpartyList

func NewCounterpartyList(page *models.CounterpartyPage) (out *CounterpartyList, err error)

type CryptoAddress

type CryptoAddress struct {
	ID            ulid.ULID `json:"id,omitempty"`
	CryptoAddress string    `json:"crypto_address"`
	Network       string    `json:"network"`
	AssetType     string    `json:"asset_type,omitempty"`
	Tag           string    `json:"tag,omitempty"`
	TravelAddress string    `json:"travel_address,omitempty"`
	Created       time.Time `json:"created,omitempty"`
	Modified      time.Time `json:"modified,omitempty"`
}

func NewCryptoAddress

func NewCryptoAddress(model *models.CryptoAddress) (*CryptoAddress, error)

func (*CryptoAddress) Model

func (c *CryptoAddress) Model(acct *models.Account) (*models.CryptoAddress, error)

func (*CryptoAddress) Validate added in v0.25.0

func (c *CryptoAddress) Validate(create bool) (err error)

type CryptoAddressList

type CryptoAddressList struct {
	Page            *PageQuery       `json:"page"`
	CryptoAddresses []*CryptoAddress `json:"crypto_addresses"`
}

func NewCryptoAddressList

func NewCryptoAddressList(page *models.CryptoAddressPage) (out *CryptoAddressList, err error)

type DetailError

type DetailError struct {
	Field string `json:"field"`
	Error string `json:"error"`
}

type EncodingQuery added in v0.26.0

type EncodingQuery struct {
	Encoding string `json:"encoding,omitempty" url:"encoding,omitempty" form:"encoding"`
	Format   string `json:"format,omitempty" url:"format,omitempty" form:"format"`
	// contains filtered or unexported fields
}

EncodingQuery manages how IVMS101 data is returned.

func (*EncodingQuery) Decode added in v0.26.0

func (q *EncodingQuery) Decode(data string) ([]byte, error)

func (*EncodingQuery) DetectEncoding added in v0.26.0

func (q *EncodingQuery) DetectEncoding(data string) string

func (*EncodingQuery) Encode added in v0.26.0

func (q *EncodingQuery) Encode(data []byte) (string, error)

func (*EncodingQuery) Marshal added in v0.26.0

func (q *EncodingQuery) Marshal(in any) (_ string, err error)

func (*EncodingQuery) Unmarshal added in v0.26.0

func (q *EncodingQuery) Unmarshal(in string, v any) (err error)

func (*EncodingQuery) Validate added in v0.26.0

func (q *EncodingQuery) Validate() (err error)

type Envelope added in v0.14.0

type Envelope struct {
	ID                 ulid.ULID                `json:"id"`
	EnvelopeID         string                   `json:"envelope_id,omitempty"`
	Direction          string                   `json:"direction"`
	Remote             string                   `json:"remote,omitempty"`
	ReplyTo            *ulid.ULID               `json:"reply_to"`
	IsError            bool                     `json:"is_error"`
	Error              *trisa.Error             `json:"error,omitempty"`
	Identity           *ivms101.IdentityPayload `json:"identity,omitempty"`
	Transaction        *generic.Transaction     `json:"transaction,omitempty"`
	Pending            *generic.Pending         `json:"pending,omitempty"`
	SentAt             *time.Time               `json:"sent_at"`
	ReceivedAt         *time.Time               `json:"received_at,omitempty"`
	Timestamp          time.Time                `json:"timestamp,omitempty"`
	PublicKeySignature string                   `json:"public_key_signature,omitempty"`
	TransferState      string                   `json:"transfer_state,omitempty"`
	SecureEnvelope     *SecureEnvelope          `json:"secure_envelope,omitempty"`
}

func NewEnvelope added in v0.14.0

func NewEnvelope(model *models.SecureEnvelope, env *envelope.Envelope) (out *Envelope, err error)

func (*Envelope) Dump added in v0.25.0

func (e *Envelope) Dump() string

func (*Envelope) ParseTransferState added in v0.22.0

func (e *Envelope) ParseTransferState() trisa.TransferState

func (*Envelope) Payload added in v0.14.0

func (e *Envelope) Payload() (payload *trisa.Payload, err error)

func (*Envelope) Validate added in v0.14.0

func (e *Envelope) Validate() (err error)

type EnvelopeListQuery

type EnvelopeListQuery struct {
	PageQuery
	EnvelopeQuery
}

type EnvelopeQuery

type EnvelopeQuery struct {
	Decrypt  bool `json:"decrypt" url:"decrypt,omitempty" form:"decrypt"`
	Archives bool `json:"archives" url:"archives,omitempty" form:"archives"`
}

type EnvelopesList

type EnvelopesList struct {
	Page               *PageQuery        `json:"page"`
	IsDecrypted        bool              `json:"is_decrypted"`
	SecureEnvelopes    []*SecureEnvelope `json:"secure_envelopes,omitempty"`
	DecryptedEnvelopes []*Envelope       `json:"decrypted_envelopes,omitempty"`
}

func NewEnvelopeList added in v0.21.0

func NewEnvelopeList(page *models.SecureEnvelopePage, envelopes []*envelope.Envelope) (out *EnvelopesList, err error)

func NewSecureEnvelopeList

func NewSecureEnvelopeList(page *models.SecureEnvelopePage) (out *EnvelopesList, err error)

type ErrorDetail

type ErrorDetail []*DetailError

type FieldError

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

func IncorrectField

func IncorrectField(field, issue string) *FieldError

func InvalidIVMS101 added in v0.26.0

func InvalidIVMS101(err *ivms101.FieldError) *FieldError

func MissingField

func MissingField(field string) *FieldError

func OneOfMissing added in v0.14.0

func OneOfMissing(fields ...string) *FieldError

func OneOfTooMany added in v0.14.0

func OneOfTooMany(fields ...string) *FieldError

func ReadOnlyField

func ReadOnlyField(field string) *FieldError

func (*FieldError) Error

func (e *FieldError) Error() string

func (*FieldError) Subfield added in v0.27.0

func (e *FieldError) Subfield(parent string) *FieldError

func (*FieldError) SubfieldArray added in v0.27.0

func (e *FieldError) SubfieldArray(parent string, index int) *FieldError

type Identification added in v0.18.0

type Identification struct {
	TypeCode    string `json:"type_code"`
	Number      string `json:"number"`
	Country     string `json:"country"`
	DateOfBirth string `json:"dob"`
	BirthPlace  string `json:"birth_place"`
}

func (*Identification) NationalIdentifierTypeCode added in v0.21.0

func (i *Identification) NationalIdentifierTypeCode() ivms101.NationalIdentifierTypeCode

type LoginReply

type LoginReply struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Next     string `json:"next"`
}

func (*LoginRequest) Validate

func (r *LoginRequest) Validate() (err error)

type PageQuery

type PageQuery struct {
	PageSize      int    `json:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
	NextPageToken string `json:"next_page_token,omitempty" url:"next_page_token,omitempty" form:"next_page_token"`
	PrevPageToken string `json:"prev_page_token,omitempty" url:"prev_page_token,omitempty" form:"prev_page_token"`
}

PageQuery manages paginated list requests.

type Person

type Person struct {
	FirstName      string          `json:"first_name"`
	LastName       string          `json:"last_name"`
	CustomerID     string          `json:"customer_id"`
	Identification *Identification `json:"identification"`
	AddrLine1      string          `json:"addr_line_1"`
	AddrLine2      string          `json:"addr_line_2"`
	City           string          `json:"city"`
	State          string          `json:"state"`
	PostalCode     string          `json:"post_code"`
	Country        string          `json:"country"`
	CryptoAddress  string          `json:"crypto_address"`
}

func (*Person) NaturalPerson

func (p *Person) NaturalPerson() *ivms101.Person

type Prepare

type Prepare struct {
	TravelAddress string    `json:"travel_address"`
	Originator    *Person   `json:"originator"`
	Beneficiary   *Person   `json:"beneficiary"`
	Transfer      *Transfer `json:"transfer"`
}

func (*Prepare) Transaction

func (p *Prepare) Transaction() *generic.Transaction

func (*Prepare) Validate

func (p *Prepare) Validate() (err error)

type Prepared

type Prepared struct {
	TravelAddress string                   `json:"travel_address"`
	Identity      *ivms101.IdentityPayload `json:"identity"`
	Transaction   *generic.Transaction     `json:"transaction"`
}

func (*Prepared) Dump

func (p *Prepared) Dump() string

func (*Prepared) Payload

func (p *Prepared) Payload() (payload *trisa.Payload, err error)

func (*Prepared) Validate

func (p *Prepared) Validate() error

type ReauthenticateRequest

type ReauthenticateRequest struct {
	RefreshToken string `json:"refresh_token"`
}

func (*ReauthenticateRequest) Validate

func (r *ReauthenticateRequest) Validate() (err error)

type Rejection added in v0.14.0

type Rejection struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Retry   bool   `json:"retry"`
}

func NewRejection added in v0.24.0

func NewRejection(env *models.SecureEnvelope) (out *Rejection, err error)

func (*Rejection) Proto added in v0.14.0

func (r *Rejection) Proto() *trisa.Error

func (*Rejection) Validate added in v0.14.0

func (r *Rejection) Validate() (err error)

type Repair added in v0.24.0

type Repair struct {
	Error    *Rejection
	Envelope *Envelope
}

type Reply

type Reply struct {
	Success     bool        `json:"success"`
	Error       string      `json:"error,omitempty"`
	ErrorDetail ErrorDetail `json:"errors,omitempty"`
}

Reply contains standard fields that are used for generic API responses and errors.

func Error

func Error(err interface{}) Reply

Construct a new response for an error or simply return unsuccessful.

type SearchQuery added in v0.23.0

type SearchQuery struct {
	Query string `json:"query,omitempty" url:"query,omitempty" form:"query"`
	Limit int    `json:"limit,omitempty" url:"limit,omitempty" form:"limit"`
}

SearchQuery manages fuzzy string searches.

func (*SearchQuery) Model added in v0.23.0

func (q *SearchQuery) Model() *models.SearchQuery

func (*SearchQuery) Validate added in v0.23.0

func (q *SearchQuery) Validate() (err error)

type SecureEnvelope

type SecureEnvelope struct {
	ID                  ulid.ULID    `json:"id"`
	EnvelopeID          uuid.UUID    `json:"envelope_id"`
	Direction           string       `json:"direction"`
	Remote              string       `json:"remote,omitempty"`
	ReplyTo             *ulid.ULID   `json:"reply_to"`
	Payload             []byte       `json:"payload,omitempty"`
	EncryptionKey       []byte       `json:"encryption_key,omitempty"`
	EncryptionAlgorithm string       `json:"encryption_algorithm,omitempty"`
	ValidHMAC           bool         `json:"valid_hmac"`
	HMAC                []byte       `json:"hmac,omitempty"`
	HMACSecret          []byte       `json:"hmac_secret,omitempty"`
	HMACAlgorithm       string       `json:"hmac_algorithm,omitempty"`
	IsError             bool         `json:"is_error"`
	Error               *trisa.Error `json:"error,omitempty"`
	Timestamp           time.Time    `json:"timestamp"`
	Sealed              bool         `json:"sealed"`
	PublicKeySignature  string       `json:"public_key_signature,omitempty"`
	TransferState       string       `json:"transfer_state,omitempty"`
	Original            []byte       `json:"original,omitempty"`
}

func NewSecureEnvelope

func NewSecureEnvelope(model *models.SecureEnvelope) (out *SecureEnvelope, err error)

type StatusError

type StatusError struct {
	StatusCode int
	Reply      Reply
}

StatusError decodes an error response from the TRISA API.

func (*StatusError) Error

func (e *StatusError) Error() string

type StatusReply

type StatusReply struct {
	Status  string `json:"status"`
	Uptime  string `json:"uptime,omitempty"`
	Version string `json:"version,omitempty"`
}

Returned on status requests.

type Transaction

type Transaction struct {
	ID                 uuid.UUID  `json:"id"`
	Source             string     `json:"source"`
	Status             string     `json:"status"`
	Counterparty       string     `json:"counterparty"`
	CounterpartyID     ulid.ULID  `json:"counterparty_id,omitempty"`
	Originator         string     `json:"originator,omitempty"`
	OriginatorAddress  string     `json:"originator_address,omitempty"`
	Beneficiary        string     `json:"beneficiary,omitempty"`
	BeneficiaryAddress string     `json:"beneficiary_address,omitempty"`
	VirtualAsset       string     `json:"virtual_asset"`
	Amount             float64    `json:"amount"`
	LastUpdate         *time.Time `json:"last_update,omitempty"`
	EnvelopeCount      int64      `json:"envelope_count,omitempty"`
	Created            time.Time  `json:"created"`
	Modified           time.Time  `json:"modified"`
}

func NewTransaction

func NewTransaction(model *models.Transaction) (*Transaction, error)

func (*Transaction) ColorStatus added in v0.24.0

func (c *Transaction) ColorStatus() string

func (*Transaction) Model

func (c *Transaction) Model() (model *models.Transaction, err error)

func (*Transaction) TitleStatus added in v0.14.0

func (c *Transaction) TitleStatus() string

func (*Transaction) TooltipStatus added in v0.24.0

func (c *Transaction) TooltipStatus() string

func (*Transaction) Validate

func (c *Transaction) Validate() (err error)

type TransactionQuery added in v0.14.0

type TransactionQuery struct {
	Detail string `json:"detail" url:"detail,omitempty" form:"detail"`
}

func (*TransactionQuery) Validate added in v0.14.0

func (q *TransactionQuery) Validate() (err error)

type TransactionsList

type TransactionsList struct {
	Page         *PageQuery     `json:"page"`
	Transactions []*Transaction `json:"transactions"`
}

func NewTransactionList

func NewTransactionList(page *models.TransactionPage) (out *TransactionsList, err error)

type Transfer

type Transfer struct {
	Amount    float64 `json:"amount"`
	Network   string  `json:"network"`
	AssetType string  `json:"asset_type"`
	TxID      string  `json:"transaction_id"`
	Tag       string  `json:"tag"`
}

type TravelAddress added in v0.12.0

type TravelAddress struct {
	Encoded string `json:"encoded,omitempty"`
	Decoded string `json:"decoded,omitempty"`
}

func (*TravelAddress) ValidateDecode added in v0.12.0

func (t *TravelAddress) ValidateDecode() (err error)

func (*TravelAddress) ValidateEncode added in v0.12.0

func (t *TravelAddress) ValidateEncode() (err error)

type User added in v0.18.0

type User struct {
	ID        ulid.ULID  `json:"id,omitempty"`
	Name      string     `json:"name"`
	Email     string     `json:"email"`
	Password  string     `json:"password,omitempty"`
	Role      string     `json:"role"`
	LastLogin *time.Time `json:"last_login,omitempty"`
	Created   time.Time  `json:"created,omitempty"`
	Modified  time.Time  `json:"modified,omitempty"`
}

func NewUser added in v0.18.0

func NewUser(model *models.User) (out *User, err error)

func (*User) Model added in v0.18.0

func (u *User) Model() (model *models.User, err error)

func (*User) Validate added in v0.18.0

func (u *User) Validate() (err error)

type UserList added in v0.18.0

type UserList struct {
	Page  *PageQuery `json:"page"`
	Users []*User    `json:"users"`
}

func NewUserList added in v0.18.0

func NewUserList(page *models.UserPage) (out *UserList, err error)

type UserPassword added in v0.18.0

type UserPassword struct {
	Password  string `json:"password"`
	SendEmail bool   `json:"send_email"`
}

func (UserPassword) Validate added in v0.18.0

func (u UserPassword) Validate() (err error)

type UserQuery added in v0.18.0

type UserQuery struct {
	Detail string `json:"detail" url:"detail,omitempty" form:"detail"`
}

func (*UserQuery) Validate added in v0.18.0

func (q *UserQuery) Validate() (err error)

type ValidationErrors

type ValidationErrors []*FieldError
Example
err := api.ValidationError(
	nil,
	api.MissingField("name"),
	api.IncorrectField("ssn", "ssn should be 8 digits only"),
	nil,
	api.MissingField("date_of_birth"),
	nil,
)

fmt.Println(err)
Output:

	3 validation errors occurred:
  missing name: this field is required
  invalid field ssn: ssn should be 8 digits only
  missing date_of_birth: this field is required

func (ValidationErrors) Error

func (e ValidationErrors) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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