import { BaseClient, ClientConfig, Response } from "@commerce-apps/core"; import type { CommonParameters } from "@commerce-apps/core"; import type { OperationOptions } from "retry"; import type { RequestInit } from "node-fetch"; import type { CompositeParameters, CustomRequestBody, QueryParameters, RequireParametersUnlessAllAreOptional } from "../../types"; import type { Promotion, PromotionSearchResult, SearchRequest } from '../models/index'; /** * [Promotions](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=promotions:Summary) * ================================== * * *[Download API specification](https://developer.salesforce.com/static/commercecloud/commerce-api/promotions/promotions-oas-v1-public.yaml) # API Overview Use the Promotions API to create, update, delete, and search for promotion information on your site. Promotions are configured with rules that define the type of promotion, conditions, and discounts. This API can be used to synchronize promotion data in the commerce platform with third-party promotion management systems. This API can also be called from a custom promotion management application. In sandbox environments, the Promotions API is useful for creating and updating test data, for example, with integration testing or as part of a continuous integration or continuous deployment process. For more information, see [Campaigns and Promotions](https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/promotions/b2c_campaigns_and_promotions.html) in the Salesforce B2C Commerce Infocenter. ## Authentication & Authorization The client requesting the promotion information must have access to the Promotion resource. For resource access, you must use a client ID and client secret from Account Manager to request an access token. The access token is used as a bearer token and added to the Authorization header of your API request. The client must first authenticate against Account Manager to log in. You must include the relevant scope(s) in the client ID used to generate the token. For details, see [Authorization Scopes Catalog.](https://developer.salesforce.com/docs/commerce/commerce-api/guide/auth-z-scope-catalog.html) For detailed setup instructions, see [Authorization for Admin APIs](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html). ## Use Cases **Note**: A promotion can be created, enabled, and assigned exclusivity using the API, but qualifier and discounted criteria must be assigned in Business Manager. ### Shipping Promotions Use the Promotions API to configure shipping promotions. You can configure shipping promotions based on an order and on individual products or product combinations. You can also configure product-specific shipping cost (fixed or surcharge). **Note**: Product-related shipping discounts are considered product promotions. In a multiple ship-to scenario, B2C Commerce determines which shipments use any of the discounted shipping methods and applies the discount from most expensive to least expensive until meeting the maximum applications limit, if specified. For example, create a shipping promotion that gives the customer free shipping when their purchase exceeds $50. For more detail, see [Shipping Promotions](https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/promotions/b2c_shipping_promotions.html) in the Salesforce B2C Commerce Infocenter. ### Product Promotions Use the Promotions API to configure product promotions. You can define product promotions for specific products, groups of products or brands, or amounts of products purchased. You can define conditions that require customers to purchase from a set of products. A product promotion is prorated, calculated, and rounded once per product in the order. A product promotion is different than an order promotion, which is calculated once at the order level, and rounded off once, if necessary. For example, create a product promotion that discounts a second item by 50% when the customer buys two. For more detail, see [Product Promotions](https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/promotions/b2c_product_promotions.html) in the Salesforce B2C Commerce Infocenter. ### Order Promotions Use the Promotions API to configure order promotions. You can configure order promotions for percentage discounts, fixed price discounts, and free shipping. You can offer a bonus product or a choice of bonus products, and you can tier order discounts. An order promotion is calculated once at the order level, and rounded off once, if necessary. An order promotion is different than a product promotion, where the promotion is prorated, calculated, and rounded per product in the order. For example, create an order promotion that discounts an entire order when the customer buys 3 qualifying items. For more detail, see [Order Promotions](https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/promotions/b2c_order_promotions.html) in the Salesforce B2C Commerce Infocenter.*
* * For instructions on how to retrieve access token for admin APIs: https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html

* Example with admin auth * * ```typescript * import { Promotions, ClientConfig } from "commerce-sdk"; * // or * const { Promotions, ClientConfig } = require("commerce-sdk"); * * const clientConfig: ClientConfig = { * parameters: { * clientId: "XXXXXX", * organizationId: "XXXX", * shortCode: "XXX", * siteId: "XX" * } * }; * * token = { access_token: 'INSERT_ACCESS_TOKEN_HERE' }; * * clientConfig.headers['authorization'] = `Bearer ${token.access_token}`; * const promotionsClient = new Promotions(clientConfig); * ``` * * * API Version: 1.4.4
* Last Updated:
*
* */ export declare class Promotions extends BaseClient { constructor(config: ClientConfig); /** * * * If you would like to get a raw Response object use the other createPromotion function. * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * * @returns A promise of type Promotion. */ createPromotion(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: Promotion & CustomRequestBody; }>): Promise; /** * * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * @param rawResponse - Set to true to return entire Response object instead of DTO. * * @returns A promise of type Response if rawResponse is true, a promise of type Promotion otherwise. */ createPromotion(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: Promotion & CustomRequestBody; }>, rawResponse?: T): Promise; /** * * * If you would like to get a raw Response object use the other deletePromotion function. * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * * @returns A promise of type void. */ deletePromotion(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>): Promise; /** * * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param rawResponse - Set to true to return entire Response object instead of DTO. * * @returns A promise of type Response if rawResponse is true, a promise of type void otherwise. */ deletePromotion(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>, rawResponse?: T): Promise; /** * * * If you would like to get a raw Response object use the other getPromotion function. * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * * @returns A promise of type Promotion. */ getPromotion(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>): Promise; /** * * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param rawResponse - Set to true to return entire Response object instead of DTO. * * @returns A promise of type Response if rawResponse is true, a promise of type Promotion otherwise. */ getPromotion(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>, rawResponse?: T): Promise; /** * The SearchRequest document contains a search object that allows you to filter using various attributes. Use the following searchable query attributes to narrow down the search: | Attribute | Type | |-----------|--------| | id | String | | name | String | | currecyCode | String | | exclusivity | String | | enabled | Boolean | Note that only searchable attributes can be used in sorting. Additionally, the following attribute can be used to sort: | Attribute | Type | |-----------|--------| | promotionClass | String | * * If you would like to get a raw Response object use the other promotionsSearch function. * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * * @returns A promise of type PromotionSearchResult. */ promotionsSearch(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: SearchRequest & CustomRequestBody; }>): Promise; /** * The SearchRequest document contains a search object that allows you to filter using various attributes. Use the following searchable query attributes to narrow down the search: | Attribute | Type | |-----------|--------| | id | String | | name | String | | currecyCode | String | | exclusivity | String | | enabled | Boolean | Note that only searchable attributes can be used in sorting. Additionally, the following attribute can be used to sort: | Attribute | Type | |-----------|--------| | promotionClass | String | * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * @param rawResponse - Set to true to return entire Response object instead of DTO. * * @returns A promise of type Response if rawResponse is true, a promise of type PromotionSearchResult otherwise. */ promotionsSearch(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: SearchRequest & CustomRequestBody; }>, rawResponse?: T): Promise; /** * * * If you would like to get a raw Response object use the other updatePromotion function. * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * * @returns A promise of type Promotion. */ updatePromotion(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: Promotion & CustomRequestBody; }>): Promise; /** * * * @param options - An object containing the options for this method. * @param options.parameters - An object containing the parameters for this method. * @param options.parameters.id - The ID of the promotion to create. * @param options.parameters.organizationId - An identifier for the organization the request is being made by * @param options.parameters.siteId - The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites. * @param options.retrySettings - Retry options for the `node-retry` package * @param options.fetchOptions - Fetch options for the `make-fetch-happen` package * @param options.headers - An object literal of key value pairs of the headers to be sent with this request. * @param options.body - The data to send as the request body. * @param rawResponse - Set to true to return entire Response object instead of DTO. * * @returns A promise of type Response if rawResponse is true, a promise of type Promotion otherwise. */ updatePromotion(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ id: string; organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: Promotion & CustomRequestBody; }>, rawResponse?: T): Promise; }