-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest-client): add Document Info endpoint
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/rest-client/src/api/conversion/conversionInfo.test.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,22 @@ | ||
import { describe, it } from '@jest/globals' | ||
|
||
import 'jest-extended' | ||
import { DOCUMENT_UUID } from '../../../test/fixtures' | ||
import { testSettings } from '../../../test/helpers' | ||
import { conversionInfo } from './conversionInfo' | ||
|
||
describe('conversionInfo', () => { | ||
it('should work with txt document', async () => { | ||
const { error, format } = await conversionInfo( | ||
{ uuid: DOCUMENT_UUID }, | ||
testSettings | ||
) | ||
|
||
expect(error).toBeNull() | ||
expect(format.name).toEqual('txt') | ||
expect(format.conversionFormats).toBeArray() | ||
expect(format.conversionFormats.map<string>(({ name }) => name)).toContain( | ||
'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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ApiRequestSettings, makeApiRequest } from '../../makeApiRequest' | ||
import { handleApiRequest } from '../handleApiRequest' | ||
|
||
export type ConversionInfoOptions = { | ||
uuid: string | ||
} | ||
|
||
export type ConversionInfoResponse = { | ||
error: string | null | ||
format: { | ||
name: string | ||
conversionFormats: { | ||
name: string | ||
}[] | ||
} | ||
convertedGroups: Record<string, string> | ||
} | ||
|
||
export async function conversionInfo( | ||
options: ConversionInfoOptions, | ||
userSettings: ApiRequestSettings | ||
): Promise<ConversionInfoResponse> { | ||
const apiRequest = await makeApiRequest( | ||
{ | ||
method: 'GET', | ||
path: `/convert/document/${options.uuid}/` | ||
}, | ||
userSettings | ||
) | ||
return handleApiRequest({ apiRequest, okCodes: [200] }) | ||
} |
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