* update dependencies * update onboarding mdx * fixes for mdx issues * fixes for mdx compatibility * resolve mdx errors * fixes in reference * fix check errors * revert change in vale action * fix node version in action * fix summary in markdown
377 lines
11 KiB
Plaintext
377 lines
11 KiB
Plaintext
---
|
|
displayed_sidebar: jsClientSidebar
|
|
slug: /references/js-client/AdminCurrenciesResource
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# AdminCurrenciesResource
|
|
|
|
This class is used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies). All its method
|
|
are available in the JS Client under the `medusa.admin.currencies` property.
|
|
|
|
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).
|
|
|
|
A store can use unlimited currencies, and each region must be associated with at least one currency.
|
|
Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.
|
|
|
|
Related Guide: [How to manage currencies](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-currencies).
|
|
|
|
## Methods
|
|
|
|
### list
|
|
|
|
Retrieve a list of currencies. The currencies can be filtered by fields such as `code`. The currencies can also be sorted or paginated.
|
|
|
|
#### Example
|
|
|
|
To list currencies:
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.currencies.list().then(({ currencies, count, offset, limit }) => {
|
|
console.log(currencies.length)
|
|
})
|
|
```
|
|
|
|
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.currencies
|
|
.list({
|
|
limit,
|
|
offset,
|
|
})
|
|
.then(({ currencies, count, offset, limit }) => {
|
|
console.log(currencies.length)
|
|
})
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "query",
|
|
"type": "[AdminGetCurrenciesParams](../internal/classes/internal.AdminGetCurrenciesParams.mdx)",
|
|
"description": "Filters and pagination configurations to apply on retrieved currencies.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "code",
|
|
"type": "`string`",
|
|
"description": "Code to filter currencies by.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "includes_tax",
|
|
"type": "`boolean`",
|
|
"description": "Filter currencies by whether they include tax.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"featureFlag": "tax_inclusive_pricing",
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "limit",
|
|
"type": "`number`",
|
|
"description": "Limit the number of items returned in the list.",
|
|
"optional": true,
|
|
"defaultValue": "20",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "offset",
|
|
"type": "`number`",
|
|
"description": "The number of items to skip when retrieving a list.",
|
|
"optional": true,
|
|
"defaultValue": "0",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "order",
|
|
"type": "`string`",
|
|
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`. By default, the returned currencies will be sorted by their `created_at` field.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, any>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminCurrenciesListRes](../internal/types/internal.AdminCurrenciesListRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the list of currencies with pagination fields.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminCurrenciesListRes",
|
|
"type": "[PaginatedResponse](../internal/interfaces/internal.PaginatedResponse.mdx) & `{ currencies: [Currency](../internal/classes/internal.Currency.mdx)[] }`",
|
|
"description": "List of currencies with pagination fields.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "count",
|
|
"type": "`number`",
|
|
"description": "The total number of items available.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "limit",
|
|
"type": "`number`",
|
|
"description": "The maximum number of items that can be returned in the list.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "offset",
|
|
"type": "`number`",
|
|
"description": "The number of items skipped before the returned items in the list.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "currencies",
|
|
"type": "[Currency](../internal/classes/internal.Currency.mdx)[]",
|
|
"description": "An array of currency details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "code",
|
|
"type": "`string`",
|
|
"description": "The 3 character ISO code for the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "includes_tax",
|
|
"type": "`boolean`",
|
|
"description": "Whether the currency prices include tax",
|
|
"optional": true,
|
|
"defaultValue": "false",
|
|
"expandable": false,
|
|
"featureFlag": "tax_inclusive_pricing",
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The written name of the currency",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol",
|
|
"type": "`string`",
|
|
"description": "The symbol used to indicate the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol_native",
|
|
"type": "`string`",
|
|
"description": "The native symbol used to indicate the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### update
|
|
|
|
Update a Currency's details.
|
|
|
|
#### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.currencies
|
|
.update(code, {
|
|
includes_tax: true,
|
|
})
|
|
.then(({ currency }) => {
|
|
console.log(currency.code)
|
|
})
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "code",
|
|
"type": "`string`",
|
|
"description": "The code of the currency to update.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payload",
|
|
"type": "[AdminPostCurrenciesCurrencyReq](../internal/classes/internal.AdminPostCurrenciesCurrencyReq.mdx)",
|
|
"description": "The attributes to update in the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "includes_tax",
|
|
"type": "`boolean`",
|
|
"description": "Tax included in prices of currency.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"featureFlag": "tax_inclusive_pricing",
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, any>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminCurrenciesRes](../internal/types/internal.AdminCurrenciesRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the currency's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminCurrenciesRes",
|
|
"type": "`object`",
|
|
"description": "A currency's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "currency",
|
|
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
|
|
"description": "Currency details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "code",
|
|
"type": "`string`",
|
|
"description": "The 3 character ISO code for the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "includes_tax",
|
|
"type": "`boolean`",
|
|
"description": "Whether the currency prices include tax",
|
|
"optional": true,
|
|
"defaultValue": "false",
|
|
"expandable": false,
|
|
"featureFlag": "tax_inclusive_pricing",
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The written name of the currency",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol",
|
|
"type": "`string`",
|
|
"description": "The symbol used to indicate the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "symbol_native",
|
|
"type": "`string`",
|
|
"description": "The native symbol used to indicate the currency.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|