import Mpc from '../../../mpc' import type { MeldCreateCustomerRequest, MeldCreateCustomerResponse, MeldSearchCustomerResponse, MeldGetRetailQuoteRequest, MeldGetRetailQuoteResponse, MeldCreateRetailWidgetRequest, MeldCreateRetailWidgetResponse, MeldSearchRetailTransactionsParams, MeldSearchRetailTransactionsResponse, MeldGetRetailTransactionResponse, MeldDiscoveryParams, MeldGetServiceProvidersResponse, MeldGetCountriesResponse, MeldGetFiatCurrenciesResponse, MeldGetCryptoCurrenciesResponse, MeldGetPaymentMethodsResponse, MeldGetDefaultsResponse, MeldGetBuyLimitsResponse, MeldGetSellLimitsResponse, MeldGetKycLimitsResponse, } from '../../../shared/types' /** * Meld fiat on-ramp API on `portal.ramps.meld`. * Each method forwards to the embedded Portal iframe, which calls connect-api. */ export default class Meld { private mpc: Mpc constructor({ mpc }: { mpc: Mpc }) { this.mpc = mpc } /** Register a new Meld customer for the authenticated client. */ public async createCustomer( data: MeldCreateCustomerRequest, ): Promise { return this.mpc.meldCreateCustomer(data) } /** Retrieve the Meld customer record for the authenticated client. */ public async searchCustomer(): Promise { return this.mpc.meldSearchCustomer() } /** Get fiat-to-crypto purchase quotes from Meld service providers. */ public async getRetailQuote( data: MeldGetRetailQuoteRequest, ): Promise { return this.mpc.meldGetRetailQuote(data) } /** * Create a Meld-hosted retail widget session. * The response contains `data.widgetUrl` — open this URL in a new browser tab * to let the user complete the purchase or KYC flow on the Meld-hosted page. */ public async createRetailWidget( data: MeldCreateRetailWidgetRequest, ): Promise { return this.mpc.meldCreateRetailWidget(data) } /** Search retail transactions for the authenticated client. */ public async searchRetailTransactions( data?: MeldSearchRetailTransactionsParams, ): Promise { return this.mpc.meldSearchRetailTransactions(data) } /** Get a single retail transaction by session ID. */ public async getRetailTransactionBySession( sessionId: string, ): Promise { return this.mpc.meldGetRetailTransactionBySession(sessionId) } /** Get a single retail transaction by transaction ID. */ public async getRetailTransaction( id: string, ): Promise { return this.mpc.meldGetRetailTransaction(id) } /** Discover available Meld service providers. */ public async getServiceProviders( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetServiceProviders(params) } /** Discover supported countries. */ public async getCountries( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetCountries(params) } /** Discover supported fiat currencies. */ public async getFiatCurrencies( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetFiatCurrencies(params) } /** Discover supported crypto currencies. */ public async getCryptoCurrencies( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetCryptoCurrencies(params) } /** Discover supported payment methods. */ public async getPaymentMethods( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetPaymentMethods(params) } /** Discover default currency and payment method settings by country. */ public async getDefaults( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetDefaults(params) } /** Discover fiat currency purchase limits. */ public async getBuyLimits( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetBuyLimits(params) } /** Discover crypto currency sell limits. */ public async getSellLimits( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetSellLimits(params) } /** Discover KYC fiat level limits. */ public async getKycLimits( params?: MeldDiscoveryParams, ): Promise { return this.mpc.meldGetKycLimits(params) } }