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 { GiftCertificate, GiftCertificateSearchResult, SearchRequest } from '../models/index'; /** * [Gift Certificates](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=gift-certificates:Summary) * ================================== * * *[Download API specification](https://developer.salesforce.com/static/commercecloud/commerce-api/gift-certificates/gift-certificates-oas-v1-public.yaml) # API Overview Use the Gift Certificates API to create, update, and delete gift certificates, so that your storefront customers can purchase and redeem gift certificates. ## Authentication & Authorization The client requesting the gift certificate information must have access to the Gift Certificates 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 ### Capture All Gift Certificates Retrieve all gift certificates for a site with no filtering. ### Capture Specific Gift Certificates Retrieve a specific gift certificate for a site using a merchant ID. ### Create Site Specific Gift Certificates Create and issue site-specific gift certificates with information such as amount, description, status, recipient email, recipient name, sender name, and so on. ### Update Gift Certificates Update a gift certificate with specified information using a merchant ID.*
* * 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 { GiftCertificates, ClientConfig } from "commerce-sdk"; * // or * const { GiftCertificates, 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 giftCertificatesClient = new GiftCertificates(clientConfig); * ``` * * * API Version: 1.4.4
* Last Updated:
*
* */ export declare class GiftCertificates extends BaseClient { constructor(config: ClientConfig); /** * If an existing identifier is specified, the gift certificate with that unique identifier is deleted and a new one is created. * * If you would like to get a raw Response object use the other createGiftCertificate 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 GiftCertificate. */ createGiftCertificate(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: GiftCertificate & CustomRequestBody; }>): Promise; /** * If an existing identifier is specified, the gift certificate with that unique identifier is deleted and a new one is created. * * @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 GiftCertificate otherwise. */ createGiftCertificate(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: GiftCertificate & CustomRequestBody; }>, rawResponse?: T): Promise; /** * * * If you would like to get a raw Response object use the other deleteGiftCertificate 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.merchantId - The merchant ID of the requested gift certificate. * @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. */ deleteGiftCertificate(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: 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.organizationId - An identifier for the organization the request is being made by * @param options.parameters.merchantId - The merchant ID of the requested gift certificate. * @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. */ deleteGiftCertificate(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>, rawResponse?: T): Promise; /** * Retrieve gift certificate information for a specified merchant ID. * * If you would like to get a raw Response object use the other getGiftCertificate 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.merchantId - The merchant ID of the requested gift certificate. * @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 GiftCertificate. */ getGiftCertificate(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>): Promise; /** * Retrieve gift certificate information for a specified merchant ID. * * @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.merchantId - The merchant ID of the requested gift certificate. * @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 GiftCertificate otherwise. */ getGiftCertificate(options?: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; }>, rawResponse?: T): Promise; /** * Use the following searchable query attributes to narrow the search: | Attribute | Type | Sortable | |-----------|--------|----------| | merchantId | String | yes | | maskedGiftCertificateCode * | String | no | | orderNo | String | yes | | senderName | String | yes | | recipientName | String | yes | | recipientEmail | String | yes | | status | String | yes | | enabled | Boolean | yes | | message | String | yes | | description | String | yes | | creationDate | Date | yes | | currencyMnemonic ** | String | yes | ## Notes: * *`maskedGiftCertificateCode`, also known as just code, can only be used in a term query. If a four-character code is supplied, it is assumed that the search is on the unmasked portion of the code. Otherwise, the full code must be matched. Text queries are not allowed. * **`currencyMnemonic` can only be joined with other attributes using a conjunction (`AND`). * Only searchable attributes can be used in sorting. * * If you would like to get a raw Response object use the other giftCertificatesSearch 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 GiftCertificateSearchResult. */ giftCertificatesSearch(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: SearchRequest & CustomRequestBody; }>): Promise; /** * Use the following searchable query attributes to narrow the search: | Attribute | Type | Sortable | |-----------|--------|----------| | merchantId | String | yes | | maskedGiftCertificateCode * | String | no | | orderNo | String | yes | | senderName | String | yes | | recipientName | String | yes | | recipientEmail | String | yes | | status | String | yes | | enabled | Boolean | yes | | message | String | yes | | description | String | yes | | creationDate | Date | yes | | currencyMnemonic ** | String | yes | ## Notes: * *`maskedGiftCertificateCode`, also known as just code, can only be used in a term query. If a four-character code is supplied, it is assumed that the search is on the unmasked portion of the code. Otherwise, the full code must be matched. Text queries are not allowed. * **`currencyMnemonic` can only be joined with other attributes using a conjunction (`AND`). * 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 GiftCertificateSearchResult otherwise. */ giftCertificatesSearch(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 updateGiftCertificate 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.merchantId - The merchant ID of the requested gift certificate. * @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 GiftCertificate. */ updateGiftCertificate(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: GiftCertificate & 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.organizationId - An identifier for the organization the request is being made by * @param options.parameters.merchantId - The merchant ID of the requested gift certificate. * @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 GiftCertificate otherwise. */ updateGiftCertificate(options: RequireParametersUnlessAllAreOptional<{ parameters?: CompositeParameters<{ organizationId: string; merchantId: string; siteId: string; } & QueryParameters, CommonParameters>; retrySettings?: OperationOptions; fetchOptions?: RequestInit; headers?: { [key: string]: string; }; body: GiftCertificate & CustomRequestBody; }>, rawResponse?: T): Promise; }