UNPKG

vendus-sdk

Version:

Unofficial Vendus API SDK for Node.js

274 lines (269 loc) 7.44 kB
type ClientStatus = "active" | "inactive"; type Client = { id: number; fiscal_id: string; external_reference: string; default_pay_due: "now" | "1" | "15" | "30" | "45" | "60" | "90"; name: string; address: string; city: string; postalcode: string; phone: string; mobile: string; email: string; website: string; country: string; price_group: { id: number; title: string; is_default: string; }; send_email: Boolean; irs_retention: Boolean; status: ClientStatus; notes: string; date: string; balance: { total: string; on_time: string; overdue: string; }; }; type ClientWithoutBalance = Omit<Client, "balance">; type CreateClient = Omit<Partial<Client>, "id" | "balance" | "price_group" | "status" | "date"> & { price_group_id?: number; }; type UpdateClient = Partial<CreateClient> & { id: number; }; declare class ClientApi { #private; constructor({ client }: { client: VendusClient; }); getClients(params?: { q?: string; fiscal_id?: string; name?: string; email?: string; external_reference?: string; status?: ClientStatus; date?: string; id?: string; }): Promise<ClientWithoutBalance[]>; getClient(id: number): Promise<Client>; updateClient(params: UpdateClient): Promise<Client>; createClient(params: CreateClient): Promise<Client>; } type Document = { register_id?: string; type: DocumentType; discount_code?: string; discount_amount?: string; discount_percentage?: string; date_due?: string; payments?: Payment[]; mode?: "normal" | "tests"; date?: string; date_supply?: string; notes?: string; ncr_id?: string; external_reference?: string; stock_operation?: "in" | "none" | "out"; ifthenpay?: Boolean; eupago?: Boolean; multibanco?: Multibanco; client?: UpdateClient; supplier?: Supplier; items?: Item[]; movement_of_goods?: MovementOfGoods; print_discount?: Boolean; output?: "pdf" | "html" | "escpos" | "tpasibs"; output_template_id?: number; tx_id?: string; errors_full?: Boolean; rest_room?: number; rest_table?: number; occupation?: number; stamp_retention_amount?: string; irc_retention_id?: string; related_document_id?: number; return_qrcode?: number; }; type DocumentType = "FT" | "FS" | "FR" | "NC" | "DC" | "PF" | "OT" | "EC" | "GA" | "GT" | "GR" | "GD" | "RG"; type Payment = { id: number; amount: string; date_due?: string; }; type Multibanco = { entity: string; reference: string; amount: string; }; type Supplier = { id?: string; fiscal_id?: string; name?: string; address?: string; postalcode?: string; city?: string; phone?: string; mobile?: string; email?: string; website?: string; country?: string; obs?: string; }; type Item = { id?: string; reference?: string; gross_price?: string; supply_price?: string; qty: string; type_id?: ItemType; variant_id?: string; title?: string; unit_id?: string; category_id?: string; brand_id?: string; discount_amount?: string; discount_percentage?: string; stock_control?: string; stock_type?: StockType; tax_id?: TaxId; tax_exemption?: TaxExemption; tax_exemption_law?: string; tax_custom?: TaxCustom; reference_document?: ReferenceDocument; text?: string; serial?: string; }; type ItemType = "P" | "S" | "O" | "I" | "E"; type StockType = "M" | "P" | "A" | "S" | "T"; type TaxId = "NOR" | "INT" | "RED" | "ISE" | "OUT"; type TaxExemption = "M01" | "M02" | "M03" | "M04" | "M05" | "M06" | "M07" | "M08" | "M09" | "M10" | "M11" | "M12" | "M13" | "M14" | "M15" | "M16" | "M19" | "M20" | "M21" | "M25" | "M26" | "M30" | "M31" | "M32" | "M33" | "M34" | "M40" | "M41" | "M42" | "M43" | "M99"; type TaxCustom = { country: string; rate: string; code: TaxId; type?: string; }; type ReferenceDocument = { document_number: string; document_row: string; reference_id: string; reference_relation?: string; }; type MovementOfGoods = { vehicle_id: string; show_prices: string; loadpoint: Loadpoint; landpoint: Landpoint; invoices: Document[]; print_discount: string; output: string; output_template_id: string; tx_id: string; errors_full: string; rest_room: string; rest_table: string; occupation: string; stamp_retention_amount: string; irc_retention_id: string; related_document_id: string; return_qrcode: string; }; type Loadpoint = { date: string; time: string; address: string; postalcode: string; city: string; country: string; store_id: string; changestock: string; }; type Landpoint = { is_global: string; date: string; time: string; address: string; postalcode: string; city: string; country: string; store_id: string; receivestock: string; }; type DocumentResponse = { id?: number; type?: DocumentType; subtype?: "G"; tax_authority_id?: string; number?: string; date?: string; date_supply?: string; system_time?: string; local_time?: string; amount_gross?: string; amount_net?: string; hash?: string; atcud?: string; output?: string; qrcode?: string; qrcode_data?: string; }; declare class DocumentApi { #private; constructor({ client }: { client: VendusClient; }); createDocument(document: Document): Promise<DocumentResponse>; } declare function date(date: Date): string; declare function number(number: number): string; type HeadersType = { [key: string]: string; }; type BodyType = { [key: string]: string | number | boolean | object; }; type QueryParametersType = { [key: string]: string[] | string | number | boolean; }; type RequestParameters = RequestBodyParameters | RequestNoBodyParameters; interface RequestBodyParameters { method: "POST" | "PUT" | "PATCH"; endpoint: string; parameters?: QueryParametersType; headers?: HeadersType; body?: BodyType; } interface RequestNoBodyParameters { method: "GET" | "DELETE"; endpoint: string; parameters?: QueryParametersType; headers?: HeadersType; body?: undefined; contentType?: undefined; } type Boolean = "yes" | "no"; declare class VendusClient { apiKey: string; baseUrl: string; debug: boolean; headers: HeadersType; client: ClientApi; document: DocumentApi; constructor({ apiKey, baseUrl, debug, }: { apiKey: string; baseUrl?: string; debug?: boolean; }); request({ endpoint, headers, parameters, body, method, }: RequestParameters): Promise<any>; queryParameters(parameters: QueryParametersType): string; authenticationHeader(): { Authorization: string; }; } export { BodyType, Boolean, Client, ClientStatus, ClientWithoutBalance, CreateClient, Document, DocumentResponse, DocumentType, HeadersType, Item, ItemType, Landpoint, Loadpoint, MovementOfGoods, Multibanco, Payment, QueryParametersType, ReferenceDocument, RequestBodyParameters, RequestNoBodyParameters, RequestParameters, StockType, Supplier, TaxCustom, TaxExemption, TaxId, UpdateClient, date, VendusClient as default, number };