# Get Catalog Change API

The Get Catalog Change API defines all offer and availability changes applicable to your catalogs by getting all the distinct unprocessed Catalog changes made on Salesforce Objects (Subjects). Some examples of changes include offer or bundle modifications such as changes in description, attachments, and cardinality changes. Additionally, this API defines any changes that impact the eligibility or effectivity of an offer.

For this API to function properly, set the custom setting `CacheAPI.RegenerateBatchCacheProcessor` to `True`. When set to `True`, the API registers the catalog change as a simpleOffer or availability for those SObjects that could lead to a catalog-level change during derivation. This custom setting is applicable for Cache Management APIs (Regenerate APIs) only to avoid processing all the catalog level jobs during the Regeneration API.

- simpleOffer: Changes made in the offer or bundle structure that only affect the properties of an offer, such as a change in description, attachments, cardinality changes, etc.

- availability: Changes that impact the eligibility or effectivity of an offer in a catalog.

## URI

/services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange

## HTTP Method

GET

## URI Parameters

| Parameter | Example                                                                                  | Default | Optional/Required | Notes                                                       |
| --------- | ---------------------------------------------------------------------------------------- | ------- | ----------------- | ----------------------------------------------------------- |
| pageSize  | /services/apexrest/h_cpq/v3/admin/catalogs/regenerate/catalogChange?pageSize=10          | 5       | Optional          | By default, this API returns five catalog changes at a time |
| offset    | /services/apexrest/h_cpq/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=0 | 0       | Optional          |                                                             |

## Request Body

This example shows how you can specify pageSize and offset parameters for this API if you wish to customize which catalog changes it returns and how many.

```nolang
GET
/services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=0
```

## Remote API

This is an example of how you invoke the API using Apex:

```nolang
String methodName;
Map<String, Object> input = new Map<String, Object>();
Map<String, Object> output = new Map<String, Object>();
Map<String, Object> options = new Map<String, Object>();
// Setting remote parameters
methodName = 'getCatalogChanges';
input.put('methodName',methodName); //required
input.put('apiName','regenerate'); //required
input.put('pagesize','20'); //optional
input.put('offset','0'); //optional

//remote action invocation
jk_232_cam.CpqAppHandler appHandler = new jk_232_cam.CpqAppHandler();
appHandler.invokeMethod(methodName, input, output, options);
```

## Parallel Invocation

You can run this API in parallel for different sets of pageSize and offset. For example, if there are 100 cachedAPIChange entries (CAC1, CAC2.....CAC100), default pageSize =10, and offset is 0, then you can run parallel threads for the GetCatalog Change API with different offset values.

```nolang
THREAD1 -  GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=0
THREAD2 -  GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=10
THREAD3 -  GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=20
.
.
.
.
THREAD10 -  GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/catalogChange?pageSize=10&offset=90
```

## HTTP Headers

| Header       | Description      |
| ------------ | ---------------- |
| Content-Type | application/json |

## Response Body

The sample output shows cached API change Ids. returnStatus indicates success or failure with an error reason. List \<Id> of records contains the unprocessed Id of the CachedAPIChange\_\_c object.

```
{
    "cachedAPIChangeIds": [
        "a4Q5g000000Tjj1EAC",
        "a4Q5g000000TjjBEAS",
        "a4Q5g000000TjjCEAS"
    ],
    "totalChanges":118,
    "errorCode": "INVOKE-200",
    "error": "OK"
}
```

## HTTP Response Codes

| Code | Description           |
| ---- | --------------------- |
| 200  | OK                    |
| 500  | Internal Server Error |
