chore(docs): Generated API Reference (#4706)
Co-authored-by: olivermrbl <olivermrbl@users.noreply.github.com> Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
This commit is contained in:
committed by
GitHub
parent
efdea04963
commit
658339767b
@@ -1,8 +1,8 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.auth.authenticate({
|
||||
email: 'user@example.com',
|
||||
password: 'user@example.com'
|
||||
email: "user@example.com",
|
||||
password: "user@example.com"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.auth.exists('user@example.com')
|
||||
medusa.auth.exists("user@example.com")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.retrieve(cart_id)
|
||||
medusa.carts.retrieve(cartId)
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.update(cart_id, {
|
||||
email: 'user@example.com'
|
||||
medusa.carts.update(cartId, {
|
||||
email: "user@example.com"
|
||||
})
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.complete(cart_id)
|
||||
medusa.carts.complete(cartId)
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.deleteDiscount(cart_id, code)
|
||||
medusa.carts.deleteDiscount(cartId, code)
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.lineItems.delete(cart_id, line_id)
|
||||
medusa.carts.lineItems.delete(cartId, lineId)
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.lineItems.update(cart_id, line_id, {
|
||||
medusa.carts.lineItems.update(cartId, lineId, {
|
||||
quantity: 1
|
||||
})
|
||||
.then(({ cart }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.setPaymentSession(cart_id, {
|
||||
provider_id: 'manual'
|
||||
medusa.carts.setPaymentSession(cartId, {
|
||||
provider_id: "manual"
|
||||
})
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.createPaymentSessions(cart_id)
|
||||
medusa.carts.createPaymentSessions(cartId)
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.deletePaymentSession(cart_id, 'manual')
|
||||
medusa.carts.deletePaymentSession(cartId, "manual")
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.updatePaymentSession(cart_id, 'manual', {
|
||||
medusa.carts.updatePaymentSession(cartId, "manual", {
|
||||
data: {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.refreshPaymentSession(cart_id, 'manual')
|
||||
medusa.carts.refreshPaymentSession(cartId, "manual")
|
||||
.then(({ cart }) => {
|
||||
console.log(cart.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.carts.addShippingMethod(cart_id, {
|
||||
medusa.carts.addShippingMethod(cartId, {
|
||||
option_id
|
||||
})
|
||||
.then(({ cart }) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.collections.retrieve(collection_id)
|
||||
medusa.collections.retrieve(collectionId)
|
||||
.then(({ collection }) => {
|
||||
console.log(collection.id);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.customers.create({
|
||||
first_name: 'Alec',
|
||||
last_name: 'Reynolds',
|
||||
email: 'user@example.com',
|
||||
password: 'supersecret'
|
||||
first_name: "Alec",
|
||||
last_name: "Reynolds",
|
||||
email: "user@example.com",
|
||||
password: "supersecret"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
|
||||
@@ -2,7 +2,7 @@ import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged
|
||||
medusa.customers.update({
|
||||
first_name: 'Laury'
|
||||
first_name: "Laury"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
|
||||
@@ -3,17 +3,15 @@ const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged
|
||||
medusa.customers.addresses.addAddress({
|
||||
address: {
|
||||
first_name: 'Celia',
|
||||
last_name: 'Schumm',
|
||||
address_1: '225 Bednar Curve',
|
||||
city: 'Danielville',
|
||||
country_code: 'US',
|
||||
postal_code: '85137',
|
||||
phone: '981-596-6748 x90188',
|
||||
company: 'Wyman LLC',
|
||||
address_2: '',
|
||||
province: 'Georgia',
|
||||
metadata: {}
|
||||
first_name: "Celia",
|
||||
last_name: "Schumm",
|
||||
address_1: "225 Bednar Curve",
|
||||
city: "Danielville",
|
||||
country_code: "US",
|
||||
postal_code: "85137",
|
||||
phone: "981-596-6748 x90188",
|
||||
company: "Wyman LLC",
|
||||
province: "Georgia",
|
||||
}
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged
|
||||
medusa.customers.addresses.deleteAddress(address_id)
|
||||
medusa.customers.addresses.deleteAddress(addressId)
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
// must be previously logged
|
||||
medusa.customers.addresses.updateAddress(address_id, {
|
||||
first_name: 'Gina'
|
||||
medusa.customers.addresses.updateAddress(addressId, {
|
||||
first_name: "Gina"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.customers.resetPassword({
|
||||
email: 'user@example.com',
|
||||
password: 'supersecret',
|
||||
token: 'supersecrettoken'
|
||||
email: "user@example.com",
|
||||
password: "supersecret",
|
||||
token: "supersecrettoken"
|
||||
})
|
||||
.then(({ customer }) => {
|
||||
console.log(customer.id);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.customers.generatePasswordToken({
|
||||
email: 'user@example.com'
|
||||
email: "user@example.com"
|
||||
})
|
||||
.then(() => {
|
||||
// successful
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orderEdits.retrieve(order_edit_id)
|
||||
medusa.orderEdits.retrieve(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orderEdits.complete(order_edit_id)
|
||||
medusa.orderEdits.complete(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orderEdits.decline(order_edit_id)
|
||||
medusa.orderEdits.decline(orderEditId)
|
||||
.then(({ order_edit }) => {
|
||||
console.log(order_edit.id);
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orders.lookupOrder({
|
||||
display_id: 1,
|
||||
email: 'user@example.com'
|
||||
email: "user@example.com"
|
||||
})
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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.orders.claimOrders({
|
||||
display_ids,
|
||||
medusa.orders.requestCustomerOrders({
|
||||
order_ids,
|
||||
})
|
||||
.then(() => {
|
||||
// successful
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orders.retrieveByCartId(cart_id)
|
||||
medusa.orders.retrieveByCartId(cartId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.orders.retrieve(order_id)
|
||||
medusa.orders.retrieve(orderId)
|
||||
.then(({ order }) => {
|
||||
console.log(order.id);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
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
|
||||
|
||||
// Total amount = 10000
|
||||
|
||||
// Adding a payment session
|
||||
medusa.paymentCollections.managePaymentSession(payment_id, { provider_id: "stripe" })
|
||||
.then(({ payment_collection }) => {
|
||||
console.log(payment_collection.id);
|
||||
|
||||
@@ -4,29 +4,33 @@ const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
|
||||
// Total amount = 10000
|
||||
|
||||
// Adding two new sessions
|
||||
medusa.paymentCollections.managePaymentSessionsBatch(payment_id, [
|
||||
{
|
||||
provider_id: "stripe",
|
||||
amount: 5000,
|
||||
},
|
||||
{
|
||||
provider_id: "manual",
|
||||
amount: 5000,
|
||||
},
|
||||
])
|
||||
// Example 1: Adding two new sessions
|
||||
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
|
||||
sessions: [
|
||||
{
|
||||
provider_id: "stripe",
|
||||
amount: 5000,
|
||||
},
|
||||
{
|
||||
provider_id: "manual",
|
||||
amount: 5000,
|
||||
},
|
||||
]
|
||||
})
|
||||
.then(({ payment_collection }) => {
|
||||
console.log(payment_collection.id);
|
||||
});
|
||||
|
||||
// Updating one session and removing the other
|
||||
medusa.paymentCollections.managePaymentSessionsBatch(payment_id, [
|
||||
{
|
||||
provider_id: "stripe",
|
||||
amount: 10000,
|
||||
session_id: "ps_123456"
|
||||
},
|
||||
])
|
||||
// Example 2: Updating one session and removing the other
|
||||
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
|
||||
sessions: [
|
||||
{
|
||||
provider_id: "stripe",
|
||||
amount: 10000,
|
||||
session_id: "ps_123456"
|
||||
},
|
||||
]
|
||||
})
|
||||
.then(({ payment_collection }) => {
|
||||
console.log(payment_collection.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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.paymentCollections.authorize(payment_id)
|
||||
medusa.paymentCollections.authorize(paymentId)
|
||||
.then(({ payment_collection }) => {
|
||||
console.log(payment_collection.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.paymentCollections.refreshPaymentSession(payment_collection_id, session_id)
|
||||
medusa.paymentCollections.refreshPaymentSession(paymentCollectionId, sessionId)
|
||||
.then(({ payment_session }) => {
|
||||
console.log(payment_session.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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.paymentCollections.authorize(payment_id, session_id)
|
||||
medusa.paymentCollections.authorize(paymentId, sessionId)
|
||||
.then(({ payment_collection }) => {
|
||||
console.log(payment_collection.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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.productCategories.retrieve(product_category_id)
|
||||
medusa.productCategories.retrieve(productCategoryId)
|
||||
.then(({ product_category }) => {
|
||||
console.log(product_category.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.products.search({
|
||||
q: 'Shirt'
|
||||
q: "Shirt"
|
||||
})
|
||||
.then(({ hits }) => {
|
||||
console.log(hits.length);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.products.retrieve(product_id)
|
||||
medusa.products.retrieve(productId)
|
||||
.then(({ product }) => {
|
||||
console.log(product.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.regions.retrieve(region_id)
|
||||
medusa.regions.retrieve(regionId)
|
||||
.then(({ region }) => {
|
||||
console.log(region.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.returnReasons.retrieve(reason_id)
|
||||
medusa.returnReasons.retrieve(reasonId)
|
||||
.then(({ return_reason }) => {
|
||||
console.log(return_reason.id);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.shippingOptions.listCartOptions(cart_id)
|
||||
medusa.shippingOptions.listCartOptions(cartId)
|
||||
.then(({ shipping_options }) => {
|
||||
console.log(shipping_options.length);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
||||
medusa.swaps.retrieveByCartId(cart_id)
|
||||
medusa.swaps.retrieveByCartId(cartId)
|
||||
.then(({ swap }) => {
|
||||
console.log(swap.id);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user