Skip to content

Commit

Permalink
DEVEXP-378: Fix Fax API issues
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch committed Apr 4, 2024
1 parent 19a1445 commit c3fcd04
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -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[];
8 changes: 4 additions & 4 deletions packages/fax/src/models/v3/fax-request/fax-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/fax/src/models/v3/fax/fax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
30 changes: 15 additions & 15 deletions packages/fax/src/rest/v3/faxes/faxes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class SinchIterator<T> implements AsyncIterator<T> {
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,
};
Expand Down Expand Up @@ -133,7 +134,7 @@ export const createNextPageMethod = <T>(
newParams = {
pageToken: nextPageValue,
};
} else if (context.pagination === PaginationEnum.PAGE) {
} else if (context.pagination === PaginationEnum.PAGE || context.pagination === PaginationEnum.PAGE3) {
newParams = {
page: nextPageValue,
};
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk-client/src/client/api-fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('&');
Expand Down

0 comments on commit c3fcd04

Please sign in to comment.