» Currency SDK Documentation

Getting the List of All Supported Currencies

Function: get_admin_currency_list()

Purpose

The get_admin_currency_list() function is designed to fetch a paginated list of all available currencies supported by the platform. It provides key details for each currency, such as its symbol, precision, rounding method, and country association.

Parameters

This function does not require any input parameters.

Use Case

This function is useful in applications or admin dashboards where the system needs to display or manage currencies. For instance, in an e-commerce admin panel, this function can be used to populate a dropdown with supported currencies during product setup, pricing configuration, or payment setup.

def get_admin_currency_list():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_currency.list()
        print(response)

    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a structured response containing a list of currencies. Each currency includes its unique ID, name, code, symbol, precision, rounding method, and associated country details. Additionally, pagination data is included to navigate through larger currency datasets.

CurrencyListDTO(
    currencies=[CurrencyDataDTO(
        active=True,
        code='CURRENCY_CODE_1',
        name='CURRENCY_NAME_1',
        precision=DECIMAL_PRECISION_1,
        rounding='ROUNDING_TYPE_1',
        symbol='CURRENCY_SYMBOL_1',
        id=CURRENCY_ID_1,
        country=CountryDataDTO(
            isDefault=IS_DEFAULT_COUNTRY_1,
            code='COUNTRY_CODE_1',
            name='COUNTRY_NAME_1',
            id=COUNTRY_ID_1,
            state=COUNTRY_STATE_1,
            isActive=IS_ACTIVE_COUNTRY_1
        ),
        updatedAt='UPDATED_AT_1'
    ),
    CurrencyDataDTO(
        active=True,
        code='CURRENCY_CODE_2',
        name='CURRENCY_NAME_2',
        precision=DECIMAL_PRECISION_2,
        rounding='ROUNDING_TYPE_2',
        symbol='CURRENCY_SYMBOL_2',
        id=CURRENCY_ID_2,
        country=CountryDataDTO(
            isDefault=IS_DEFAULT_COUNTRY_2,
            code='COUNTRY_CODE_2',
            name='COUNTRY_NAME_2',
            id=COUNTRY_ID_2,
            state=COUNTRY_STATE_2,
            isActive=IS_ACTIVE_COUNTRY_2
        ),
        updatedAt='UPDATED_AT_2'
    )],
    pagination=PaginationDTO(
        records=TOTAL_RECORDS,
        limit=LIMIT_PER_PAGE,
        offset=CURRENT_OFFSET,
        nextPage='NEXT_PAGE_URL',
        previousPage='PREVIOUS_PAGE_URL'
    )
)

Getting Information About a Specific Currency

Function: get_currency_info()

Purpose

The get_currency_info() function retrieves detailed information about a specific currency, such as its code, name, symbol, rounding method, and the country associated with it. This function allows the retrieval of data for a particular currency using its unique ID, which can be used for applications that require displaying detailed currency information.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the currency whose details are to be fetched.

Use Case

This function can be used when you need detailed information about a specific currency. For example, in a financial application, you might need to show detailed information about a selected currency, including its name, symbol, and rounding behavior. The information can be useful for updating or displaying a currency’s properties.

def get_currency_info():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_currency.info(id="Currency_ID")
        print(response)

    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a structured response containing detailed information about the requested currency, including its active status, currency code, name, rounding settings, symbol, and the country it is associated with. The response includes a CurrencyDataDTO object that holds the relevant data and is encapsulated in a CurrencyInfoResponseDTO structure.

CurrencyInfoResponseDTO(
    currency=CurrencyDataDTO(
        active=True,
        code='CURRENCY_CODE',
        name='CURRENCY_NAME',
        precision=DECIMAL_PRECISION,
        rounding='ROUNDING_TYPE',
        symbol='CURRENCY_SYMBOL',
        id=CURRENCY_ID,
        country=CountryDataDTO(
            isDefault=IS_DEFAULT_COUNTRY,
            code='COUNTRY_CODE',
            name='COUNTRY_NAME',
            id=COUNTRY_ID,
            state=COUNTRY_STATE,
            isActive=IS_ACTIVE_COUNTRY
        ),
        updatedAt='UPDATED_AT'
    )
)

Creating a New Currency

Function: create_currency()

Purpose

The create_currency() function allows administrators to add a new currency to the WebCommander system. This includes specifying currency code, symbol, country, rounding method, and precision. It helps in expanding the supported list of currencies for global transactions.

Parameters

