chore(docs): added eslint to lint documentation code blocks (#2920)
* docs: added rule for code length * chore: fixes based on vale errors * changed to use eslint * fixes using eslint * added github action for documentation eslint * changed allowed max-length * fixed incorrect heading level * removed comment
This commit is contained in:
@@ -68,31 +68,31 @@ You can do that by sending the following request to the [Upload Files](https://d
|
||||
<TabItem value="client" label="Medusa JS Client" default>
|
||||
|
||||
```jsx
|
||||
medusa.admin.uploads.create(file) //file is an instance of File
|
||||
medusa.admin.uploads.create(file) // file is an instance of File
|
||||
.then(({ uploads }) => {
|
||||
const key = uploads[0].key;
|
||||
});
|
||||
const key = uploads[0].key
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
const formData = new FormData();
|
||||
formData.append('files', file); //file is an instance of File
|
||||
const formData = new FormData()
|
||||
formData.append("files", file) // file is an instance of File
|
||||
|
||||
fetch(`<YOUR_SERVER>/admin/uploads`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
body: formData
|
||||
body: formData,
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ uploads }) => {
|
||||
const key = uploads[0].key;
|
||||
});
|
||||
const key = uploads[0].key
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -123,16 +123,16 @@ You can do that by sending the following request to the [Create a Batch Job](htt
|
||||
|
||||
```jsx
|
||||
medusa.admin.batchJobs.create({
|
||||
type: 'price-list-import',
|
||||
type: "price-list-import",
|
||||
context: {
|
||||
fileKey: key, //obtained from previous step
|
||||
price_list_id
|
||||
fileKey: key, // obtained from previous step
|
||||
price_list_id,
|
||||
},
|
||||
dry_run: true
|
||||
dry_run: true,
|
||||
})
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -140,24 +140,24 @@ medusa.admin.batchJobs.create({
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
type: 'price-list-import',
|
||||
type: "price-list-import",
|
||||
context: {
|
||||
fileKey: key, //obtained from previous step
|
||||
price_list_id
|
||||
fileKey: key, // obtained from previous step
|
||||
price_list_id,
|
||||
},
|
||||
dry_run: true
|
||||
})
|
||||
dry_run: true,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -212,8 +212,8 @@ You can retrieve all the details of the batch job, including its status and the
|
||||
```jsx
|
||||
medusa.admin.batchJobs.retrieve(batchJobId)
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status, batch_job.result);
|
||||
});
|
||||
console.log(batch_job.status, batch_job.result)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -221,12 +221,12 @@ medusa.admin.batchJobs.retrieve(batchJobId)
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status, batch_job.result);
|
||||
});
|
||||
console.log(batch_job.status, batch_job.result)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -257,7 +257,7 @@ Here’s an example of the `result` property:
|
||||
"message": "5 prices will be added"
|
||||
}
|
||||
],
|
||||
"advancement_count": 0 //number of prices processed so far. Will be 0 before the import is confirmed.
|
||||
"advancement_count": 0 //number of prices processed so far.
|
||||
},
|
||||
```
|
||||
|
||||
@@ -275,8 +275,8 @@ To confirm a batch job send the following request:
|
||||
```jsx
|
||||
medusa.admin.batchJobs.confirm(batchJobId)
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -284,13 +284,13 @@ medusa.admin.batchJobs.confirm(batchJobId)
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}/confirm`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -62,31 +62,31 @@ You can do that by sending the following request to the [Upload Files](https://d
|
||||
<TabItem value="client" label="Medusa JS Client" default>
|
||||
|
||||
```jsx
|
||||
medusa.admin.uploads.create(file) //file is an instance of File
|
||||
medusa.admin.uploads.create(file) // file is an instance of File
|
||||
.then(({ uploads }) => {
|
||||
const key = uploads[0].key;
|
||||
});
|
||||
const key = uploads[0].key
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
const formData = new FormData();
|
||||
formData.append('files', file); //file is an instance of File
|
||||
const formData = new FormData()
|
||||
formData.append("files", file) // file is an instance of File
|
||||
|
||||
fetch(`<YOUR_SERVER>/admin/uploads`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
body: formData
|
||||
body: formData,
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ uploads }) => {
|
||||
const key = uploads[0].key;
|
||||
});
|
||||
const key = uploads[0].key
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -117,15 +117,15 @@ You can do that by sending the following request to the [Create a Batch Job](htt
|
||||
|
||||
```jsx
|
||||
medusa.admin.batchJobs.create({
|
||||
type: 'product-import',
|
||||
type: "product-import",
|
||||
context: {
|
||||
fileKey: key //obtained from previous step
|
||||
fileKey: key, // obtained from previous step
|
||||
},
|
||||
dry_run: true
|
||||
dry_run: true,
|
||||
})
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -133,23 +133,23 @@ medusa.admin.batchJobs.create({
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
type: 'product-import',
|
||||
type: "product-import",
|
||||
context: {
|
||||
fileKey: key //obtained from previous step
|
||||
fileKey: key, // obtained from previous step
|
||||
},
|
||||
dry_run: true
|
||||
})
|
||||
dry_run: true,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -200,8 +200,8 @@ You can retrieve all the details of the batch job, including its status and the
|
||||
```jsx
|
||||
medusa.admin.batchJobs.retrieve(batchJobId)
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status, batch_job.result);
|
||||
});
|
||||
console.log(batch_job.status, batch_job.result)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -209,12 +209,12 @@ medusa.admin.batchJobs.retrieve(batchJobId)
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status, batch_job.result);
|
||||
});
|
||||
console.log(batch_job.status, batch_job.result)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -242,10 +242,10 @@ Here’s an example of the `result` property:
|
||||
{
|
||||
"key": "product-import-count",
|
||||
"name": "Products/variants to import",
|
||||
"message": "There will be 2 products created (0 updated).\n 3 variants will be created and 0 updated"
|
||||
"message": "There will be 2 products created..."
|
||||
}
|
||||
],
|
||||
"advancement_count": 0 //number of products processed so far. Will be 0 before the import is confirmed.
|
||||
"advancement_count": 0 //number of products processed so far.
|
||||
},
|
||||
```
|
||||
|
||||
@@ -263,8 +263,8 @@ To confirm a batch job send the following request:
|
||||
```jsx
|
||||
medusa.admin.batchJobs.confirm(batchJobId)
|
||||
.then(( batch_job ) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -272,13 +272,13 @@ medusa.admin.batchJobs.confirm(batchJobId)
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}/confirm`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.status);
|
||||
});
|
||||
console.log(batch_job.status)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -49,8 +49,8 @@ You can show a list of customers by sending a request to the [List Customers](/a
|
||||
```ts
|
||||
medusa.admin.customers.list()
|
||||
.then(({ customers, limit, offset, count }) => {
|
||||
console.log(customers.length);
|
||||
});
|
||||
console.log(customers.length)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -58,12 +58,12 @@ medusa.admin.customers.list()
|
||||
|
||||
```ts
|
||||
fetch(`<SERVER_URL>/admin/customers`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customers, limit, offset, count }) => {
|
||||
console.log(customers.length);
|
||||
});
|
||||
console.log(customers.length)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -108,11 +108,11 @@ medusa.admin.customers.create({
|
||||
email,
|
||||
password,
|
||||
first_name,
|
||||
last_name
|
||||
last_name,
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
});
|
||||
console.log(customer.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -120,19 +120,19 @@ medusa.admin.customers.create({
|
||||
|
||||
```ts
|
||||
fetch(`<SERVER_URL>/admin/customers`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
password,
|
||||
first_name,
|
||||
last_name
|
||||
})
|
||||
last_name,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
});
|
||||
console.log(customer.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -177,11 +177,11 @@ You can edit a customer’s information by sending a request to the [Update a Cu
|
||||
|
||||
```ts
|
||||
medusa.admin.customers.update(customerId, {
|
||||
first_name
|
||||
first_name,
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
});
|
||||
console.log(customer.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -189,16 +189,16 @@ medusa.admin.customers.update(customerId, {
|
||||
|
||||
```ts
|
||||
fetch(`<SERVER_URL>/admin/customers/${customerId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
first_name
|
||||
})
|
||||
first_name,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
});
|
||||
console.log(customer.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -60,21 +60,21 @@ You can create a discount by sending a request to the [Create Discount](/api/adm
|
||||
|
||||
```jsx
|
||||
import { AllocationType, DiscountRuleType } from "@medusajs/medusa"
|
||||
//...
|
||||
// ...
|
||||
medusa.admin.discounts.create({
|
||||
code,
|
||||
rule: {
|
||||
type: DiscountRuleType.FIXED,
|
||||
value: 10,
|
||||
allocation: AllocationType.ITEM
|
||||
allocation: AllocationType.ITEM,
|
||||
},
|
||||
regions: [
|
||||
regionId
|
||||
]
|
||||
regionId,
|
||||
],
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -82,27 +82,27 @@ medusa.admin.discounts.create({
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
code,
|
||||
rule: {
|
||||
type: 'fixed',
|
||||
type: "fixed",
|
||||
value: 10,
|
||||
allocation: 'item'
|
||||
allocation: "item",
|
||||
},
|
||||
regions: [
|
||||
regionId
|
||||
]
|
||||
})
|
||||
regionId,
|
||||
],
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -153,11 +153,11 @@ For example, you can update the discount’s description and status by sending t
|
||||
```jsx
|
||||
medusa.admin.discounts.update(discountId, {
|
||||
description: "New description",
|
||||
is_disabled: true
|
||||
is_disabled: true,
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -165,20 +165,20 @@ medusa.admin.discounts.update(discountId, {
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
description: "New description",
|
||||
is_disabled: true
|
||||
})
|
||||
is_disabled: true,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -222,16 +222,16 @@ You can send a request to the [Create Condition](/api/admin/#tag/Discount-Condit
|
||||
|
||||
```jsx
|
||||
import { DiscountConditionOperator } from "@medusajs/medusa"
|
||||
//...
|
||||
// ...
|
||||
medusa.admin.discounts.createCondition(discount_id, {
|
||||
operator: DiscountConditionOperator.IN,
|
||||
products: [
|
||||
productId
|
||||
]
|
||||
productId,
|
||||
],
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -239,22 +239,22 @@ medusa.admin.discounts.createCondition(discount_id, {
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}/conditions`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
operator: 'in',
|
||||
operator: "in",
|
||||
products: [
|
||||
productId
|
||||
]
|
||||
})
|
||||
productId,
|
||||
],
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -301,24 +301,28 @@ You can retrieve a condition and its resources by sending a request to the [Get
|
||||
|
||||
```jsx
|
||||
medusa.admin.discounts.getCondition(discountId, conditionId, {
|
||||
expand: 'products'
|
||||
expand: "products",
|
||||
})
|
||||
.then(({ discount_condition }) => {
|
||||
console.log(discount_condition.id, discount_condition.products);
|
||||
});
|
||||
console.log(discount_condition.id, discount_condition.products)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}/conditions/${conditionId}&expand=products`, {
|
||||
credentials: 'include'
|
||||
})
|
||||
fetch(
|
||||
`<YOUR_SERVER>/admin/discounts/${discountId}` +
|
||||
`/conditions/${conditionId}&expand=products`,
|
||||
{
|
||||
credentials: "include",
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ discount_condition }) => {
|
||||
console.log(discount_condition.id, discount_condition.products);
|
||||
});
|
||||
console.log(discount_condition.id, discount_condition.products)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -351,35 +355,38 @@ For example, to update the products in a condition:
|
||||
medusa.admin.discounts.updateCondition(discountId, conditionId, {
|
||||
products: [
|
||||
productId1,
|
||||
productId2
|
||||
]
|
||||
productId2,
|
||||
],
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}/conditions/${conditionId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
products: [
|
||||
productId1,
|
||||
productId2
|
||||
]
|
||||
})
|
||||
})
|
||||
fetch(
|
||||
`<YOUR_SERVER>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
products: [
|
||||
productId1,
|
||||
productId2,
|
||||
],
|
||||
}),
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -416,22 +423,25 @@ You can delete a condition by sending a request to the [Delete Condition](/api/a
|
||||
```jsx
|
||||
medusa.admin.discounts.deleteCondition(discountId, conditionId)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount);
|
||||
});
|
||||
console.log(discount)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}/conditions/${conditionId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
})
|
||||
fetch(
|
||||
`<YOUR_SERVER>/admin/discounts/${discountId}/conditions/${conditionId}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
});
|
||||
console.log(discount.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -461,8 +471,8 @@ You can delete a discount by sending a request to the [Delete Discount](/api/adm
|
||||
```jsx
|
||||
medusa.admin.discounts.delete(discount_id)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -470,13 +480,13 @@ medusa.admin.discounts.delete(discount_id)
|
||||
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/discounts/${discountId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -57,9 +57,9 @@ You can retrieve regions available on your server using the [List Regions](/api/
|
||||
```tsx
|
||||
medusa.admin.regions.list()
|
||||
.then(({ regions, limit, offset, count }) => {
|
||||
console.log(regions.length);
|
||||
//display regions
|
||||
});
|
||||
console.log(regions.length)
|
||||
// display regions
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -67,13 +67,13 @@ medusa.admin.regions.list()
|
||||
|
||||
```tsx
|
||||
fetch(`<SERVER_URL>/admin/regions`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ regions, limit, offset, count }) => {
|
||||
console.log(regions.length);
|
||||
//display regions
|
||||
});
|
||||
console.log(regions.length)
|
||||
// display regions
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -102,22 +102,22 @@ You can create a region by sending a request to the [Create a Region](/api/admin
|
||||
|
||||
```tsx
|
||||
medusa.admin.regions.create({
|
||||
name: 'Europe',
|
||||
currency_code: 'eur',
|
||||
name: "Europe",
|
||||
currency_code: "eur",
|
||||
tax_rate: 0,
|
||||
payment_providers: [
|
||||
'manual'
|
||||
"manual",
|
||||
],
|
||||
fulfillment_providers: [
|
||||
'manual'
|
||||
"manual",
|
||||
],
|
||||
countries: [
|
||||
'DK'
|
||||
]
|
||||
"DK",
|
||||
],
|
||||
})
|
||||
.then(({ region }) => {
|
||||
console.log(region.id);
|
||||
});
|
||||
console.log(region.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -125,27 +125,27 @@ medusa.admin.regions.create({
|
||||
|
||||
```tsx
|
||||
fetch(`<SERVER_URL>/admin/regions`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: 'Europe',
|
||||
currency_code: 'eur',
|
||||
name: "Europe",
|
||||
currency_code: "eur",
|
||||
tax_rate: 0,
|
||||
payment_providers: [
|
||||
'manual'
|
||||
"manual",
|
||||
],
|
||||
fulfillment_providers: [
|
||||
'manual'
|
||||
"manual",
|
||||
],
|
||||
countries: [
|
||||
'DK'
|
||||
]
|
||||
})
|
||||
"DK",
|
||||
],
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ region }) => {
|
||||
console.log(region.id);
|
||||
});
|
||||
console.log(region.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -202,12 +202,12 @@ Alternatively, you can update the details of a region using the [Update a Region
|
||||
medusa.admin.regions.update(regionId, {
|
||||
countries: [
|
||||
"DK",
|
||||
"DE"
|
||||
]
|
||||
"DE",
|
||||
],
|
||||
})
|
||||
.then(({ region }) => {
|
||||
console.log(region.id);
|
||||
});
|
||||
console.log(region.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -215,25 +215,25 @@ medusa.admin.regions.update(regionId, {
|
||||
|
||||
```tsx
|
||||
fetch(`<SERVER_URL>/admin/regions/${regionId}`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
countries: [
|
||||
'DK',
|
||||
'DE'
|
||||
]
|
||||
})
|
||||
"DK",
|
||||
"DE",
|
||||
],
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ region }) => {
|
||||
console.log(region.id);
|
||||
});
|
||||
console.log(region.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```tsx
|
||||
```bash
|
||||
curl -L -X POST '<SERVER_URL>/admin/regions/<REGION_ID>' \
|
||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
@@ -271,17 +271,17 @@ You can add a shipping option to a region by sending a request to the [Create Sh
|
||||
|
||||
```tsx
|
||||
medusa.admin.shippingOptions.create({
|
||||
name: 'PostFake',
|
||||
name: "PostFake",
|
||||
region_id: regionId,
|
||||
provider_id: "manual",
|
||||
data: {
|
||||
},
|
||||
price_type: 'flat_rate',
|
||||
amount: 1000
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
})
|
||||
.then(({ shipping_option }) => {
|
||||
console.log(shipping_option.id);
|
||||
});
|
||||
console.log(shipping_option.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -289,28 +289,28 @@ medusa.admin.shippingOptions.create({
|
||||
|
||||
```tsx
|
||||
fetch(`<SERVER_URL>/admin/shipping-options`, {
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: 'PostFake',
|
||||
name: "PostFake",
|
||||
region_id: regionId,
|
||||
provider_id: "manual",
|
||||
price_type: 'flat_rate',
|
||||
price_type: "flat_rate",
|
||||
data: {
|
||||
},
|
||||
amount: 1000
|
||||
})
|
||||
amount: 1000,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ shipping_option }) => {
|
||||
console.log(shipping_option.id);
|
||||
});
|
||||
console.log(shipping_option.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```tsx
|
||||
```bash
|
||||
curl -L -X POST '<SERVER_URL>/admin/shipping-options' \
|
||||
-H 'Authorization: Bearer <API_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
@@ -360,8 +360,8 @@ You can delete a region by sending a request to the [Delete a Region](/api/admin
|
||||
```tsx
|
||||
medusa.admin.regions.delete(regionId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -369,19 +369,19 @@ medusa.admin.regions.delete(regionId)
|
||||
|
||||
```tsx
|
||||
fetch(`<SERVER_URL>/admin/regions/${regionId}`, {
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
credentials: "include",
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```tsx
|
||||
```bash
|
||||
curl -L -X DELETE '<SERVER_URL>/admin/regions/<REGION_ID>' \
|
||||
-H 'Authorization: Bearer <API_TOKEN>'
|
||||
```
|
||||
|
||||
@@ -87,11 +87,11 @@ To do that, send a request to the [Create an OrderEdit](/api/admin/#tag/OrderEdi
|
||||
|
||||
```ts
|
||||
medusa.admin.orderEdits.create({
|
||||
order_id, //required
|
||||
order_id, // required
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id);
|
||||
});
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -99,19 +99,19 @@ medusa.admin.orderEdits.create({
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
order_id
|
||||
})
|
||||
order_id,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id);
|
||||
});
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -161,11 +161,11 @@ To add a new item to the original order, send a request to the [Add Line Item](/
|
||||
```ts
|
||||
medusa.admin.orderEdits.addLineItem(orderEditId, {
|
||||
quantity: 1,
|
||||
variant_id
|
||||
variant_id,
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -173,20 +173,20 @@ medusa.admin.orderEdits.addLineItem(orderEditId, {
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/items`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
quantity: 1,
|
||||
variant_id
|
||||
})
|
||||
variant_id,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -225,8 +225,8 @@ medusa.admin.orderEdits.updateLineItem(orderEditId, itemId, {
|
||||
quantity: 2,
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -234,19 +234,19 @@ medusa.admin.orderEdits.updateLineItem(orderEditId, itemId, {
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
quantity: 2
|
||||
})
|
||||
quantity: 2,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -280,8 +280,8 @@ You can remove an item from the original order by sending a request to the [Remo
|
||||
```ts
|
||||
medusa.admin.orderEdits.removeLineItem(orderEditId, itemId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -289,13 +289,13 @@ medusa.admin.orderEdits.removeLineItem(orderEditId, itemId)
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/items/${itemId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.changes);
|
||||
});
|
||||
console.log(order_edit.changes)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -327,22 +327,25 @@ To revert an item change, send a request to the [Delete Item Change](/api/admin/
|
||||
```ts
|
||||
medusa.admin.orderEdits.deleteItemChange(orderEditId, changeId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/changes/${changeId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
})
|
||||
fetch(
|
||||
`<YOUR_SERVER>/admin/order-edits/${orderEditId}/changes/${changeId}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id, object, deleted);
|
||||
});
|
||||
console.log(id, object, deleted)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -378,7 +381,7 @@ To move an Order Edit into the request state, send a request to the [Request Con
|
||||
```ts
|
||||
medusa.admin.orderEdits.requestConfirmation(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.requested_at, order_edit.requested_by);
|
||||
console.log(order_edit.requested_at, order_edit.requested_by)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -387,12 +390,12 @@ medusa.admin.orderEdits.requestConfirmation(orderEditId)
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/request`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.requested_at, order_edit.requested_by);
|
||||
console.log(order_edit.requested_at, order_edit.requested_by)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -445,7 +448,7 @@ To confirm an Order Edit, send a request to the [Confirm Order Edit](/api/admin/
|
||||
```ts
|
||||
medusa.admin.orderEdits.confirm(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by);
|
||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -454,12 +457,12 @@ medusa.admin.orderEdits.confirm(orderEditId)
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/order-edits/${orderEditId}/confirm`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by);
|
||||
console.log(order_edit.confirmed_at, order_edit.confirmed_by)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -507,7 +510,7 @@ If the payment is authorized by the customer, it can be captured by sending a re
|
||||
```ts
|
||||
medusa.admin.payments.capturePayment(paymentId)
|
||||
.then(({ payment }) => {
|
||||
console.log(payment.captured_at);
|
||||
console.log(payment.captured_at)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -516,12 +519,12 @@ medusa.admin.payments.capturePayment(paymentId)
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/payments/${paymentId}/capture`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ payment }) => {
|
||||
console.log(payment.captured_at);
|
||||
console.log(payment.captured_at)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -551,10 +554,10 @@ To refund the difference to the customer, send a request to the [Refund Payment]
|
||||
|
||||
```ts
|
||||
medusa.admin.payments.refundPayment(paymentId, {
|
||||
amount
|
||||
amount,
|
||||
})
|
||||
.then(({ refund }) => {
|
||||
console.log(refund.id);
|
||||
console.log(refund.id)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -563,18 +566,18 @@ medusa.admin.payments.refundPayment(paymentId, {
|
||||
|
||||
```ts
|
||||
fetch(`<YOUR_SERVER>/admin/payments/${paymentId}/refund`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
amount
|
||||
})
|
||||
amount,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ refund }) => {
|
||||
console.log(refund.id);
|
||||
console.log(refund.id)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ You can create a customer group by sending a request to the Create Customer Grou
|
||||
|
||||
```jsx
|
||||
medusa.admin.customerGroups.create({
|
||||
name: 'VIP'
|
||||
name: "VIP",
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
});
|
||||
console.log(customer_group.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -56,19 +56,19 @@ medusa.admin.customerGroups.create({
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: 'VIP'
|
||||
})
|
||||
name: "VIP",
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -100,8 +100,8 @@ You can get a list of all customer groups by sending a request to the List Custo
|
||||
```jsx
|
||||
medusa.admin.customerGroups.list()
|
||||
.then(({ customer_groups, limit, offset, count }) => {
|
||||
console.log(customer_groups.length);
|
||||
});
|
||||
console.log(customer_groups.length)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -109,12 +109,12 @@ medusa.admin.customerGroups.list()
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_groups, limit, offset, count }) => {
|
||||
console.log(customer_groups.length)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -144,8 +144,8 @@ You can retrieve a single customer group by sending a request to the Get a Custo
|
||||
```jsx
|
||||
medusa.admin.customerGroups.retrieve(customerGroupId)
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
});
|
||||
console.log(customer_group.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -153,12 +153,12 @@ medusa.admin.customerGroups.retrieve(customerGroupId)
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -186,12 +186,12 @@ You can update a customer group’s data by sending a request to the Update Cust
|
||||
```jsx
|
||||
medusa.admin.customerGroups.update(customerGroupId, {
|
||||
metadata: {
|
||||
is_seller: true
|
||||
}
|
||||
is_seller: true,
|
||||
},
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
});
|
||||
console.log(customer_group.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -199,21 +199,21 @@ medusa.admin.customerGroups.update(customerGroupId, {
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
metadata: {
|
||||
is_seller: true
|
||||
}
|
||||
})
|
||||
is_seller: true,
|
||||
},
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -247,8 +247,8 @@ You can delete a customer group by sending a request to the Delete a Customer Gr
|
||||
```jsx
|
||||
medusa.admin.customerGroups.delete(customerGroupId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
});
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -256,13 +256,13 @@ medusa.admin.customerGroups.delete(customerGroupId)
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include',
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -293,37 +293,40 @@ You can add a customer to a group by sending a request to the Customer Group’s
|
||||
medusa.admin.customerGroups.addCustomers(customerGroupId, {
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId
|
||||
}
|
||||
]
|
||||
id: customerId,
|
||||
},
|
||||
],
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
});
|
||||
console.log(customer_group.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
fetch(
|
||||
`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -357,8 +360,8 @@ You can retrieve a list of all customers in a customer group using the List Cust
|
||||
```jsx
|
||||
medusa.admin.customerGroups.listCustomers(customerGroupId)
|
||||
.then(({ customers, count, offset, limit }) => {
|
||||
console.log(customers.length);
|
||||
});
|
||||
console.log(customers.length)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -366,12 +369,12 @@ medusa.admin.customerGroups.listCustomers(customerGroupId)
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(({ customers, count, offset, limit }) => {
|
||||
console.log(customers.length)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -404,37 +407,40 @@ You can remove customers from a customer group by sending a request to the Remov
|
||||
medusa.admin.customerGroups.removeCustomers(customer_group_id, {
|
||||
customer_ids: [
|
||||
{
|
||||
id: customer_id
|
||||
}
|
||||
]
|
||||
id: customer_id,
|
||||
},
|
||||
],
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
});
|
||||
console.log(customer_group.id)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```jsx
|
||||
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
fetch(
|
||||
`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`,
|
||||
{
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
Reference in New Issue
Block a user