-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.2-next' into DEVEXP-446_Refactor-models-in-Verificat…
…ion-SDK
- Loading branch information
Showing
32 changed files
with
655 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
.DS_Store | ||
|
||
.env | ||
fax-pdf/ | ||
fax-pdf/* | ||
!fax-pdf/you-faxed.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Fax } from '@sinch/sdk-core'; | ||
import { | ||
getFaxCallbackUrlFromConfig, | ||
getPhoneNumberFromConfig, | ||
getPrintFormat, | ||
initFaxService, | ||
printFullResponse, | ||
} from '../../config'; | ||
import * as fs from 'fs'; | ||
|
||
const getBase64 = (filePath: string): Fax.FaxBase64File => { | ||
const fileExtension = filePath.split('.').pop()?.toUpperCase(); | ||
try { | ||
const fileBuffer = fs.readFileSync(filePath); | ||
return { | ||
file: fileBuffer.toString('base64'), | ||
fileType: Fax.convertToSupportedFileType(fileExtension), | ||
}; | ||
} catch (error) { | ||
console.error('Error reading or converting the file:', error); | ||
throw error; | ||
} | ||
}; | ||
|
||
(async () => { | ||
console.log('*************************'); | ||
console.log('* sendFax - base64 file *'); | ||
console.log('*************************'); | ||
|
||
const originPhoneNumber = getPhoneNumberFromConfig(); | ||
const destinationPhoneNumber = getPhoneNumberFromConfig(); | ||
const faxCallbackUrl = getFaxCallbackUrlFromConfig(); | ||
|
||
const requestData: Fax.SendSingleFaxRequestData = { | ||
sendFaxRequestBody: { | ||
to: destinationPhoneNumber, | ||
from: originPhoneNumber, | ||
contentUrl: 'https://developers.sinch.com/', | ||
files: [getBase64('./fax-pdf/you-faxed.pdf')], | ||
callbackUrl: faxCallbackUrl, | ||
callbackUrlContentType: 'application/json', | ||
imageConversionMethod: 'MONOCHROME', | ||
headerTimeZone: 'Europe/Paris', | ||
headerText: ' - Sent with the Node.js SDK', | ||
maxRetries: 2, | ||
}, | ||
}; | ||
|
||
const faxService = initFaxService(); | ||
const response = await faxService.faxes.send(requestData); | ||
|
||
const printFormat = getPrintFormat(process.argv); | ||
|
||
if (printFormat === 'pretty') { | ||
const fax = response[0]; | ||
console.log(`Fax successfully created at '${fax.createTime?.toISOString()}'. Status = '${fax.status}'`); | ||
} else { | ||
printFullResponse(response); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Fax } from '@sinch/sdk-core'; | ||
import { | ||
getFaxCallbackUrlFromConfig, | ||
getPhoneNumberFromConfig, | ||
getPrintFormat, | ||
initFaxService, | ||
printFullResponse, | ||
} from '../../config'; | ||
|
||
(async () => { | ||
console.log('**********************'); | ||
console.log('* sendFax - filePath *'); | ||
console.log('**********************'); | ||
|
||
const originPhoneNumber = getPhoneNumberFromConfig(); | ||
const destinationPhoneNumber = getPhoneNumberFromConfig(); | ||
const faxCallbackUrl = getFaxCallbackUrlFromConfig(); | ||
|
||
const requestData: Fax.SendSingleFaxRequestData = { | ||
sendFaxRequestBody: { | ||
to: destinationPhoneNumber, | ||
from: originPhoneNumber, | ||
contentUrl: 'https://developers.sinch.com/', | ||
filePaths: ['./fax-pdf/you-faxed.pdf', './fax-pdf/you-faxed.pdf'], | ||
callbackUrl: faxCallbackUrl, | ||
callbackUrlContentType: 'application/json', | ||
imageConversionMethod: 'MONOCHROME', | ||
headerTimeZone: 'Europe/Paris', | ||
headerText: ' - Sent with the Node.js SDK', | ||
maxRetries: 2, | ||
}, | ||
}; | ||
|
||
const faxService = initFaxService(); | ||
const response = await faxService.faxes.send(requestData); | ||
|
||
const printFormat = getPrintFormat(process.argv); | ||
|
||
if (printFormat === 'pretty') { | ||
const fax = response[0]; | ||
console.log(`Fax successfully created at '${fax.createTime?.toISOString()}'. Status = '${fax.status}'`); | ||
} else { | ||
printFullResponse(response); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/fax/src/models/v3/date-range-filter/date-range-filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DateFormat } from '@sinch/sdk-client'; | ||
|
||
/** | ||
* Filter calls based on `createTime`. If not value is submitted, the default value is the prior week. | ||
* - `from: '2024-02-15'` will return all faxes from February 2024, 15th | ||
* - `from: '2024-02-01T14:00:00Z'` will return all faxes after 14:00:00 on the first of February 2024. | ||
* - `from: '2024-02-01T14:00:00Z'` + `to: '2024-02-01T15:00:00Z'` will return all faxes between 14:00:00 and 15:00:00 (inclusive) on the first of February 2024. | ||
* - `from: '2024-02-01'` + `to: '2024-02-29'` will return all faxes for all of February 2024. | ||
* | ||
* Note: It is also possible to submit partial dates. | ||
* - `from: '2024-02'` will return all faxes for February 2024 | ||
*/ | ||
export interface DateRangeFilter { | ||
/** */ | ||
from?: string | Date | DateFormat; | ||
/** */ | ||
to?: string | Date | DateFormat; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { DateRangeFilter } from './date-range-filter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.