ParametersTypeDescription
nameStringThe full name of the currency to be created.
codeStringA short code representing the currency.
countryStringThe full name of the country associated with the currency.
countryCodeStringThe ISO 2-letter country code.
symbolStringThe symbol used to represent the currency.
activeBooleanIf true, the currency will be active upon creation.
roundingStringThe rounding method.
precisionIntegerNumber of decimal places to be used for the currency values.

Use Case

This function is commonly used during the initial setup of an e-commerce platform when new currencies need to be supported. For instance, if a business starts accepting a new currency, an admin can create and activate it using this method.

def create_currency():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        currency_data = CurrencyCreateDataDTO(
            name="CURRENCY_NAME",
            code="CURRENCY_CODE",
            country="COUNTRY_NAME",
            countryCode="COUNTRY_CODE",
            symbol="CURRENCY_SYMBOL",
            active=True,
            rounding="ROUNDING_METHOD",
            precision=2
        )

        response = webcommander_sdk.admin_currency.create(request_data=currency_data)
        print(response)

    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

Returns a detailed object representing the newly created currency, including its internal ID, country information, symbol, and metadata.

CurrencyInfoResponseDTO(
    currency=CurrencyDataDTO(
        active=IS_ACTIVE,
        code='CURRENCY_CODE',
        name='CURRENCY_NAME',
        precision=CURRENCY_PRECISION,
        rounding='ROUNDING_TYPE',
        symbol='CURRENCY_SYMBOL',
        id=CURRENCY_ID,
        country=CountryDataDTO(
            isDefault=IS_DEFAULT_COUNTRY,
            code='COUNTRY_CODE',
            name='COUNTRY_NAME',
            id=COUNTRY_ID,
            state=COUNTRY_STATE,
            isActive=IS_COUNTRY_ACTIVE
        ),
        updatedAt='CURRENCY_UPDATED_AT'
    )
)

Update Currency Information by ID

Function: admin_currency_update()

Purpose

The admin_currency_update() function updates the details of a currency based on its unique identifier. It allows administrators to modify attributes such as the currency's name, code, symbol, and other related settings, ensuring the latest information is stored in the system.

Parameters

Parameter Type Description
id String The ID of the currency to update.
name String The name of the currency.
code String ISO currency code.
country String Country name using the currency.
countryCode String ISO country code.
symbol String Currency symbol.
active Boolean Whether the currency is active.
rounding String Rounding strategy, ("Nearest", "Up", "Down").
precision Integer Number of decimal places to consider.

Use Case

This function is useful for administrators who need to update an existing currency's details in the system. For instance, an administrator may want to change the currency name, symbol, or precision for a particular country. The function takes the currency ID and updated data, then applies the changes.

def admin_currency_update():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        currency_data = CurrencyCreateDataDTO(
            name="CURRNECY_NAME",
            code="CURRRNCY_CODE",
            country="COUNTRY",
            countryCode="COUNTRY_CODE",
            symbol="SYMBOL",
            active=True,
            rounding="Nearest",
            precision=2
        )
        response = webcommander_sdk.admin_currency.update(id="19", request_data=currency_data)
        print(response)

    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response is a DTO object containing the updated currency information. It includes details such as the updated currency's name, code, symbol, precision, rounding method, and the associated country. The response also includes the timestamp when the currency was last updated.

CurrencyInfoResponseDTO(
    currency=CurrencyDataDTO(
        active=True,
        code='CURRENCY_CODE',
        name='CURRENCY_NAME',
        precision=PRECISION,
        rounding='ROUNDING_METHOD',
        symbol='CURRENCY_SYMBOL',
        id=CURRENCY_ID,
        country=CountryDataDTO(
            isDefault=DEFAULT_STATUS,
            code='COUNTRY_CODE',
            name='COUNTRY_NAME',
            id=COUNTRY_ID,
            state='STATE_NAME',
            isActive=COUNTRY_ACTIVE_STATUS
        ),
        updatedAt='UPDATED_AT'
    )
)

Deleting a Specific Currency

Function: delete_currency_by_id()

Purpose

The delete_currency_by_id() function is used to permanently remove a currency from the system based on its unique ID. This operation is typically performed by administrators managing currency options in platforms like e-commerce or finance management systems. It ensures that outdated or unused currencies can be efficiently removed.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the currency to delete.

Use Case

This function is useful when an admin needs to clean up the list of supported currencies by removing obsolete or mistakenly added entries. For instance, if a currency is no longer used for transactions on a platform, this method allows for its removal from the backend configuration.

def delete_currency_by_id():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_currency.delete(id="CURRENCY _ID")
        print(response)

    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response 

The function returns a confirmation that the request was successful. However, since this is a DELETE operation, there is no response body content. The response signifies that the currency identified by the given ID was successfully removed from the system without errors.

Request was successful, but there is no content to display.