From c3fcd04a4c900c6b6f10152db5072321da80915b Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Thu, 4 Apr 2024 11:35:44 +0200 Subject: [PATCH] DEVEXP-378: Fix Fax API issues --- .../v3/fax-content-url/fax-content-url.ts | 6 +++- .../src/models/v3/fax-request/fax-request.ts | 8 ++--- packages/fax/src/models/v3/fax/fax.ts | 8 ++--- .../service-phone-number.ts | 2 +- packages/fax/src/rest/v3/faxes/faxes-api.ts | 30 +++++++++---------- .../client/api-client-pagination-helper.ts | 5 ++-- .../sdk-client/src/client/api-fetch-client.ts | 12 ++++---- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/packages/fax/src/models/v3/fax-content-url/fax-content-url.ts b/packages/fax/src/models/v3/fax-content-url/fax-content-url.ts index 6e6c5dba..9ad9d050 100644 --- a/packages/fax/src/models/v3/fax-content-url/fax-content-url.ts +++ b/packages/fax/src/models/v3/fax-content-url/fax-content-url.ts @@ -1,5 +1,9 @@ /** - * Give us any URL on the Internet (including ones with basic authentication) At least one file or contentUrl parameter is required. Please note: If you are passing fax a secure URL (starting with https://), make sure that your SSL certificate (including your intermediate cert, if you have one) is installed properly, valid, and up-to-date. If the file parameter is specified as well, content from URLs will be rendered before content from files. You can add multiple URLs by adding them as an array them with a comma when posting as multipart/form-data For example: \"https://developers.sinch.com/fax/fax.pdf, https://developers.sinch.com/\" or if posting JSON `\"contentUrl\": [\"https://developers.sinch.com/fax/fax.pdf\", \"https://developers.sinch.com/\"]` + * Give us any URL on the Internet (including ones with basic authentication) At least one file or contentUrl parameter is required. + * Please note: If you are passing fax a secure URL (starting with https://), make sure that your SSL certificate (including your intermediate cert, if you have one) is installed properly, valid, and up-to-date. + * If the file parameter is specified as well, content from URLs will be rendered before content from files. + * You can add multiple URLs by adding them as an array them with a comma when posting as multipart/form-data + * For example: "https://developers.sinch.com/fax/fax.pdf, https://developers.sinch.com/" or if posting JSON `"contentUrl": ["https://developers.sinch.com/fax/fax.pdf", "https://developers.sinch.com/"]` */ export type FaxContentUrl = string | string[]; diff --git a/packages/fax/src/models/v3/fax-request/fax-request.ts b/packages/fax/src/models/v3/fax-request/fax-request.ts index 9330d560..1571a84a 100644 --- a/packages/fax/src/models/v3/fax-request/fax-request.ts +++ b/packages/fax/src/models/v3/fax-request/fax-request.ts @@ -5,13 +5,13 @@ import { FaxBase64File } from '../fax-base64-file'; export type FaxRequest = FaxRequestJson | FaxRequestFormData; interface FaxRequestBase { - /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \\\'+\\\'. */ + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading '+'. */ to: string; - /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \\\'+\\\'. */ + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading '+'. */ from?: string; /** */ contentUrl?: FaxContentUrl; - /** Text that will be displayed at the top of each page of the fax. 50 characters maximum. Default header text is \\\"-\\\". Note that the header is not applied until the fax is transmitted, so it will not appear on fax PDFs or thumbnails. */ + /** Text that will be displayed at the top of each page of the fax. 50 characters maximum. Default header text is "-". Note that the header is not applied until the fax is transmitted, so it will not appear on fax PDFs or thumbnails. */ headerText?: string; /** If true, page numbers will be displayed in the header. Default is true. */ headerPageNumbers?: boolean; @@ -29,7 +29,7 @@ interface FaxRequestBase { imageConversionMethod?: ImageConversionMethod; /** ID of the fax service used. */ serviceId?: string; - /** | The number of times the fax will be retired before cancel. Default value is set in your fax service. | The maximum number of retries is 5. */ + /** The number of times the fax will be retired before cancel. Default value is set in your fax service. The maximum number of retries is 5. */ maxRetries?: number; } diff --git a/packages/fax/src/models/v3/fax/fax.ts b/packages/fax/src/models/v3/fax/fax.ts index 89b78d6e..6ccef1fb 100644 --- a/packages/fax/src/models/v3/fax/fax.ts +++ b/packages/fax/src/models/v3/fax/fax.ts @@ -9,9 +9,9 @@ export interface Fax { id?: string; /** @see FaxDirection */ direction?: FaxDirection; - /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \'+\'. */ + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading '+'. */ from?: string; - /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \'+\'. */ + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading '+'. */ to?: string; /** @see FaxContentUrl */ contentUrl?: FaxContentUrl; @@ -27,7 +27,7 @@ export interface Fax { createTime?: Date; /** If the job is complete, this is a timestamp representing the time the job was completed. */ completedTime?: Date; - /** Text that will be displayed at the top of each page of the fax. 50 characters maximum. Default header text is \"-\". Note that the header is not applied until the fax is transmitted, so it will not appear on fax PDFs or thumbnails. */ + /** Text that will be displayed at the top of each page of the fax. 50 characters maximum. Default header text is "-". Note that the header is not applied until the fax is transmitted, so it will not appear on fax PDFs or thumbnails. */ headerText?: string; /** If true, page numbers will be displayed in the header. Default is true. */ headerPageNumbers?: boolean; @@ -53,7 +53,7 @@ export interface Fax { projectId?: string; /** ID of the fax service used. */ serviceId?: string; - /** | The number of times the fax will be retired before cancel. Default value is set in your fax service. | The maximum number of retries is 5. */ + /** The number of times the fax will be retired before cancel. Default value is set in your fax service. The maximum number of retries is 5. */ maxRetries?: number; /** The number of times the fax has been retried. */ retryCount?: number; diff --git a/packages/fax/src/models/v3/service-phone-number/service-phone-number.ts b/packages/fax/src/models/v3/service-phone-number/service-phone-number.ts index 131778b5..39a38906 100644 --- a/packages/fax/src/models/v3/service-phone-number/service-phone-number.ts +++ b/packages/fax/src/models/v3/service-phone-number/service-phone-number.ts @@ -1,7 +1,7 @@ export interface ServicePhoneNumber { - /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \'+\'. */ + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading '+'. */ phoneNumber?: string; /** The `Id` of the project associated with the call. */ projectId?: string; diff --git a/packages/fax/src/rest/v3/faxes/faxes-api.ts b/packages/fax/src/rest/v3/faxes/faxes-api.ts index 73978363..ad74fa2a 100644 --- a/packages/fax/src/rest/v3/faxes/faxes-api.ts +++ b/packages/fax/src/rest/v3/faxes/faxes-api.ts @@ -238,22 +238,22 @@ export class FaxesApi extends FaxDomainApi { headers['Content-Type'] = 'application/json'; body = JSON.stringify(data['sendFaxRequestBody']); } else { - const formParams:any = {}; + const formParams: any = {}; const requestData = data.sendFaxRequestBody as FaxRequestFormData; - if( requestData.to ) { formParams['to'] = requestData.to; } - if( requestData.file ) { formParams['file'] = requestData.file; } - if( requestData.from ) { formParams['from'] = requestData.from; } - if( requestData.contentUrl ) { formParams['contentUrl'] = requestData.contentUrl; } - if( requestData.headerText ) { formParams['headerText'] = requestData.headerText; } - if( requestData.headerPageNumbers ) { formParams['headerPageNumbers'] = requestData.headerPageNumbers; } - if( requestData.headerTimeZone ) { formParams['headerTimeZone'] = requestData.headerTimeZone; } - if( requestData.retryDelaySeconds ) { formParams['retryDelaySeconds'] = requestData.retryDelaySeconds; } - if( requestData.labels ) { formParams['labels'] = requestData.labels; } - if( requestData.callbackUrl ) { formParams['callbackUrl'] = requestData.callbackUrl; } - if( requestData.callbackContentType ) { formParams['callbackContentType'] = requestData.callbackContentType; } - if( requestData.imageConversionMethod ) {formParams['imageConversionMethod'] = requestData.imageConversionMethod;} - if( requestData.serviceId ) { formParams['serviceId'] = requestData.serviceId; } - if( requestData.maxRetries ) { formParams['maxRetries'] = requestData.maxRetries; } + if( requestData.to ) { formParams.to = requestData.to; } + if( requestData.file ) { formParams.file = requestData.file; } + if( requestData.from ) { formParams.from = requestData.from; } + if( requestData.contentUrl ) { formParams.contentUrl = requestData.contentUrl; } + if( requestData.headerText ) { formParams.headerText = requestData.headerText; } + if( requestData.headerPageNumbers ) { formParams.headerPageNumbers = requestData.headerPageNumbers.toString(); } + if( requestData.headerTimeZone ) { formParams.headerTimeZone = requestData.headerTimeZone; } + if( requestData.retryDelaySeconds ) { formParams.retryDelaySeconds = requestData.retryDelaySeconds; } + if( requestData.labels ) { formParams.labels = requestData.labels; } + if( requestData.callbackUrl ) { formParams.callbackUrl = requestData.callbackUrl; } + if( requestData.callbackContentType ) { formParams.callbackContentType = requestData.callbackContentType; } + if( requestData.imageConversionMethod ) {formParams.imageConversionMethod = requestData.imageConversionMethod;} + if( requestData.serviceId ) { formParams.serviceId = requestData.serviceId; } + if( requestData.maxRetries ) { formParams.maxRetries = requestData.maxRetries; } body = this.client.processFormData(formParams, 'multipart/form-data'); } diff --git a/packages/sdk-client/src/client/api-client-pagination-helper.ts b/packages/sdk-client/src/client/api-client-pagination-helper.ts index 7e6d976f..6bec6955 100644 --- a/packages/sdk-client/src/client/api-client-pagination-helper.ts +++ b/packages/sdk-client/src/client/api-client-pagination-helper.ts @@ -60,7 +60,8 @@ class SinchIterator implements AsyncIterator { return updateQueryParamsAndSendRequest( this.apiClient, newParams, requestOptions, this.paginatedOperationProperties); } - if (this.paginatedOperationProperties.pagination === PaginationEnum.PAGE) { + if (this.paginatedOperationProperties.pagination === PaginationEnum.PAGE + || this.paginatedOperationProperties.pagination === PaginationEnum.PAGE3) { const newParams = { page: pageResult.nextPageValue, }; @@ -133,7 +134,7 @@ export const createNextPageMethod = ( newParams = { pageToken: nextPageValue, }; - } else if (context.pagination === PaginationEnum.PAGE) { + } else if (context.pagination === PaginationEnum.PAGE || context.pagination === PaginationEnum.PAGE3) { newParams = { page: nextPageValue, }; diff --git a/packages/sdk-client/src/client/api-fetch-client.ts b/packages/sdk-client/src/client/api-fetch-client.ts index 20f86787..bde6fe8d 100644 --- a/packages/sdk-client/src/client/api-fetch-client.ts +++ b/packages/sdk-client/src/client/api-fetch-client.ts @@ -284,17 +284,17 @@ export class ApiFetchClient extends ApiClient { if (type === 'multipart/form-data') { const formData: FormData = new FormData(); - for (const i in data) { - if (Object.prototype.hasOwnProperty.call(data, i)) { - formData.append(i, data[i]); + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + formData.append(key, data[key]); } } encodedData = formData; } else { const formData: string[] = []; - for (const i in data) { - if (Object.prototype.hasOwnProperty.call(data, i)) { - formData.push(`${i}=${encodeURIComponent(data[i])}`); + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + formData.push(`${key}=${encodeURIComponent(data[key])}`); } } encodedData = formData.join('&');