|
1
|
import { HttpTypes } from "@medusajs/types" |
|
2
|
import { Client } from "../client.js" |
|
3
|
import { ClientHeaders } from "../types.js" |
|
4
|
|
|
5
|
const taxProviderUrl = "/admin/tax-providers" |
|
6
|
|
|
7
|
export class TaxProvider { |
|
8
|
/** |
|
9
|
* @ignore |
|
10
|
*/ |
|
11
|
private client: Client |
|
12
|
/** |
|
13
|
* @ignore |
|
14
|
*/ |
|
15
|
constructor(client: Client) { |
|
16
|
this.client = client |
|
17
|
} |
|
18
|
|
|
19
|
/** |
|
20
|
* This method retrieves a list of tax providers. It sends a request to the |
|
21
|
* [List Tax Providers](https://docs.medusajs.com/api/admin/tax-providers/list-tax-providers) |
|
22
|
* API route. |
|
23
|
* |
|
24
|
* @since 2.8.0 |
|
25
|
* |
|
26
|
* @param query - Filters and pagination configurations. |
|
27
|
* @param headers - Headers to pass in the request. |
|
28
|
* @returns The list of tax providers. |
|
29
|
* |
|
30
|
* @example |
|
31
|
* To retrieve the list of tax providers: |
|
32
|
* |
|
33
|
* ```ts |
|
34
|
* sdk.admin.taxProvider.list() |
|
35
|
* .then(({ tax_providers, count, limit, offset }) => { |
|
36
|
* console.log(tax_providers) |
|
37
|
* }) |
|
38
|
* ``` |
|
39
|
* |
|
40
|
* To configure the pagination, pass the `limit` and `offset` query parameters. |
|
41
|
* |
|
42
|
* For example, to retrieve only 10 items and skip 10 items: |
|
43
|
* |
|
44
|
* ```ts |
|
45
|
* sdk.admin.taxProvider.list({ |
|
46
|
* limit: 10, |
|
47
|
* offset: 10, |
|
48
|
* }) |
|
49
|
* .then(({ tax_providers, count, limit, offset }) => { |
|
50
|
* console.log(tax_providers) |
|
51
|
* }) |
|
52
|
* ``` |
|
53
|
* |
|
54
|
* Using the `fields` query parameter, you can specify the fields and relations to retrieve |
|
55
|
* in each products: |
|
56
|
* |
|
57
|
* ```ts |
|
58
|
* sdk.admin.taxProvider.list({ |
|
59
|
* fields: "id,*regions" |
|
60
|
* }) |
|
61
|
* .then(({ tax_providers, count, limit, offset }) => { |
|
62
|
* console.log(tax_providers) |
|
63
|
* }) |
|
64
|
* ``` |
|
65
|
* |
|
66
|
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). |
|
67
|
*/ |
|
68
|
async list( |
|
69
|
query?: HttpTypes.AdminGetTaxProvidersParams, |
|
70
|
headers?: ClientHeaders |
|
71
|
) { |
|
72
|
return await this.client.fetch<HttpTypes.AdminTaxProviderListResponse>( |
|
73
|
taxProviderUrl, |
|
74
|
{ |
|
75
|
method: "GET", |
|
76
|
headers, |
|
77
|
query, |
|
78
|
} |
|
79
|
) |
|
80
|
} |
|
81
|
} |