Skip to content

Commit 43fb29d

Browse files
authored
Merge pull request #76 from FreeClimbAPI/VCSWP-18370
Resolve VCSWP-18370: Pagination for node.js SDK
2 parents 9631e5c + 03f4179 commit 43fb29d

File tree

11 files changed

+226
-9
lines changed

11 files changed

+226
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
99

1010
None
1111

12+
<a name="3.7.0"></a>
13+
14+
## [3.7.0] - 2024-08-28
15+
16+
### Add
17+
18+
- getNextPage functions to PromiseApi, DefaultApi, and ObservableApi
19+
1220
<a name="3.6.2"></a>
1321

1422
## [3.6.2] - 2024-07-31

DefaultApi.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Method | HTTP request | Description
6060
[**updateAnAccount**](DefaultApi.md#updateAnAccount) | **POST** /Accounts/{accountId} | Manage an account
6161
[**updateAnApplication**](DefaultApi.md#updateAnApplication) | **POST** /Accounts/{accountId}/Applications/{applicationId} | Update an application
6262
[**updateAnIncomingNumber**](DefaultApi.md#updateAnIncomingNumber) | **POST** /Accounts/{accountId}/IncomingPhoneNumbers/{phoneNumberId} | Update an Incoming Number
63-
63+
[**getNextPage**](DefaultApi.md#getNextPage) | **GET** /Accounts/{accountId}/{nextPageUri} | Get Next Page of Resource Data
6464

6565
# **buyAPhoneNumber**
6666
> IncomingNumberResult buyAPhoneNumber(buyIncomingNumberRequest)
@@ -3590,3 +3590,62 @@ Name | Type | Description | Notes
35903590
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
35913591

35923592

3593+
# **getNextPage**
3594+
> PaginationModel<T> getNextPage<T>()
3595+
3596+
### Example
3597+
3598+
3599+
```typescript
3600+
import { freeclimb } from '@freeclimb';
3601+
import * as fs from 'fs';
3602+
3603+
const configuration = freeclimb.createConfiguration({
3604+
accountId: 'YOUR_ACCOUND_ID',
3605+
apiKey: 'YOUR_API_KEY'
3606+
});
3607+
const apiInstance = new freeclimb.DefaultApi(configuration);
3608+
3609+
let body:freeclimb.DefaultApiListCallRecordingsRequest = {
3610+
3611+
// string | String that uniquely identifies this call resource.
3612+
callId: "callId_example",
3613+
3614+
// string | Only show recordings created on the specified date, in the form *YYYY-MM-DD*. (optional)
3615+
dateCreated: "dateCreated_example",
3616+
3617+
};
3618+
3619+
const recordingsResponse = await apiInstance.listCallRecordings(body)
3620+
3621+
await apiInstance.getNextPage(recordingsResponse).then((data:any) => {
3622+
console.log('Next page fetched succesfully. Returned data: ' + data);
3623+
}).catch((error:any) => console.error(error));
3624+
```
3625+
3626+
3627+
### Parameters
3628+
Name | Type | Description | Notes
3629+
------------------ | ------------------------ | ---------------------------------------------- | ---------------------
3630+
**responseObject** | [**PaginationModel<T>**] | Response from resource used to fetch next page | defaults to undefined
3631+
3632+
### Return type
3633+
3634+
**PaginationModel<T>**
3635+
3636+
### Authorization
3637+
3638+
[fc](README.md#fc)
3639+
3640+
### HTTP request headers
3641+
3642+
- **Content-Type**: Not defined
3643+
- **Accept**: application/json
3644+
3645+
### HTTP response details
3646+
| Status code | Description | Response headers |
3647+
|-------------|-------------|------------------|
3648+
**200** | Next page of resource data | - |
3649+
3650+
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
3651+

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22
-------------
33

4-
Copyright (c) 2023 FreeClimbAPI
4+
Copyright (c) 2024 FreeClimbAPI
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
77

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ For more information, please visit [https://www.freeclimb.com/support/](https://
1414
## Installing
1515

1616
```sh
17-
npm install @freeclimb/sdk@3.6.2
17+
npm install @freeclimb/sdk@3.7.0
1818
or
19-
yarn add @freeclimb/sdk@3.6.2
19+
yarn add @freeclimb/sdk@3.7.0
2020
```
2121

2222
## Getting Started

__tests__/DefaultApi.spec.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from "@jest/globals";
1+
import { describe, expect, test, beforeAll } from "@jest/globals";
22
import * as freeclimb from '../index'
33
import * as DefaultApi from '../apis/DefaultApi'
44
import { AccountRequest, AccountResult, ApplicationList, ApplicationRequest, ApplicationResult, AvailableNumberList, BuyIncomingNumberRequest, CallList, CallResult, ConferenceList, ConferenceParticipantList, ConferenceParticipantResult, ConferenceResult, CreateConferenceRequest, FilterLogsRequest, IncomingNumberList, IncomingNumberRequest, IncomingNumberResult, LogList, MessageResult, MessagesList, QueueList, QueueMember, QueueMemberList, QueueRequest, QueueResult, RecordingList, RecordingResult, ServerConfiguration, UpdateCallRequest, UpdateConferenceRequest } from "../index";
@@ -455,5 +455,42 @@ describe('DefaultAPI', () => {
455455
let data = await apiInstance.listConferenceRecordings(callId, conferenceId, dateCreated)
456456
expect(data).toBeInstanceOf(RecordingList)
457457
});
458+
459+
test('#getNextPage', async () => {
460+
const responseObject: RecordingList = {
461+
total: 0,
462+
start: 0,
463+
end: 0,
464+
page: 0,
465+
numPages: 0,
466+
pageSize: 0,
467+
nextPageUri: '/Recordings?cursor=1',
468+
recordings: []
469+
}
470+
const expectedResponseObject: RecordingList = {
471+
total: 0,
472+
start: 0,
473+
end: 0,
474+
page: 0,
475+
numPages: 0,
476+
pageSize: 0,
477+
nextPageUri: 'string',
478+
recordings: [
479+
{
480+
accountId: "string",
481+
callId: "string",
482+
conferenceId: "string",
483+
dateCreated: "string",
484+
dateUpdated: "string",
485+
durationSec: 0,
486+
recordingId: "string",
487+
revision: 0,
488+
uri: "string",
489+
}
490+
]
491+
}
492+
let data = await apiInstance.getNextPage(responseObject)
493+
expect(data).toStrictEqual(expectedResponseObject)
494+
});
458495
})
459496

apis/DefaultApi.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Configuration} from '../configuration';
44
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
55
import * as FormData from "form-data";
66
import { URLSearchParams } from 'url';
7-
import {ObjectSerializer} from '../models/ObjectSerializer';
7+
import {ObjectSerializer, PaginationModel} from '../models/ObjectSerializer';
88
import {ApiException} from './exception';
99
import {canConsumeForm, isCodeInRange} from '../util';
1010
import {SecurityAuthentication} from '../auth/auth';
@@ -2483,6 +2483,30 @@ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
24832483
return requestContext;
24842484
}
24852485

2486+
2487+
public async getNextPage<T extends PaginationModel>(responseObject: T, _options?: Configuration): Promise<RequestContext> {
2488+
const _config = _options || this.configuration;
2489+
const { accountId } = this.configuration
2490+
// Path Params
2491+
const localVarPath = `/Accounts/{accountId}${responseObject.nextPageUri}`
2492+
.replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId)));
2493+
// Make Request Context
2494+
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
2495+
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
2496+
2497+
2498+
let authMethod: SecurityAuthentication | undefined;
2499+
// Apply auth methods
2500+
authMethod = _config.authMethods["fc"]
2501+
if (authMethod?.applySecurityAuthentication) {
2502+
await authMethod?.applySecurityAuthentication(requestContext);
2503+
}
2504+
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
2505+
if (defaultAuth?.applySecurityAuthentication) {
2506+
await defaultAuth?.applySecurityAuthentication(requestContext);
2507+
}
2508+
return requestContext;
2509+
}
24862510
}
24872511

