Skip to content

Commit

Permalink
Merge pull request #46 from veryfi/feature/LP-949-update-nodejs
Browse files Browse the repository at this point in the history
Update Types
  • Loading branch information
manycoding authored Nov 7, 2024
2 parents 815a699 + 01f95e2 commit 66653e6
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/client/getHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Client = require('../client/constructor');
*/
Client.prototype._get_headers = function (has_files = false) {
let final_headers = {
"User-Agent": "Node.js Veryfi-Nodejs/1.4.0",
"User-Agent": "Node.js Veryfi-Nodejs/1.4.1",
"Accept": "application/json",
"Content-Type": "application/json",
"Client-Id": this.client_id,
Expand Down
19 changes: 17 additions & 2 deletions lib/types/LineItem.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
import {BoundingElement} from "./BoundingElement";


export declare type LineItem = {
category?: null | string | BoundingElement;
country_of_origin?: null | string | BoundingElement;
custom_fields?: Record<string, unknown>;
date?: null | string | BoundingElement;
description?: null | string | BoundingElement;
discount?: null | number | BoundingElement;
discount_price?: null | number | BoundingElement;
discount_rate?: null | number | BoundingElement;
end_date?: null | string | BoundingElement;
full_description?: null | string | BoundingElement;
gross_total?: null | number | BoundingElement;
hsn?: null | string;
id?: null | number;
lot?: null | string | BoundingElement;
manufacturer?: null | string | BoundingElement;
net_total?: null | number | BoundingElement;
normalized_description?: null | string | BoundingElement;
order?: null | number;
price?: null | number | BoundingElement;
quantity?: null | number | BoundingElement;
reference?: null | string | BoundingElement;
section?: null | string;
sku?: null | string | BoundingElement;
start_date?: null | string;
tags?: null | null[];
subtotal?: null | number | BoundingElement;
tags?: null | string[];
tax?: null | number | BoundingElement;
tax_code?: null | string | BoundingElement;
tax_rate?: null | number;
text?: null | string | BoundingElement;
total?: null | number | BoundingElement;
type?: null | string;
unit_of_measure?: null | string;
upc?: null | string | BoundingElement;
weight?: null | number | BoundingElement;
};
26 changes: 23 additions & 3 deletions lib/types/Vendor.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
import {BoundingElement} from "./BoundingElement";

export declare type Vendor = {
abn_number?: null | string | BoundingElement;
account_currency?: null | string | BoundingElement;
account_number?: null | string | BoundingElement;
address?: null | string | BoundingElement;
bank_breakdown?: Array<null | Record<string, unknown>>;
bank_name?: null | string | BoundingElement;
bank_number?: null | string | BoundingElement;
bank_swift?: null | string | BoundingElement;
biller_code?: null | string | BoundingElement;
category?: null | string | BoundingElement;
country_code?: null | string | BoundingElement;
email?: null | string | BoundingElement;
external_id?: null | string | BoundingElement;
external_ids?: Array<null | string>;
fax_number?: null | string | BoundingElement;
iban?: null | string | BoundingElement;
lat?: number;
lng?: number;
logo?: null | string | BoundingElement;
logo_name?: null | string | BoundingElement;
map_url?: null | string | BoundingElement;
name?: null | string | BoundingElement;
order_number?: null | string | BoundingElement;
parsed_address?: null | Record<string, unknown>;
phone_number?: null | string | BoundingElement;
raw_address?: null | string | BoundingElement;
raw_name?: null | string;
vendor_logo?: null | string | BoundingElement;
vendor_reg_number?: null | string | BoundingElement;
vendor_type?: null | string;
reg_number?: null | string | BoundingElement;
type?: null | string | BoundingElement;
vat_number?: null | string | BoundingElement;
web?: null | string | BoundingElement;
};
62 changes: 60 additions & 2 deletions lib/types/VeryfiDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export declare type VeryfiDocument = {
account_number?: null | string | BoundingElement;
accounting_entry_type?: null | string;
balance?: null | string | BoundingElement;
barcodes?: null | string[] | BoundingElement[];
barcodes?: null | Array<{ data: string; type: string }>;
bill_to?: null | BillTo;
card_number?: null | string | BoundingElement;
cashback?: null | number | BoundingElement;
Expand Down Expand Up @@ -51,16 +51,75 @@ export declare type VeryfiDocument = {
is_document?: null | boolean;
is_duplicate?: null | boolean;
is_money_in?: null | boolean | BoundingElement;
language?: null | string[];
license_plate_number?: null | string | BoundingElement;
line_items?: null | LineItem[];
line_items_with_scores?: null | LineItem[];
meta?: null | {
device_id?: null | string;
device_user_uuid?: null | string;
duplicates?: Array<{
id: number;
score: number;
url: string;
}>;
fraud?: {
attribution?: null | string;
color?: string;
custom_types?: string[];
decision?: string;
images?: Array<{
is_lcd: boolean;
score: number;
}>;
pages?: Array<{
is_lcd: {
score: number;
value: boolean;
};
}>;
score?: number;
submissions?: Record<string, unknown>;
types?: string[];
version?: null | string;
};
handwritten_fields?: null | string[];
language?: null | string[];
owner?: null | string;
pages?: Array<{
height: number;
is_blurry: {
score: number;
value: boolean;
};
language: string[];
screenshot: {
score: number;
type: null | string;
};
width: number;
}>;
processed_pages?: null | number;
source?: null | string;
source_documents?: Array<{
height: number;
size_kb: number;
width: number;
}>;
total_pages?: null | number;
warnings?: Array<{
message: string;
type: string;
}>;
};
notes?: null | string;
ocr_text?: null | string;
order_date?: null | string | BoundingElement;
payment?: null | Payment;
pdf_url?: null | string;
previous_balance?: null | number | BoundingElement;
purchase_order_number?: null | string | BoundingElement;
reference_number?: null | string | BoundingElement;
rounding?: null | number | BoundingElement;
server_name?: null | string | BoundingElement;
service_end_date?: null | string;
Expand All @@ -76,7 +135,6 @@ export declare type VeryfiDocument = {
tax_lines?: null | TaxLine[];
tip?: null | number | BoundingElement;
total?: null | number | BoundingElement;
total_pages?: null | number;
total_quantity?: null | string | BoundingElement;
total_weight?: null | string | BoundingElement;
tracking_number?: null | string | BoundingElement;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@veryfi/veryfi-sdk",
"version": "1.4.0",
"version": "1.4.1",
"description": "Node.js module for communicating with the Veryfi OCR API",
"main": "lib/client/client.js",
"typings": "lib/types/Client.ts",
Expand Down
5 changes: 4 additions & 1 deletion test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ describe('Processing documents', () => {
const base64_encoded_string = Buffer.from(image_file).toString('utf-8');
let response = await veryfi_client.process_document_from_base64(
base64_encoded_string,
'receipt.png'
'receipt.png',
null,
false,
{device_data: {user_uuid: '7c4a4f92-9d31-4e56-8f2a-e62435f1b871'}}
);
expect(response['total']).toBe(34.95);
} catch (error) {
Expand Down

0 comments on commit 66653e6

Please sign in to comment.