Documentation ¶
Index ¶
- Constants
- type CreateOption
- type Data
- type ID
- type Offering
- type PayinDetails
- type PayinMethod
- type PaymentMethodOption
- func MethodDescription(description string) PaymentMethodOption
- func MethodFee(fee string) PaymentMethodOption
- func MethodGroup(group string) PaymentMethodOption
- func MethodMax(max string) PaymentMethodOption
- func MethodMin(min string) PaymentMethodOption
- func MethodName(name string) PaymentMethodOption
- func RequiredDetails(details string) PaymentMethodOption
- type PaymentOption
- type PayoutDetails
- type PayoutMethod
Constants ¶
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
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 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 ¶
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
Parse validates, parses input data into an Offering, and verifies the signature.
func (*Offering) UnmarshalJSON ¶
UnmarshalJSON validates and unmarshals the input data into an 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