async function processDocumentFields()

in appscript/main.gs [186:209]


async function processDocumentFields(documentType, contentBase64) {
  let settings = getCore().getDataJson('Settings');
  let response = await getCore().run({
    gatherer: ['docai'],
    srcData: {
      documentType: documentType,
      contentBase64: contentBase64,
    },
    destDatasetId: 'Fields',
    multiRowsGatherer: 'docai',
    docai: {
      authorization: 'Bearer ' + settings.oauthToken,
      projectId: settings.projectId,
      processorId: documentTypeMap[documentType].processorId,
      fieldKeyOnly: true,
    },
  });

  console.log(response.results);

  if (response.errors && response.errors.length > 0) {
    SpreadsheetApp.getUi().alert(response.errors);
  }
}