chore: updated TSDocs of the Currency Module (#6908)
Updated TSDocs of the Currency Module
This commit is contained in:
@@ -7,19 +7,31 @@ import { BaseFilterable } from "../../dal"
|
|||||||
*/
|
*/
|
||||||
export interface CurrencyDTO {
|
export interface CurrencyDTO {
|
||||||
/**
|
/**
|
||||||
* The ISO 3 code of the currency.
|
* The ISO 3 character code of the currency.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* usd
|
||||||
*/
|
*/
|
||||||
code: string
|
code: string
|
||||||
/**
|
/**
|
||||||
* The symbol of the currency.
|
* The symbol of the currency.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* $
|
||||||
*/
|
*/
|
||||||
symbol: string
|
symbol: string
|
||||||
/**
|
/**
|
||||||
* The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
* The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* $
|
||||||
*/
|
*/
|
||||||
symbol_native: string
|
symbol_native: string
|
||||||
/**
|
/**
|
||||||
* The name of the currency.
|
* The name of the currency.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* US Dollar
|
||||||
*/
|
*/
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Context } from "../shared-context"
|
|||||||
import { FilterableCurrencyProps, CurrencyDTO } from "./common"
|
import { FilterableCurrencyProps, CurrencyDTO } from "./common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main service interface for the currency module.
|
* The main service interface for the Currency Module.
|
||||||
*/
|
*/
|
||||||
export interface ICurrencyModuleService extends IModuleService {
|
export interface ICurrencyModuleService extends IModuleService {
|
||||||
/**
|
/**
|
||||||
@@ -19,44 +19,7 @@ export interface ICurrencyModuleService extends IModuleService {
|
|||||||
* @returns {Promise<CurrencyDTO>} The retrieved currency.
|
* @returns {Promise<CurrencyDTO>} The retrieved currency.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* A simple example that retrieves a currency by its code:
|
* const currency = await currencyModuleService.retrieve("usd")
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* import {
|
|
||||||
* initialize as initializeCurrencyModule,
|
|
||||||
* } from "@medusajs/currency"
|
|
||||||
*
|
|
||||||
* async function retrieveCurrency (code: string) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const currency = await currencyModule.retrieve(
|
|
||||||
* code
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currency or return it
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* To specify attributes that should be retrieved:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* import {
|
|
||||||
* initialize as initializeCurrencyModule,
|
|
||||||
* } from "@medusajs/currency"
|
|
||||||
*
|
|
||||||
* async function retrieveCurrency (code: string) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const currency = await currencyModule.retrieve(
|
|
||||||
* code,
|
|
||||||
* {
|
|
||||||
* select: ["symbol_native"]
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currency or return it
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
*/
|
||||||
retrieve(
|
retrieve(
|
||||||
code: string,
|
code: string,
|
||||||
@@ -79,69 +42,23 @@ export interface ICurrencyModuleService extends IModuleService {
|
|||||||
* To retrieve a list of currencies using their codes:
|
* To retrieve a list of currencies using their codes:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* import {
|
* const currencies = await currencyModuleService.list({
|
||||||
* initialize as initializeCurrencyModule,
|
* code: ["usd", "eur"],
|
||||||
* } from "@medusajs/currency"
|
* })
|
||||||
*
|
|
||||||
* async function retrieveCurrencies (codes: string[]) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const currencies = await currencyModule.list(
|
|
||||||
* {
|
|
||||||
* code: codes
|
|
||||||
* },
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* To specify attributes that should be retrieved within the money amounts:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* import {
|
|
||||||
* initialize as initializeCurrencyModule,
|
|
||||||
* } from "@medusajs/currency"
|
|
||||||
*
|
|
||||||
* async function retrieveCurrencies (codes: string[]) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const currencies = await currencyModule.list(
|
|
||||||
* {
|
|
||||||
* code: codes
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* select: ["symbol_native"]
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* import {
|
* const currencies = await currencyModuleService.list(
|
||||||
* initialize as initializeCurrencyModule,
|
* {
|
||||||
* } from "@medusajs/currency"
|
* code: ["usd", "eur"],
|
||||||
*
|
* },
|
||||||
* async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
* {
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
* take: 20,
|
||||||
*
|
* skip: 2,
|
||||||
* const currencies = await currencyModule.list(
|
* }
|
||||||
* {
|
* )
|
||||||
* code: codes
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* select: ["symbol_native"],
|
|
||||||
* skip,
|
|
||||||
* take
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
list(
|
list(
|
||||||
@@ -165,69 +82,25 @@ export interface ICurrencyModuleService extends IModuleService {
|
|||||||
* To retrieve a list of currencies using their codes:
|
* To retrieve a list of currencies using their codes:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* import {
|
* const [currencies, count] =
|
||||||
* initialize as initializeCurrencyModule,
|
* await currencyModuleService.listAndCount({
|
||||||
* } from "@medusajs/currency"
|
* code: ["usd", "eur"],
|
||||||
*
|
* })
|
||||||
* async function retrieveCurrencies (codes: string[]) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const [currencies, count] = await currencyModule.listAndCount(
|
|
||||||
* {
|
|
||||||
* code: codes
|
|
||||||
* },
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* To specify attributes that should be retrieved within the money amounts:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* import {
|
|
||||||
* initialize as initializeCurrencyModule,
|
|
||||||
* } from "@medusajs/currency"
|
|
||||||
*
|
|
||||||
* async function retrieveCurrencies (codes: string[]) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const [currencies, count] = await currencyModule.listAndCount(
|
|
||||||
* {
|
|
||||||
* code: codes
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* select: ["symbol_native"]
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* import {
|
* const [currencies, count] =
|
||||||
* initialize as initializeCurrencyModule,
|
* await currencyModuleService.listAndCount(
|
||||||
* } from "@medusajs/currency"
|
|
||||||
*
|
|
||||||
* async function retrieveCurrencies (codes: string[], skip: number, take: number) {
|
|
||||||
* const currencyModule = await initializeCurrencyModule()
|
|
||||||
*
|
|
||||||
* const [currencies, count] = await currencyModule.listAndCount(
|
|
||||||
* {
|
* {
|
||||||
* code: codes
|
* code: ["usd", "eur"],
|
||||||
* },
|
* },
|
||||||
* {
|
* {
|
||||||
* select: ["symbol_native"],
|
* take: 20,
|
||||||
* skip,
|
* skip: 2,
|
||||||
* take
|
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*
|
|
||||||
* // do something with the currencies or return them
|
|
||||||
* }
|
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
listAndCount(
|
listAndCount(
|
||||||
|
|||||||
Reference in New Issue
Block a user