OnRamper
The OnRamper
class from @moonup/moon-api
provides a convenient way to interact with the OnRamper
API. This API allows you to perform various operations related to cryptocurrency purchases and sales, as well as retrieving supported assets, currencies, and payment types.
Here's a detailed documentation for the OnRamper
class:
Initialization
To use the OnRamper
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Onramper API.
Here's an example of how to create an instance of the OnRamper
class:
Class: OnRamper
Methods
onRamperCheckout(accountName: string, data: TransactionInput, params?: RequestParams)
This method is used to initiate a cryptocurrency purchase for a specific account.
Parameters:
accountName
: The name of the account to fund.data
: An object containing the transaction input details.params
: Optional request parameters.
Returns: A promise that resolves to the checkout data.
Example:
onRamperGetQuotesBuy(query: OnRamperGetQuotesBuyParams, params?: RequestParams)
This method is used to get quotes for buying cryptocurrency.
Parameters:
query
: An object containing the parameters for the quote request.params
: Optional request parameters.
Returns: A promise that resolves to the quotes for buying cryptocurrency.
Example:
onRamperGetQuotesSell(query: OnRamperGetQuotesSellParams, params?: RequestParams)
This method is used to get quotes for selling cryptocurrency.
Parameters:
query
: An object containing the parameters for the quote request.params
: Optional request parameters.
Returns: A promise that resolves to the quotes for selling cryptocurrency.
Example:
onRamperGetSupportedAssets(query: OnRamperGetSupportedAssetsParams, params?: RequestParams)
This method is used to get the supported assets for a specific country and source.
Parameters:
query
: An object containing the country and source.params
: Optional request parameters.
Returns: A promise that resolves to the supported assets.
Example:
onRamperGetSupportedCurrencies(query: OnRamperGetSupportedCurrenciesParams, params?: RequestParams)
This method is used to get the supported currencies for a specific type.
Parameters:
query
: An object containing the type.params
: Optional request parameters.
Returns: A promise that resolves to the supported currencies.
Example:
onRamperGetSupportedDefaultsAll(query: OnRamperGetSupportedDefaultsAllParams, params?: RequestParams)
This method is used to get the supported defaults for a specific country and type.
Parameters:
query
: An object containing the country and type.params
: Optional request parameters.
Returns: A promise that resolves to the supported defaults.
Example:
onRamperGetSupportedOnRampsAll(params?: RequestParams)
This method is used to get all supported on-ramps.
Parameters:
params
: Optional request parameters.
Returns: A promise that resolves to all supported on-ramps.
Example:
onRamperGetSupportedPaymentTypes(query: OnRamperGetSupportedPaymentTypesParams, params?: RequestParams)
This method is used to get the supported payment types for a specific country, fiat, and type.
Parameters:
query
: An object containing the country, fiat, and type.params
: Optional request parameters.
Returns: A promise that resolves to the supported payment types.
Example:
onRamperGetSupportedPaymentTypesFiat(query: OnRamperGetSupportedPaymentTypesFiatParams, params?: RequestParams)
This method is used to get the supported payment types for a specific country and fiat.
Parameters:
query
: An object containing the country and fiat.params
: Optional request parameters.
Returns: A promise that resolves to the supported payment types.
Example:
Usage
To use the Onramper
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Onramper API.
You can then use the onramper
instance to call the various methods of the Onramper
class. Make sure to handle any potential errors that may occur during the API calls using try-catch
blocks.
Here's a detailed documentation for the Onramper
class:
Initialization
To use the Onramper
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Onramper API.
Here's an example of how to create an instance of the Onramper
class:
Class: Onramper
Methods
onRamperCheckout(accountName: string, data: TransactionInput, params?: RequestParams)
This method is used to initiate a cryptocurrency purchase for a specific account.
Parameters:
accountName
: The name of the account to fund.data
: An object containing the transaction input details.params
: Optional request parameters.
Returns: A promise that resolves to the checkout data.
Example:
onRamperGetQuotesBuy(query: OnRamperGetQuotesBuyParams, params?: RequestParams)
This method is used to get quotes for buying cryptocurrency.
Parameters:
query
: An object containing the parameters for the quote request.params
: Optional request parameters.
Returns: A promise that resolves to the quotes for buying cryptocurrency.
Example:
onRamperGetQuotesSell(query: OnRamperGetQuotesSellParams, params?: RequestParams)
This method is used to get quotes for selling cryptocurrency.
Parameters:
query
: An object containing the parameters for the quote request.params
: Optional request parameters.
Returns: A promise that resolves to the quotes for selling cryptocurrency.
Example:
onRamperGetSupportedAssets(query: OnRamperGetSupportedAssetsParams, params?: RequestParams)
This method is used to get the supported assets for a specific country and source.
Parameters:
query
: An object containing the country and source.params
: Optional request parameters.
Returns: A promise that resolves to the supported assets.
Example:
onRamperGetSupportedCurrencies(query: OnRamperGetSupportedCurrenciesParams, params?: RequestParams)
This method is used to get the supported currencies for a specific type.
Parameters:
query
: An object containing the type.params
: Optional request parameters.
Returns: A promise that resolves to the supported currencies.
Example:
onRamperGetSupportedDefaultsAll(query: OnRamperGetSupportedDefaultsAllParams, params?: RequestParams)
This method is used to get the supported defaults for a specific country and type.
Parameters:
query
: An object containing the country and type.params
: Optional request parameters.
Returns: A promise that resolves to the supported defaults.
Example:
onRamperGetSupportedOnRampsAll(params?: RequestParams)
This method is used to get all supported on-ramps.
Parameters:
params
: Optional request parameters.
Returns: A promise that resolves to all supported on-ramps.
Example:
onRamperGetSupportedPaymentTypes(query: OnRamperGetSupportedPaymentTypesParams, params?: RequestParams)
This method is used to get the supported payment types for a specific country, fiat, and type.
Parameters:
query
: An object containing the country, fiat, and type.params
: Optional request parameters.
Returns: A promise that resolves to the supported payment types.
Example:
onRamperGetSupportedPaymentTypesFiat(query: OnRamperGetSupportedPaymentTypesFiatParams, params?: RequestParams)
This method is used to get the supported payment types for a specific country and fiat.
Parameters:
query
: An object containing the country and fiat.params
: Optional request parameters.
Returns: A promise that resolves to the supported payment types.
Example:
Usage
To use the Onramper
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Onramper API.
You can then use the onramper
instance to call the various methods of the Onramper
class. Make sure to handle any potential errors that may occur during the API calls using try-catch
blocks..
Last updated