Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .env.sample

This file was deleted.

19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# commercetools-js-sdk-v2-training
commercetools-js-sdk-v2-training

** COMING SOON **
NEW JAVASCRIPT COURSE USING THE NEW COMMERCETOOLS JS SDK
https://ok.commercetools.com/training-offering-calendar

NEW JAVASCRIPT COURSE USING THE NEW COMMERCETOOLS TypeScript SDK
https://github.com/commercetools/commercetools-sdk-typescript#sdk

Usage

Add API Client Credentials in .env.sample then remove the ".sample" file name should be only ".env"
then follow your trainer instructions to solve the exercises.

use the command yarn to install dependencies
Use the command `npm install` to install dependencies

then you should be able to run any file using yarn [fileNumber]
then you should be able to run any file using `yarn [fileNumber]`
example
yarn 1
yarn 4c
yarn 6b
- npm run 1
- npm run 4c
- npm run 6b

The following (or later) must be installed before the TypeScript SDK can be used:
- Node v16
- npm v8

for questions email training@commercetools.com
8 changes: 7 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
set up the main branch to include the exercises
update docker to latest in the import sync and maybe use docker settings sync too
task 9 performance considerations.
retry
set correlation id
loggings
reuse tokens
use updateActions arary
17 changes: 0 additions & 17 deletions Task01_project_setup.js

This file was deleted.

29 changes: 29 additions & 0 deletions Task01_project_setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { log } from "./utils/logger";
import { apiRoot } from "./handson/client";

// TODO 1: Complete the functions in
// ./handson/client.js
// So this code displays the project configuration
// https://docs.commercetools.com/http-api-projects-project.html#get-project

apiRoot
.get()
.execute()
.then(log)
.catch(log);

apiRoot
.shippingMethods()
.withId({ ID: "d24e8501-65c0-4125-994d-7e9ba80724a5" })
.get()
.execute()
.then(log)
.catch(log);

apiRoot
.taxCategories()
.withKey({ key: "standard-tax-category" })
.get()
.execute()
.then(log)
.catch(log);
27 changes: 0 additions & 27 deletions Task02_customers.js

This file was deleted.

33 changes: 33 additions & 0 deletions Task02_customers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
createCustomer,
getCustomerById,
getCustomerByKey,
createCustomerToken,
confirmCustomerEmail,
assignCustomerToCustomerGroup,
CustomerDraftData,
} from "./handson/customer";
import { log } from "./utils/logger";

const customerDraftData: CustomerDraftData = {
firstName: "test",
lastName: "test",
email: "test@test.com",
password: "password",
key: "test123",
countryCode: "DE",
};

// createCustomer(customerDraftData).then(log).catch(log);

// getCustomerByKey("test123").then(log).catch(log);

// getCustomerById("a303f0e7-8535-4784-a638-e59f05208355").then(log).catch(log);

// getCustomerByKey("test123")
// .then(createCustomerToken)
// .then(confirmCustomerEmail)
// .then(log)
// .catch(log);

// assignCustomerToCustomerGroup("test123", "indoor-customers").then(log).catch(log);
21 changes: 0 additions & 21 deletions Task03_import_sync_products.js

This file was deleted.

43 changes: 43 additions & 0 deletions Task03_import_sync_products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
checkImportOperationStatusById,
checkImportSummary,
createImportContainer,
importProducts,
importPrices
} from "./handson/importService";
import { log } from "./utils/logger";

const containerKey = "ff-ImportContainer";

// Create an import container
// createImportContainer(containerKey).then(log).catch(log);

// import products
// importProducts(containerKey).then(log).catch(log);

// Import prices
// importPrices(containerKey).then(log).catch(log);

// check import summary for your container
// checkImportSummary(containerKey).then(log).catch(log);

// check import operations for your container
// checkImportOperationsStatus(containerKey).then(operations =>
// operations.body.results.forEach(operation =>
// log(operation.id + " : " + operation.state)
// )
// )

// Check the status of import operations by their Ids
checkImportOperationStatusById("9eee411c-a698-4e13-b1fd-0996180df437").then(log).catch(log);
checkImportOperationStatusById("340ec151-ebd3-422a-97a8-e7625e85633a").then(log).catch(log);

// https://github.com/commercetools/commercetools-project-sync#run
// docker run \
// -e SOURCE_PROJECT_KEY=xxx \
// -e SOURCE_CLIENT_ID=xxx \
// -e SOURCE_CLIENT_SECRET=xxx \
// -e TARGET_PROJECT_KEY=xxx \
// -e TARGET_CLIENT_ID=xxx \
// -e TARGET_CLIENT_SECRET=xxx \
// commercetools/commercetools-project-sync:5.0.0 -s all
17 changes: 0 additions & 17 deletions Task04a_states.js

This file was deleted.

37 changes: 37 additions & 0 deletions Task04a_states.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as states from "./handson/states";
import { log } from "./utils/logger";

const orderPackedStateDraft: states.StateDraftData = {
key: "ff-order-packed",
type: "OrderState",
name: {
"de": "FF Order Packed ",
"en": "FF Order Packed ",
},
initial: true,
};

const orderCompletedStateDraft: states.StateDraftData = {
key: "ff-order-completed",
type: "OrderState",
name: {
"de": "FF Order Completed ",
"en": "FF Order Completed ",
},
initial: false,
};

const createStatesWithTransitions = async () => {
let orderPackedState = await states.createNewState(orderPackedStateDraft)
let orderCompletedState = await states.createNewState(orderCompletedStateDraft)

orderPackedState = await states.addTransition(orderPackedState.body.id, [orderCompletedState.body.id])

orderCompletedState = await states.addTransition(orderCompletedState.body.id, [])

return orderPackedState;
};

createStatesWithTransitions().then(log).catch(log)

// states.getStateByKey(orderPackedStateDraft.key).then(log).catch(log)
63 changes: 0 additions & 63 deletions Task04b_checkout.js

This file was deleted.

Loading