Documentation
¶
Overview ¶
Package ultraocr implements utilities to help on the UltraOCR API usage.
Package ultraocr implements utilities to help on the UltraOCR API usage.
Index ¶
- type BatchStatusJobs
- type BatchStatusResponse
- type Client
- func (client *Client) Authenticate(ctx context.Context, clientID, clientSecret string, expires int) error
- func (client *Client) CreateAndWaitBatch(ctx context.Context, service, filePath string, metadata []map[string]any, ...) (BatchStatusResponse, error)
- func (client *Client) CreateAndWaitJob(ctx context.Context, ...) (JobResultResponse, error)
- func (client *Client) GenerateSignedUrl(ctx context.Context, service, resource string, metadata any, ...) (SignedUrlResponse, error)
- func (client *Client) GetBatchStatus(ctx context.Context, ID string) (BatchStatusResponse, error)
- func (client *Client) GetJobResult(ctx context.Context, batchID, jobID string) (JobResultResponse, error)
- func (client *Client) GetJobs(ctx context.Context, start, end string) ([]JobResultResponse, error)
- func (client *Client) SendBatch(ctx context.Context, service, filePath string, metadata []map[string]any, ...) (CreatedResponse, error)
- func (client *Client) SendBatchBase64(ctx context.Context, service, file string, metadata []map[string]any, ...) (CreatedResponse, error)
- func (client *Client) SendJob(ctx context.Context, ...) (CreatedResponse, error)
- func (client *Client) SendJobBase64(ctx context.Context, service, file, facematchFile, extraFile string, ...) (CreatedResponse, error)
- func (client *Client) SendJobSingleStep(ctx context.Context, service, file, facematchFile, extraFile string, ...) (CreatedResponse, error)
- func (client *Client) SetAuthBaseURL(url string)
- func (client *Client) SetAutoRefresh(clientID, clientSecret string, expires int)
- func (client *Client) SetBaseURL(url string)
- func (client *Client) SetHttpClient(httpClient HttpClient)
- func (client *Client) SetInterval(interval int)
- func (client *Client) SetTimeout(timeout int)
- func (client Client) UploadFile(ctx context.Context, url string, path string) error
- func (client Client) UploadFileBase64(ctx context.Context, url string, data string) error
- func (client *Client) WaitForBatchDone(ctx context.Context, ID string, waitJobs bool) (BatchStatusResponse, error)
- func (client *Client) WaitForJobDone(ctx context.Context, batchID, jobID string) (JobResultResponse, error)
- type CreatedResponse
- type GetJobsResponse
- type HttpClient
- type JobResultResponse
- type Response
- type Result
- type SignedUrlResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchStatusJobs ¶
type BatchStatusResponse ¶
type Client ¶
type Client struct { BaseURL string AuthBaseURL string Token string ClientID string ClientSecret string AutoRefresh bool Expires int Timeout int Interval int ExpiresAt time.Time HttpClient HttpClient }
func (*Client) Authenticate ¶
func (client *Client) Authenticate(ctx context.Context, clientID, clientSecret string, expires int) error
Authenticate Generates a token on UltraOCR and save the token to use on future requests. Requires the Client informations (ID and Secret) and the token expiration time (in minutes).
func (*Client) CreateAndWaitBatch ¶
func (client *Client) CreateAndWaitBatch(ctx context.Context, service, filePath string, metadata []map[string]any, params map[string]string, waitJobs bool, ) (BatchStatusResponse, error)
CreateAndWaitJob Creates and wait a batch to be done. Have a timeout and an interval configured on the Client. Requires the service, file path and required metadata and query params.
func (*Client) CreateAndWaitJob ¶
func (client *Client) CreateAndWaitJob(ctx context.Context, service, filePath, facematchFilePath, extraFilePath string, metadata map[string]any, params map[string]string, ) (JobResultResponse, error)
CreateAndWaitJob Creates and wait a job to be done. Have a timeout and an interval configured on the Client. Requires the service, files paths and required metadata and query params.
func (*Client) GenerateSignedUrl ¶
func (client *Client) GenerateSignedUrl( ctx context.Context, service, resource string, metadata any, params map[string]string, ) (SignedUrlResponse, error)
GenerateSignedUrl Generates a signed url to upload the document image to be processed. Requires the service (document type), the resource (job or batch) and the required metadata and query params.
func (*Client) GetBatchStatus ¶
GetBatchStatus Gets the batch status. Requires the batch ID.
func (*Client) GetJobResult ¶
func (client *Client) GetJobResult(ctx context.Context, batchID, jobID string) (JobResultResponse, error)
GetBatchStatus Gets the job result. Requires the batch and job ID.
func (*Client) GetJobs ¶
GetJobs Gets the jobs in a time interval. Requires the start and end time in 2006-01-02 format.
func (*Client) SendBatch ¶
func (client *Client) SendBatch(ctx context.Context, service, filePath string, metadata []map[string]any, params map[string]string, ) (CreatedResponse, error)
SendBatch Sends a batch. Requires the service, the file path and the required metadata and query params.
func (*Client) SendBatchBase64 ¶
func (client *Client) SendBatchBase64(ctx context.Context, service, file string, metadata []map[string]any, params map[string]string, ) (CreatedResponse, error)
SendBatchBase64 Sends a batch on base64 format. Requires the service, the file on base64 format and the required metadata and query params.
func (*Client) SendJob ¶
func (client *Client) SendJob(ctx context.Context, service, filePath, facematchFilePath, extraFilePath string, metadata map[string]any, params map[string]string, ) (CreatedResponse, error)
SendJob Sends a job. Requires the service, the files (facematch and extra file if requested on params) paths and the required metadata and query params.
func (*Client) SendJobBase64 ¶
func (client *Client) SendJobBase64(ctx context.Context, service, file, facematchFile, extraFile string, metadata map[string]any, params map[string]string, ) (CreatedResponse, error)
SendJobBase64 Sends a job on base64 format. Requires the service, the files (facematch and extra file if requested on params) on base64 format and the required metadata and query params.
func (*Client) SendJobSingleStep ¶
func (client *Client) SendJobSingleStep( ctx context.Context, service, file, facematchFile, extraFile string, metadata map[string]any, params map[string]string, ) (CreatedResponse, error)
SendJobSingleStep Sends a job in single step, with 6MB body limit. Requires the service, the files (facematch and extra file if requested on params) on base64 format and the required metadata and query params.
func (*Client) SetAuthBaseURL ¶
SetAuthBaseURL Changes the Client Authentication Base URL.
func (*Client) SetAutoRefresh ¶
SetAutoRefresh Changes Client to auto refresh token.
func (*Client) SetBaseURL ¶
SetBaseURL Changes the Client Base URL.
func (*Client) SetHttpClient ¶
func (client *Client) SetHttpClient(httpClient HttpClient)
SetHttpClient Changes the Client HTTP Client.
func (*Client) SetInterval ¶
SetInterval Changes the Client interval (in seconds) between requests on wait job and batch done.
func (*Client) SetTimeout ¶
SetTimeout Changes the Client (timeout in seconds) on wait job and batch done.
func (Client) UploadFile ¶
UploadFileBase64 Upload a file given a path. Requires the s3 URL and the file path.
func (Client) UploadFileBase64 ¶
UploadFileBase64 Upload a file on base64 format. Requires the s3 URL and the data on base64 (string).
func (*Client) WaitForBatchDone ¶
func (client *Client) WaitForBatchDone(ctx context.Context, ID string, waitJobs bool) (BatchStatusResponse, error)
WaitForBatchDone Waits for the batch status be done or error. Have a timeout and an interval configured on the Client. Requires the batch and an info if the utility will also wait the jobs to be done.
func (*Client) WaitForJobDone ¶
func (client *Client) WaitForJobDone(ctx context.Context, batchID, jobID string) (JobResultResponse, error)
WaitForJobDone Waits for the job status be done or error. Have a timeout and an interval configured on the Client. Requires the batch and job ID.
type CreatedResponse ¶
type GetJobsResponse ¶
type GetJobsResponse struct { Jobs []JobResultResponse `json:"jobs"` NextPageToken string `json:"nextPageToken"` }
type JobResultResponse ¶
type JobResultResponse struct { Result Result `json:"result,omitempty"` JobID string `json:"job_ksuid"` CreatedAt string `json:"created_at"` Service string `json:"service"` Status string `json:"status"` Error string `json:"error,omitempty"` ProcessTime string `json:"process_time,omitempty"` Filename string `json:"filename,omitempty"` ValidationStatus string `json:"validation_status,omitempty"` ClientData interface{} `json:"client_data,omitempty"` Validation interface{} `json:"validation,omitempty"` }