24882512
export class DefaultApiResponseProcessor {
@@ -4077,4 +4101,24 @@ export class DefaultApiResponseProcessor {
40774101
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
40784102
}
40794103

4104+
4105+
public async getNextPage<T extends PaginationModel>(response: ResponseContext): Promise<T> {
4106+
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
4107+
if (isCodeInRange("200", response.httpStatusCode)) {
4108+
const body: T = ObjectSerializer.deserialize(
4109+
ObjectSerializer.parse(await response.body.text(), contentType),
4110+
"T", ""
4111+
) as T;
4112+
return body;
4113+
}
4114+
// Work around for missing responses in specification, e.g. for petstore.yaml
4115+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
4116+
const body: T = ObjectSerializer.deserialize(
4117+
ObjectSerializer.parse(await response.body.text(), contentType),
4118+
"T", ""
4119+
) as T;
4120+
return body;
4121+
}
4122+
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
4123+
}
40804124
}

models/AddToConference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { Unpark } from './Unpark';
3939
import { HttpFile } from '../http/http';
4040

4141
/**
42-
* The `AddToConference` command adds a Participant to a Conference. If this Participant currently is in another Conference, the Participant is first removed from that Conference. Two Call legs can be bridged together by creating a Conference and adding both Call legs to it via `AddToConference`.
42+
* The `AddToConference` command adds a Participant to a Conference. Two Call legs can be bridged together by creating a Conference and adding both Call legs to it via `AddToConference`.
4343
*/
4444

4545
interface AttributeType {

0 commit comments

Comments
 (0)