diff --git a/client/intents.go b/client/intents.go index de32a07..03013c3 100644 --- a/client/intents.go +++ b/client/intents.go @@ -18,6 +18,9 @@ type CreateIntentRequest struct { UserSourceAddress string `json:"user_source_address"` UserDestinationAddress string `json:"user_destination_address"` RefundAddress string `json:"refund_address"` + + // ReferrerID is an optional identifier for further filtration. + ReferrerID string `json:"referrer_id,omitempty"` } // CreateIntentResponse represents the response payload of creating new intent. diff --git a/client/swaps.go b/client/swaps.go index 504c700..f0c12e0 100644 --- a/client/swaps.go +++ b/client/swaps.go @@ -42,6 +42,8 @@ type ListSwapHistoryParams struct { Statuses []types.CombinedStatus // RetailID specifies the retail ID filter. RetailID string + // ReferrerID is an optional referrer id (setup during intent creation) to request history for. + ReferrerID string } func (params *ListSwapHistoryParams) toQueryParams() string { @@ -79,6 +81,10 @@ func (params *ListSwapHistoryParams) toQueryParams() string { q.Set("retail_id", params.RetailID) } + if params.ReferrerID != "" { + q.Set("referrer_id", params.ReferrerID) + } + for _, status := range params.Statuses { q.Add("status", status.String()) } diff --git a/types/intents.go b/types/intents.go index 4775f08..41d3201 100644 --- a/types/intents.go +++ b/types/intents.go @@ -1,5 +1,9 @@ package types +import ( + "github.com/google/uuid" +) + // CombinedStatus combines intent statuses with swaps statuses to provide a general overview on swap flow progress. type CombinedStatus string @@ -29,3 +33,29 @@ const ( func (s CombinedStatus) String() string { return string(s) } + +// Fee represents an affiliate fee that will be collected and stored for a specific intent. +type Fee struct { + IntentID uuid.UUID `json:"intent_id"` + SubAffiliateID string `json:"sub_affiliate_id"` + FeeBps *Int `json:"fee_bps"` + NetworkID int64 `json:"network_id"` + Token string `json:"token"` + FeeAmountLots *Int `json:"fee_amount_lots"` + FeeAmountDecimals int64 `json:"fee_amount_decimals"` + Status FeeStatus `json:"status"` +} + +// FeeStatus represents settlement status for an affiliate fee. +type FeeStatus string + +const ( + // FeeStatusCreated defines that fee is in the Created status until the swap is finished for the user (swap_status < Fulfilled). + FeeStatusCreated FeeStatus = "Created" + // FeeStatusToSettle defines that fee moves to ToSettle when the swap is confirmed and completed for the user (swap_status = Fulfilled). + FeeStatusToSettle FeeStatus = "ToSettle" + // FeeStatusCancelled defines that fee is set to Cancelled when the swap fails and transitions to Refunding or Refunded. + FeeStatusCancelled FeeStatus = "Cancelled" + // FeeStatusSettled defines that fee is set to Settled when the swap is completed and the fee has been settled to the affiliate. + FeeStatusSettled FeeStatus = "Settled" +) diff --git a/types/swaps.go b/types/swaps.go index dde771f..eb44bc8 100644 --- a/types/swaps.go +++ b/types/swaps.go @@ -8,10 +8,12 @@ import ( // Swap represents the swap entity data. type Swap struct { - IntentID uuid.UUID `json:"intent_id"` - Status CombinedStatus `json:"status"` - Metadata *SwapMetadata `json:"swap_metadata,omitempty"` - AdditionalInfo SwapAdditionalInfo `json:"additional_info"` + SwapAdditionalInfo + + IntentID uuid.UUID `json:"intent_id"` + Status CombinedStatus `json:"status"` + Metadata *SwapMetadata `json:"swap_metadata,omitempty"` + Fees []Fee `json:"fees"` } // SwapMetadata holds swap extra data.