Skip to content

Commit c209145

Browse files
Vikram KaltaVikram Kalta
authored andcommitted
feat: added support for getLastActivities
1 parent 0cd8ea6 commit c209145

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/lib/contentstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { httpClient, retryRequestHandler, retryResponseErrorHandler, retryResponseHandler } from '@contentstack/core';
2-
import { InternalAxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios';
2+
import { AxiosRequestHeaders } from 'axios';
33
import { handleRequest } from './cache';
44
import { Stack as StackClass } from './stack';
55
import { Policy, StackConfig } from './types';

src/lib/stack.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StackConfig, SyncStack, SyncType, LivePreviewQuery } from './types';
2-
import { AxiosInstance } from '@contentstack/core';
2+
import { AxiosInstance, getData } from '@contentstack/core';
33
import { Asset } from './asset';
44
import { AssetQuery } from './asset-query';
55
import { ContentType } from './content-type';
@@ -186,4 +186,18 @@ export class Stack {
186186
getClient(): any {
187187
return this._client;
188188
}
189+
190+
async getLastActivities() {
191+
try {
192+
const result = await getData(this._client, '/content_types', {
193+
params: {
194+
only_last_activity: true,
195+
environment: this.config.environment,
196+
},
197+
});
198+
return result;
199+
} catch (error) {
200+
throw new Error("Error fetching last activities");
201+
}
202+
}
189203
}

test/api/stack.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { stackInstance } from '../utils/stack-instance';
2+
3+
const stack = stackInstance();
4+
5+
describe('Stack methods tests', () => {
6+
it('should check last activities', async () => {
7+
const result = await stack.getLastActivities();
8+
expect(result).toBeDefined();
9+
expect(result.content_types).toBeDefined();
10+
expect(Array.isArray(result.content_types)).toBe(true);
11+
});
12+
});

0 commit comments

Comments
 (0)