docs: update api-reference project for v2 (#7307)
* remove everything v1 and make v2 default * move main v2 rewrites to book * move rewrites to book + other fixes
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged in
|
||||
medusa.admin.auth.deleteSession()
|
||||
@@ -1,7 +0,0 @@
|
||||
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.auth.getSession()
|
||||
.then(({ user }) => {
|
||||
console.log(user.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.admin.auth.createSession({
|
||||
email: "user@example.com",
|
||||
password: "supersecret"
|
||||
})
|
||||
.then(({ user }) => {
|
||||
console.log(user.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.admin.auth.getToken({
|
||||
email: 'user@example.com',
|
||||
password: 'supersecret'
|
||||
})
|
||||
.then(({ access_token }) => {
|
||||
console.log(access_token);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.batchJobs.list()
|
||||
.then(({ batch_jobs, limit, offset, count }) => {
|
||||
console.log(batch_jobs.length)
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
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.batchJobs.create({
|
||||
type: 'product-export',
|
||||
context: {},
|
||||
dry_run: false
|
||||
}).then((({ batch_job }) => {
|
||||
console.log(batch_job.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.batchJobs.retrieve(batchJobId)
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.batchJobs.cancel(batchJobId)
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.batchJobs.confirm(batchJobId)
|
||||
.then(({ batch_job }) => {
|
||||
console.log(batch_job.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.collections.list()
|
||||
.then(({ collections, limit, offset, count }) => {
|
||||
console.log(collections.length);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.collections.create({
|
||||
title: "New Collection"
|
||||
})
|
||||
.then(({ collection }) => {
|
||||
console.log(collection.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.collections.delete(collectionId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.collections.retrieve(collectionId)
|
||||
.then(({ collection }) => {
|
||||
console.log(collection.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.collections.update(collectionId, {
|
||||
title: "New Collection"
|
||||
})
|
||||
.then(({ collection }) => {
|
||||
console.log(collection.id);
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
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.collections.removeProducts(collectionId, {
|
||||
product_ids: [
|
||||
productId1,
|
||||
productId2
|
||||
]
|
||||
})
|
||||
.then(({ id, object, removed_products }) => {
|
||||
console.log(removed_products)
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
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.collections.addProducts(collectionId, {
|
||||
product_ids: [
|
||||
productId1,
|
||||
productId2
|
||||
]
|
||||
})
|
||||
.then(({ collection }) => {
|
||||
console.log(collection.products)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customerGroups.list()
|
||||
.then(({ customer_groups, limit, offset, count }) => {
|
||||
console.log(customer_groups.length);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.customerGroups.create({
|
||||
name: "VIP"
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customerGroups.delete(customerGroupId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customerGroups.retrieve(customerGroupId)
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.customerGroups.update(customerGroupId, {
|
||||
name: "VIP"
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customerGroups.listCustomers(customerGroupId)
|
||||
.then(({ customers }) => {
|
||||
console.log(customers.length);
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
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.customerGroups.removeCustomers(customerGroupId, {
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
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.customerGroups.addCustomers(customerGroupId, {
|
||||
customer_ids: [
|
||||
{
|
||||
id: customerId
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ customer_group }) => {
|
||||
console.log(customer_group.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customers.list()
|
||||
.then(({ customers, limit, offset, count }) => {
|
||||
console.log(customers.length);
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
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.customers.create({
|
||||
email: "user@example.com",
|
||||
first_name: "Caterina",
|
||||
last_name: "Yost",
|
||||
password: "supersecret"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.customers.retrieve(customerId)
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.customers.update(customerId, {
|
||||
first_name: "Dolly"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.list()
|
||||
.then(({ discounts, limit, offset, count }) => {
|
||||
console.log(discounts.id);
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
import { AllocationType, DiscountRuleType } from "@medusajs/medusa"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.discounts.create({
|
||||
code: "TEST",
|
||||
rule: {
|
||||
type: DiscountRuleType.FIXED,
|
||||
value: 10,
|
||||
allocation: AllocationType.ITEM
|
||||
},
|
||||
regions: ["reg_XXXXXXXX"],
|
||||
is_dynamic: false,
|
||||
is_disabled: false
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.retrieveByCode(code)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
import { DiscountConditionOperator } from "@medusajs/medusa"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.discounts.createCondition(discountId, {
|
||||
operator: DiscountConditionOperator.IN,
|
||||
products: [productId]
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.deleteCondition(discountId, conditionId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.getCondition(discountId, conditionId)
|
||||
.then(({ discount_condition }) => {
|
||||
console.log(discount_condition.id);
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
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.discounts.updateCondition(discountId, conditionId, {
|
||||
products: [
|
||||
productId
|
||||
]
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.discounts.deleteConditionResourceBatch(discountId, conditionId, {
|
||||
resources: [{ id: itemId }]
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.discounts.addConditionResourceBatch(discountId, conditionId, {
|
||||
resources: [{ id: itemId }]
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.delete(discountId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.retrieve(discountId)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.discounts.update(discountId, {
|
||||
code: "TEST"
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
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.discounts.createDynamicCode(discountId, {
|
||||
code: "TEST",
|
||||
usage_limit: 1
|
||||
})
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.deleteDynamicCode(discountId, code)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.removeRegion(discountId, regionId)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.discounts.addRegion(discountId, regionId)
|
||||
.then(({ discount }) => {
|
||||
console.log(discount.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.draftOrders.list()
|
||||
.then(({ draft_orders, limit, offset, count }) => {
|
||||
console.log(draft_orders.length);
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
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.draftOrders.create({
|
||||
email: "user@example.com",
|
||||
region_id,
|
||||
items: [
|
||||
{
|
||||
quantity: 1
|
||||
}
|
||||
],
|
||||
shipping_methods: [
|
||||
{
|
||||
option_id
|
||||
}
|
||||
],
|
||||
})
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.draftOrders.delete(draftOrderId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.draftOrders.retrieve(draftOrderId)
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.draftOrders.update(draftOrderId, {
|
||||
email: "user@example.com"
|
||||
})
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.draftOrders.addLineItem(draftOrderId, {
|
||||
quantity: 1
|
||||
})
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.draftOrders.removeLineItem(draftOrderId, itemId)
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.draftOrders.updateLineItem(draftOrderId, lineId, {
|
||||
quantity: 1
|
||||
})
|
||||
.then(({ draft_order }) => {
|
||||
console.log(draft_order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.draftOrders.markPaid(draftOrderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.giftCards.list()
|
||||
.then(({ gift_cards, limit, offset, count }) => {
|
||||
console.log(gift_cards.length);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.giftCards.create({
|
||||
region_id
|
||||
})
|
||||
.then(({ gift_card }) => {
|
||||
console.log(gift_card.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.giftCards.delete(giftCardId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.giftCards.retrieve(giftCardId)
|
||||
.then(({ gift_card }) => {
|
||||
console.log(gift_card.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.giftCards.update(giftCardId, {
|
||||
region_id
|
||||
})
|
||||
.then(({ gift_card }) => {
|
||||
console.log(gift_card.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.inventoryItems.list()
|
||||
.then(({ inventory_items, count, offset, limit }) => {
|
||||
console.log(inventory_items.length);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.inventoryItems.create({
|
||||
variant_id: "variant_123",
|
||||
})
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.inventoryItems.delete(inventoryItemId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.inventoryItems.retrieve(inventoryItemId)
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.inventoryItems.update(inventoryItemId, {
|
||||
origin_country: "US",
|
||||
})
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.inventoryItems.listLocationLevels(inventoryItemId)
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.location_levels);
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
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.inventoryItems.createLocationLevel(inventoryItemId, {
|
||||
location_id: "sloc_123",
|
||||
stocked_quantity: 10,
|
||||
})
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.inventoryItems.deleteLocationLevel(inventoryItemId, locationId)
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.inventoryItems.updateLocationLevel(inventoryItemId, locationId, {
|
||||
stocked_quantity: 15,
|
||||
})
|
||||
.then(({ inventory_item }) => {
|
||||
console.log(inventory_item.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.invites.list()
|
||||
.then(({ invites }) => {
|
||||
console.log(invites.length);
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
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.invites.create({
|
||||
user: "user@example.com",
|
||||
role: "admin"
|
||||
})
|
||||
.then(() => {
|
||||
// successful
|
||||
})
|
||||
.catch(() => {
|
||||
// an error occurred
|
||||
})
|
||||
@@ -1,17 +0,0 @@
|
||||
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.invites.accept({
|
||||
token,
|
||||
user: {
|
||||
first_name: "Brigitte",
|
||||
last_name: "Collier",
|
||||
password: "supersecret"
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// successful
|
||||
})
|
||||
.catch(() => {
|
||||
// an error occurred
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.invites.delete(inviteId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
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.invites.resend(inviteId)
|
||||
.then(() => {
|
||||
// successful
|
||||
})
|
||||
.catch(() => {
|
||||
// an error occurred
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.notes.list()
|
||||
.then(({ notes, limit, offset, count }) => {
|
||||
console.log(notes.length);
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
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.notes.create({
|
||||
resource_id,
|
||||
resource_type: "order",
|
||||
value: "We delivered this order"
|
||||
})
|
||||
.then(({ note }) => {
|
||||
console.log(note.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.notes.delete(noteId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.notes.retrieve(noteId)
|
||||
.then(({ note }) => {
|
||||
console.log(note.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.notes.update(noteId, {
|
||||
value: "We delivered this order"
|
||||
})
|
||||
.then(({ note }) => {
|
||||
console.log(note.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.notifications.list()
|
||||
.then(({ notifications }) => {
|
||||
console.log(notifications.length);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.notifications.resend(notificationId)
|
||||
.then(({ notification }) => {
|
||||
console.log(notification.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.list()
|
||||
.then(({ order_edits, count, limit, offset }) => {
|
||||
console.log(order_edits.length)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.create({ orderId })
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.delete(orderEditId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.retrieve(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.orderEdits.update(orderEditId, {
|
||||
internal_note: "internal reason XY"
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.cancel(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.deleteItemChange(orderEdit_id, itemChangeId)
|
||||
.then(({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.confirm(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
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.orderEdits.addLineItem(orderEditId, {
|
||||
variant_id,
|
||||
quantity
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.removeLineItem(orderEditId, lineItemId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.orderEdits.updateLineItem(orderEditId, lineItemId, {
|
||||
quantity: 5
|
||||
})
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orderEdits.requestConfirmation(orderEditId)
|
||||
.then({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orders.list()
|
||||
.then(({ orders, limit, offset, count }) => {
|
||||
console.log(orders.length);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orders.retrieve(orderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
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.orders.update(orderId, {
|
||||
email: "user@example.com"
|
||||
})
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orders.archive(orderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orders.cancel(orderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
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.orders.capturePayment(orderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
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.orders.createClaim(orderId, {
|
||||
type: 'refund',
|
||||
claim_items: [
|
||||
{
|
||||
item_id,
|
||||
quantity: 1
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user