From 94230438ad255c208ba90e06d43a97a42d76a45b Mon Sep 17 00:00:00 2001 From: ajimae <32770340+ajimae@users.noreply.github.com> Date: Wed, 8 May 2024 12:09:55 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20commerce?= =?UTF-8?q?tools/commercetools-sdk-typescript@4550cf097071f27aaea4c7c21b16?= =?UTF-8?q?e09ac4d14f92=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/ClientBuilder.html | 4 ++-- functions/Process.html | 2 +- functions/createAuthForAnonymousSessionFlow.html | 2 +- functions/createAuthForClientCredentialsFlow.html | 2 +- functions/createAuthForPasswordFlow.html | 2 +- functions/createAuthForRefreshTokenFlow.html | 2 +- functions/createAuthWithExistingToken.html | 2 +- functions/createClient.html | 2 +- functions/createCorrelationIdMiddleware.html | 2 +- functions/createHttpClient.html | 2 +- functions/createLoggerMiddleware.html | 2 +- functions/createQueueMiddleware.html | 2 +- functions/createUserAgentMiddleware.html | 2 +- functions/getErrorByCode.html | 2 +- index.html | 2 +- interfaces/ClientRequest.html | 4 ++-- modules.html | 2 +- types/ActionGroup.html | 2 +- types/AfterExecutionMiddlewareOptions.html | 2 +- types/AnonymousAuthMiddlewareOptions.html | 2 +- types/ApiRequestBuilder.html | 2 +- types/AuthMiddlewareBaseOptions.html | 2 +- types/AuthMiddlewareOptions.html | 2 +- types/AuthOptions.html | 2 +- types/AuthRequest.html | 2 +- types/BeforeExecutionMiddlewareOptions.html | 2 +- types/Client.html | 2 +- types/ClientAuthOptions.html | 2 +- types/ClientOptions.html | 2 +- types/ClientResponse.html | 2 +- types/ClientResult.html | 2 +- types/CorrelationIdMiddlewareOptions.html | 2 +- types/Credentials.html | 2 +- types/CustomAuthOptions.html | 2 +- types/Dispatch.html | 2 +- types/ExistingTokenMiddlewareOptions.html | 2 +- types/GenericOmit.html | 2 +- types/HttpErrorType.html | 2 +- types/HttpMiddlewareOptions.html | 2 +- types/HttpUserAgentOptions.html | 2 +- types/JsonObject.html | 2 +- types/LoggerMiddlewareOptions.html | 2 +- types/MethodType.html | 2 +- types/Middleware.html | 2 +- types/MiddlewareRequest.html | 2 +- types/MiddlewareResponse.html | 2 +- types/Next.html | 2 +- types/Nullable.html | 2 +- types/PasswordAuthMiddlewareOptions.html | 2 +- types/ProcessFn.html | 2 +- types/ProcessOptions.html | 2 +- types/ProcessResult.html | 2 +- types/QueryParam.html | 2 +- types/QueueMiddlewareOptions.html | 2 +- types/RefreshAuthMiddlewareOptions.html | 2 +- types/RequestOptions.html | 2 +- types/RequestState.html | 2 +- types/RequestStateStore.html | 2 +- types/ServiceBuilder.html | 2 +- types/ServiceBuilderDefaultParams.html | 2 +- types/ServiceBuilderDefinition.html | 2 +- types/ServiceBuilderInstance.html | 2 +- types/ServiceBuilderParams.html | 2 +- types/SuccessResult.html | 2 +- types/SyncAction.html | 2 +- types/SyncActionConfig.html | 2 +- types/Task.html | 2 +- types/TelemetryOptions.html | 2 +- types/TokenCache.html | 2 +- types/TokenCacheOptions.html | 2 +- types/TokenInfo.html | 2 +- types/TokenStore.html | 2 +- types/UpdateAction.html | 2 +- types/UserAgentMiddlewareOptions.html | 2 +- types/UserAuthOptions.html | 2 +- types/ValiadateOption.html | 2 +- types/VariableMap.html | 2 +- types/executeRequest.html | 2 +- types/executeRequestOptions.html | 2 +- types/requestBaseOptions.html | 2 +- 80 files changed, 82 insertions(+), 82 deletions(-) diff --git a/classes/ClientBuilder.html b/classes/ClientBuilder.html index 16b100310..09dc913ec 100644 --- a/classes/ClientBuilder.html +++ b/classes/ClientBuilder.html @@ -1,4 +1,4 @@ -
Private
afterPrivate
authPrivate
beforePrivate
correlationPrivate
httpPrivate
loggerPrivate
middlewaresPrivate
projectPrivate
queuePrivate
telemetryPrivate
userOptional
oauthUri: stringOptional
projectKey: stringOptional
options: ExistingTokenMiddlewareOptionsOptional
options: LoggerMiddlewareOptionsOptional
options: HttpUserAgentOptionsPrivate
afterPrivate
authPrivate
beforePrivate
correlationPrivate
httpPrivate
loggerPrivate
middlewaresPrivate
projectPrivate
queuePrivate
telemetryPrivate
userOptional
oauthUri: stringOptional
projectKey: stringOptional
options: ExistingTokenMiddlewareOptionsOptional
options: LoggerMiddlewareOptionsOptional
options: HttpUserAgentOptionsOptional
options: HttpUserAgentOptionsOptional
options: HttpUserAgentOptionsconst {
ClientBuilder,
createAuthForClientCredentialsFlow,
createHttpClient,
} = require('@commercetools/sdk-client-v2')
const { createApiBuilderFromCtpClient } = require('@commercetools/platform-sdk')
const fetch = require('node-fetch')
const projectKey = 'mc-project-key'
const authMiddlewareOptions = {
host: 'https://auth.europe-west1.gcp.commercetools.com',
projectKey,
credentials: {
clientId: 'mc-client-id',
clientSecret: 'mc-client-secrets',
},
oauthUri: '/oauth/token', // - optional: custom oauthUri
scopes: [`manage_project:${projectKey}`],
fetch,
}
const httpMiddlewareOptions = {
host: 'https://api.europe-west1.gcp.commercetools.com',
fetch,
}
const client = new ClientBuilder()
.withProjectKey(projectKey)
.withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions))
.withMiddleware(createHttpClient(httpMiddlewareOptions))
.withUserAgentMiddleware()
.build()
// or
const client = new ClientBuilder()
.withProjectKey(projectKey)
.withClientCredentialsFlow(authMiddlewareOptions)
.withHttpMiddleware(httpMiddlewareOptions)
.withUserAgentMiddleware()
.build()
const apiRoot = createApiBuilderFromCtpClient(client)
// calling the Composable Commerce functions
// get project details
apiRoot
.withProjectKey({
projectKey,
})
.get()
.execute()
.then((x) => {
/*...*/
})
// create a productType
apiRoot
.withProjectKey({ projectKey })
.productTypes()
.post({
body: { name: 'product-type-name', description: 'some description' },
})
.execute()
.then((x) => {
/*...*/
})
// create a product
apiRoot
.withProjectKey({ projectKey })
.products()
.post({
body: {
name: { en: 'our-great-product-name' },
productType: {
typeId: 'product-type',
id: 'some-product-type-id',
},
slug: { en: 'some-slug' },
},
})
.execute()
.then((x) => {
/*...*/
})
// -----------------------------------------------------------------------
// The sdk-client-v2 also has support for the old syntax
import {
createClient,
createHttpClient,
createAuthForClientCredentialsFlow,
} from '@commercetools/sdk-client-v2'
import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk'
import fetch from 'node-fetch'
const projectKey = 'some_project_key'
const authMiddleware = createAuthForClientCredentialsFlow({
host: 'https://auth.europe-west1.gcp.commercetools.com',
projectKey,
credentials: {
clientId: 'some_id',
clientSecret: 'some_secret',
},
fetch,
})
const httpMiddleware = createHttpClient({
host: 'https://api.europe-west1.gcp.commercetools.com',
fetch,
})
const ctpClient = createClient({
middlewares: [authMiddleware, httpMiddleware],
})
const apiRoot = createApiBuilderFromCtpClient(ctpClient)
apiRoot
.withProjectKey({
projectKey,
})
.get()
.execute()
.then((x) => {
/*...*/
})
apiRoot
.withProjectKey({ projectKey })
.productTypes()
.post({
body: { name: 'product-type-name', description: 'some description' },
})
.execute()
.then((x) => {
/*...*/
})
apiRoot
.withProjectKey({ projectKey })
.products()
.post({
body: {
name: { en: 'our-great-product-name' },
productType: {
typeId: 'product-type',
id: 'some-product-type-id',
},
slug: { en: 'some-slug' },
},
})
.execute()
.then((x) => {
/*...*/
})
See full usage example here
-