Skip to content

Commit

Permalink
add some more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rmt-kirill committed Apr 10, 2024
1 parent 08b0259 commit 153e2ac
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions packages/examples/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const basicExample = async () => {
};

try {
console.log('Creating catalog:', myCatalogKey);
await createCatalog(myNewCatalog);
console.log('Done');
} catch (e: any) {
if (e.response?.status === 409) {
console.log('Catalog already exists');
Expand All @@ -67,7 +69,9 @@ const basicExample = async () => {
}

try {
console.log('Adding product #1');
await createProduct(myCatalogKey, myNewProducts[0]);
console.log('Done');
} catch (e: any) {
if (e.response?.status === 409) {
console.log('Product already exists');
Expand All @@ -77,7 +81,9 @@ const basicExample = async () => {
}

try {
console.log('Adding product #2');
await createProduct(myCatalogKey, myNewProducts[1]);
console.log('Done');
} catch (e: any) {
if (e.response?.status === 409) {
console.log('Product already exists');
Expand Down Expand Up @@ -151,7 +157,9 @@ const batchImportExample = async () => {
};

try {
console.log('Creating catalog:', myCatalogKey);
await createCatalog(myNewCatalog);
console.log('Done');
} catch (e: any) {
if (e.response?.status === 409) {
console.log('Catalog already exists');
Expand All @@ -160,15 +168,38 @@ const batchImportExample = async () => {
}
}

const {
data: { id: sessionId },
} = await createImportSession(myCatalogKey, {});
let sessionId = '';
try {
console.log('Creating import session for catalog:', myCatalogKey);
const { data } = await createImportSession(myCatalogKey, {});
sessionId = data.id;
console.log('Import session ID:', sessionId);
} catch (e: any) {
console.log('Error creating import session', `${e}`);
return;
}

await importProducts(myCatalogKey, sessionId, myNewProducts);
console.log(
'Check session',
await getImportSessionStatus(myCatalogKey, sessionId),
);

await pollImportSessionStatus(myCatalogKey, sessionId);
try {
console.log('Importing products');
await importProducts(myCatalogKey, sessionId, myNewProducts);
console.log('Products imported');
} catch (e: any) {
console.log('Error importing products', `${e}`);
console.log(e.response?.data);
}

console.log('Import session completed');
try {
console.log('Polling import session status');
await pollImportSessionStatus(myCatalogKey, sessionId);
console.log('Import session completed');
} catch (e: any) {
console.log('Error polling import session status', `${e}`);
}

const pepperonis = await getProducts(
myCatalogKey,
Expand Down

0 comments on commit 153e2ac

Please sign in to comment.