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 { PromotionCampaignAssignmentSearchResult, SearchRequest } from '../models/index'; /** * [Assignments](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=assignments:Summary) * ================================== * * *[Download API specification](https://developer.salesforce.com/static/commercecloud/commerce-api/assignments/assignments-oas-v1-public.yaml) # API Overview Use the Assignments API to search for promotions associated with campaigns. For more information, see [Campaigns and Promotions](https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/Promotions/CampaignsandPromotions.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 ### Find All Associated Promotions Use the Assignments API to find all associated promotions for a given campaign. *
* * 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 { Assignments, ClientConfig } from "commerce-sdk"; * // or * const { Assignments, 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 assignmentsClient = new Assignments(clientConfig); * ``` * * * API Version: 1.4.4
* Last Updated:
*
* */ export declare class Assignments extends BaseClient { constructor(config: ClientConfig); /** * The promotion campaign assignment search document contains a search object that allows filtering on various attributes. The query attribute specifies a complex query that can be used to narrow down the search. Attributes are grouped into different buckets. The following is a list of searchable attributes with their corresponding buckets: main: | Attribute | Type | |-----------|--------| | rank| Integer | | startDate | Date | | endDate | Date | campaign: | Attribute | Type | |-----------|--------| | campaign| String | promotion: | Attribute | Type | |-----------|--------| | promotionId| String | | description | String | | enabled | Boolean | special handling: | Attribute | Type | |-----------|--------| | couponId| String | Only fields in the same bucket can be joined using a disjunction (or). For instance, when joining campaignId and rank, only a conjunction (and) is allowed, while promotionId and description can be joined using a disjunction because they are in the same bucket. Special handling fields must always use conjunctions. If the field is used in a disjunction that violates this rule, an exception is thrown. Note that only searchable attributes can be used in sorting. * * If you would like to get a raw Response object use the other assignmentsSearch 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 PromotionCampaignAssignmentSearchResult. */ assignmentsSearch(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: SearchRequest & CustomRequestBody; }>): Promise; /** * The promotion campaign assignment search document contains a search object that allows filtering on various attributes. The query attribute specifies a complex query that can be used to narrow down the search. Attributes are grouped into different buckets. The following is a list of searchable attributes with their corresponding buckets: main: | Attribute | Type | |-----------|--------| | rank| Integer | | startDate | Date | | endDate | Date | campaign: | Attribute | Type | |-----------|--------| | campaign| String | promotion: | Attribute | Type | |-----------|--------| | promotionId| String | | description | String | | enabled | Boolean | special handling: | Attribute | Type | |-----------|--------| | couponId| String | Only fields in the same bucket can be joined using a disjunction (or). For instance, when joining campaignId and rank, only a conjunction (and) is allowed, while promotionId and description can be joined using a disjunction because they are in the same bucket. Special handling fields must always use conjunctions. If the field is used in a disjunction that violates this rule, an exception is thrown. Note that only searchable attributes can be used in sorting. * * @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 PromotionCampaignAssignmentSearchResult otherwise. */ assignmentsSearch(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: SearchRequest & CustomRequestBody; }>, rawResponse?: T): Promise; }