offering

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Kind = "offering"

Kind distinguishes between different resource kinds

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOption

type CreateOption func(*createOptions)

CreateOption implements functional options pattern for Create.

func CreatedAt

func CreatedAt(t time.Time) CreateOption

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

func Description

func Description(d string) CreateOption

Description can be passed to Create to provide a custom description.

func OfferingID

func OfferingID(id ID) CreateOption

OfferingID can be passed to [CreateOffering] to provide a custom id.

func RequiredClaims

func RequiredClaims(claims pexv2.PresentationDefinition) CreateOption

RequiredClaims can be used to set claims on the offering being created

func UpdatedAt

func UpdatedAt(t time.Time) CreateOption

UpdatedAt can be passed to Create to provide a custom updated at time.

type Data

type Data struct {
	Description    string                        `json:"description"`
	Rate           string                        `json:"payoutUnitsPerPayinUnit"`
	Payin          PayinDetails                  `json:"payin,omitempty"`
	Payout         PayoutDetails                 `json:"payout,omitempty"`
	RequiredClaims *pexv2.PresentationDefinition `json:"requiredClaims,omitempty"`
}

Data represents the data of an Offering.

type ID

type ID struct {
	typeid.TypeID[ID]
}

ID is a unique identifier for an Offering.

func (ID) Prefix

func (id ID) Prefix() string

Prefix returns the prefix for the Offering ID.

type Offering

type Offering struct {
	tbdex.ResourceMetadata `json:"metadata"`
	Data                   `json:"data"`
	Signature              string `json:"signature"`
}

Offering is a resource created by a PFI to define requirements for a given currency pair offered for exchange.

func Create

func Create(payin PayinDetails, payout PayoutDetails, rate string, opts ...CreateOption) (Offering, error)

Create creates an Offering

An Offering is a resource created by a PFI to define requirements for a given currency pair offered for exchange.

func (Offering) Digest

func (o Offering) Digest() ([]byte, error)

Digest computes a hash of the resource A digest is the output of the hash function. It's a fixed-size string of bytes

  • that uniquely represents the data input into the hash function. The digest is often used for
  • data integrity checks, as any alteration in the input data results in a significantly
  • different digest. *
  • It takes the algorithm identifier of the hash function and data to digest as input and returns
  • the digest of the data.

func (*Offering) Parse added in v0.8.0

func (o *Offering) Parse(data []byte) error

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

func (*Offering) Sign

func (o *Offering) Sign(bearerDID did.BearerDID) error

Sign cryptographically signs the Resource using DID's private key

func (*Offering) UnmarshalJSON

func (o *Offering) UnmarshalJSON(data []byte) error

UnmarshalJSON validates and unmarshals the input data into an Offering.

func (*Offering) Verify added in v0.8.0

func (o *Offering) Verify() error

Verify verifies the signature of the Offering.

type PayinDetails

type PayinDetails struct {
	CurrencyCode string        `json:"currencyCode"`
	Min          string        `json:"min,omitempty"`
	Max          string        `json:"max,omitempty"`
	Methods      []PayinMethod `json:"methods,omitempty"`
}

PayinDetails represents the details of the payin part of an Offering.

func NewPayin

func NewPayin(currencyCode string, methods []PayinMethod, opts ...PaymentOption) PayinDetails

NewPayin creates PayinDetails

type PayinMethod

type PayinMethod struct {
	Kind                   string          `json:"kind"`
	Name                   string          `json:"name,omitempty"`
	Description            string          `json:"description,omitempty"`
	Group                  string          `json:"group,omitempty"`
	RequiredPaymentDetails json.RawMessage `json:"requiredPaymentDetails,omitempty"` // TODO: change to JSON Schema type
	Fee                    string          `json:"fee,omitempty"`
	Min                    string          `json:"min,omitempty"`
	Max                    string          `json:"max,omitempty"`
}

PayinMethod represents a single payment option on an Offering.

func NewPayinMethod

func NewPayinMethod(kind string, opts ...PaymentMethodOption) PayinMethod

NewPayinMethod creates PayinMethod

type PaymentMethodOption

type PaymentMethodOption func(*paymentMethodOptions)

PaymentMethodOption implements functional options pattern for PayinMethod and PayoutMethod.

func MethodDescription

func MethodDescription(description string) PaymentMethodOption

MethodDescription can be passed to Create to provide a custom payin method description.

func MethodFee

func MethodFee(fee string) PaymentMethodOption

MethodFee can be passed to Create to provide a custom payin method fee.

func MethodGroup

func MethodGroup(group string) PaymentMethodOption

MethodGroup can be passed to Create to provide a custom payin method group.

func MethodMax

func MethodMax(max string) PaymentMethodOption

MethodMax can be passed to Create to provide a custom max payin method amount.

func MethodMin

func MethodMin(min string) PaymentMethodOption

MethodMin can be passed to Create to provide a custom min payin method amount.

func MethodName

func MethodName(name string) PaymentMethodOption

MethodName can be passed to Create to provide a custom payin method name.

func RequiredDetails

func RequiredDetails(details string) PaymentMethodOption

RequiredDetails can be passed to Create to provide a custom payin method required payment details.

type PaymentOption

type PaymentOption func(*paymentOptions)

PaymentOption implements functional options pattern for Payin and Payout

func Max

func Max(max string) PaymentOption

Max can be passed to Create to provide a custom max payin amount.

func Min

func Min(min string) PaymentOption

Min can be passed to Create to provide a custom min payin amount.

type PayoutDetails

type PayoutDetails struct {
	CurrencyCode string         `json:"currencyCode"`
	Min          string         `json:"min,omitempty"`
	Max          string         `json:"max,omitempty"`
	Methods      []PayoutMethod `json:"methods,omitempty"`
}

PayoutDetails represents the details of the payout part of an Offering.

func NewPayout

func NewPayout(currencyCode string, methods []PayoutMethod, opts ...PaymentOption) PayoutDetails

NewPayout creates PayoutDetails

type PayoutMethod

type PayoutMethod struct {
	Kind                    string          `json:"kind"`
	Name                    string          `json:"name,omitempty"`
	Description             string          `json:"description,omitempty"`
	Group                   string          `json:"group,omitempty"`
	RequiredPaymentDetails  json.RawMessage `json:"requiredPaymentDetails,omitempty"` // TODO: change to JSON Schema type
	Fee                     string          `json:"fee,omitempty"`
	Min                     string          `json:"min,omitempty"`
	Max                     string          `json:"max,omitempty"`
	EstimatedSettlementTime uint64          `json:"estimatedSettlementTime"`
}

PayoutMethod contains all the fields from PaymentMethod, in addition to estimated settlement time.

func NewPayoutMethod

func NewPayoutMethod(kind string, estimatedSettlementTime time.Duration, opts ...PaymentMethodOption) PayoutMethod

NewPayoutMethod creates PayoutMethod

Jump to

Keyboard shortcuts

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