Skip to content

Robo-Meister/flow-scribe-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

FlowScribe OCR SDK (PHP)

PHP client for connecting to the Robo-Meister FlowScribe OCR API.

Install

composer require robo-meister/flow-scribe-api

For local development from this repository, add the package as a path repository:

{
  "repositories": [
    {
      "type": "path",
      "url": "shared-profile/sdk/flowscribe-ocr/php"
    }
  ],
  "require": {
    "robo-meister/flow-scribe-api": "*"
  }
}

Usage

use Robo\FlowScribeOcr\FlowScribeOcrClient;

$client = new FlowScribeOcrClient(
    baseUrl: 'https://ocr.robo-meister.com'
);

$health = $client->health();
$metadata = $client->metadata();

$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
    'document_type' => 'invoice',
    'mode' => 'fuse',
    'journal_csv' => true,
]);

if (($result['exit_code'] ?? 1) === 0) {
    $parsed = $result['parsed'] ?? [];
    $csv = $result['csv'] ?? null;
}

Custom dictionary config

Pass either a JSON file path:

$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
    'config_path' => __DIR__ . '/custom-dictionary.json',
]);

Or pass an array that the SDK serializes as config.json for the multipart upload:

$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
    'config' => [
        'fields' => [
            'invoiceNumber' => ['keywords' => ['Invoice #']],
        ],
    ],
]);

Authenticated integration jobs

Authenticated integration routes require an access token generated by the Robo Connector link flow. The SDK sends the token as a bearer token.

use Robo\FlowScribeOcr\FlowScribeOcrClient;

$client = new FlowScribeOcrClient(
    baseUrl: 'https://ocr.robo-meister.com',
    accessToken: getenv('FLOWSCRIBE_ACCESS_TOKEN') ?: null
);

$queued = $client->ingestFlowScribe(__DIR__ . '/invoice.pdf', [
    'document_type' => 'invoice',
]);

$jobId = $queued['data']['job']['id'];
$status = $client->flowScribeStatus($jobId);

For the RC invoice OCR bridge, use ingestRcInvoice() and rcInvoiceStatus().

Errors

HTTP and transport failures throw FlowScribeOcrException:

use Robo\FlowScribeOcr\FlowScribeOcrException;

try {
    $result = $client->processDocument(__DIR__ . '/invoice.pdf');
} catch (FlowScribeOcrException $exception) {
    $statusCode = $exception->getStatusCode();
    $responseBody = $exception->getResponseBody();
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages