quote

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Kind = "quote"

Kind identifies this message kind

Variables

This section is empty.

Functions

func ValidNext added in v0.11.0

func ValidNext() []string

ValidNext returns the valid message kinds that can follow a Quote.

Types

type CreateOption

type CreateOption func(*createOptions)

CreateOption defines a type for functions that can modify the createOptions struct.

func CreatedAt

func CreatedAt(t time.Time) CreateOption

CreatedAt can be passed to Create to provide a custom created at time.

func ExternalID

func ExternalID(externalID string) CreateOption

ExternalID can be passed to Create to provide a custom external id.

func ID

func ID(id string) CreateOption

ID can be passed to Create to provide a custom id.

type Data

type Data struct {
	ExpiresAt string       `json:"expiresAt,omitmepty"`
	Payin     QuoteDetails `json:"payin,omitempty"`
	Payout    QuoteDetails `json:"payout,omitempty"`
}

Data encapsulates the data content of a quote.

type PaymentInstruction

type PaymentInstruction struct {
	Link        string `json:"link,omitempty"`
	Instruction string `json:"instruction,omitempty"`
}

PaymentInstruction contains instructions with plain text and/or a link

func NewPaymentInstruction

func NewPaymentInstruction(opts ...PaymentInstructionOptions) *PaymentInstruction

NewPaymentInstruction creates a new PaymentInstruction using the provided options.

type PaymentInstructionOptions

type PaymentInstructionOptions func(*paymentInstructionOptions)

PaymentInstructionOptions defines a type for functions that can modify the paymentInstructionOptions struct.

func Instruction

func Instruction(instruction string) PaymentInstructionOptions

Instruction is an option for NewPaymentInstruction that allows setting custom text.

func InstructionLink(link string) PaymentInstructionOptions

InstructionLink is an option for NewPaymentInstruction that allows setting a custom link.

type Quote

type Quote struct {
	Metadata  message.Metadata `json:"metadata,omitempty"`
	Data      Data             `json:"data,omitempty"`
	Signature string           `json:"signature,omitempty"`
}

Quote represents a quote message within the exchange.

func Create

func Create(fromDID did.BearerDID, to, exchangeID, expiresAt string, payin, payout QuoteDetails, opts ...CreateOption) (Quote, error)

Create generates a new Quote with the specified parameters and options.

func Parse added in v0.10.0

func Parse(data []byte) (Quote, error)

Parse validates, parses input data into an Quote, and verifies the signature.

func (Quote) Digest

func (q Quote) Digest() ([]byte, error)

Digest computes a hash of the quote

func (Quote) GetKind added in v0.13.0

func (q Quote) GetKind() string

GetKind returns the kind of message

func (Quote) GetMetadata added in v0.13.0

func (q Quote) GetMetadata() message.Metadata

GetMetadata returns the metadata of the message

func (Quote) GetValidNext added in v0.13.0

func (q Quote) GetValidNext() []string

GetValidNext returns the valid message kinds that can follow a Quote.

func (*Quote) UnmarshalJSON

func (q *Quote) UnmarshalJSON(data []byte) error

UnmarshalJSON validates and unmarshals the input data into an Quote.

func (*Quote) Verify

func (q *Quote) Verify() error

Verify verifies the signature of the quote.

type QuoteDetails

type QuoteDetails struct {
	CurrencyCode       string              `json:"currencyCode,omitempty"`
	Amount             string              `json:"amount,omitempty"`
	Fee                string              `json:"fee,omitempty,omitempty"`
	PaymentInstruction *PaymentInstruction `json:"paymentInstruction,omitempty"`
}

QuoteDetails describes the relevant information of a currency that is being sent or received

func NewQuoteDetails

func NewQuoteDetails(currencyCode string, amount string, opts ...QuoteDetailsOption) QuoteDetails

NewQuoteDetails creates a QuoteDetails object with the specified currency code, amount, and optional modifications provided through QuoteDetailsOption functions.

type QuoteDetailsOption

type QuoteDetailsOption func(*quoteDetailsOptions)

QuoteDetailsOption defines a type for functions that can modify the quoteDetailsOptions struct.

func DetailsFee

func DetailsFee(fee string) QuoteDetailsOption

DetailsFee is an option for NewQuoteDetails that allows setting a custom fee for a QuoteDetails.

func DetailsInstruction

func DetailsInstruction(p *PaymentInstruction) QuoteDetailsOption

DetailsInstruction is an option for NewQuoteDetails that allows setting a custom PaymentInstruction for a QuoteDetails.

Jump to

Keyboard shortcuts

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