mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The resource API is /v1/rest and the operation API is /v1/rpc: named for what they are, so neither shadows the other, and the v2-beta alias is gone. Hanzo IAM returns to /auth/callback, the callback path IAM already derives for this host, so sign-in needs no IAM change. Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { initClient } from '@ts-rest/core';
|
|
|
|
import { ApiContractV1 } from '../contract';
|
|
|
|
const main = async () => {
|
|
const client = initClient(ApiContractV1, {
|
|
baseUrl: 'http://localhost:3000/v1/rest',
|
|
baseHeaders: {
|
|
authorization: 'Bearer <my-token>',
|
|
},
|
|
});
|
|
|
|
const documentId = '1';
|
|
const recipientId = 1;
|
|
|
|
const { status, body } = await client.createField({
|
|
params: {
|
|
id: documentId,
|
|
},
|
|
body: {
|
|
type: 'SIGNATURE',
|
|
pageHeight: 2.5, // percent of page to occupy in height
|
|
pageWidth: 5, // percent of page to occupy in width
|
|
pageX: 10, // percent from left
|
|
pageY: 10, // percent from top
|
|
pageNumber: 1,
|
|
recipientId,
|
|
},
|
|
});
|
|
|
|
if (status !== 200) {
|
|
throw new Error('Failed to create field');
|
|
}
|
|
|
|
// One field in, one field out, but the response names a list or a single field.
|
|
const [field] = Array.isArray(body.fields) ? body.fields : [body.fields];
|
|
|
|
console.log(`Field created with id: ${field.id}`);
|
|
};
|
|
|
|
main().catch((error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
});
|