@vencav/pohoda-client
v0.1.1
Published
TypeScript client for the Pohoda mServer XML API. Covers XML submission, response parsing, and stock export helpers.
Maintainers
Readme
@vencav/pohoda-client
TypeScript client for the Pohoda mServer XML API. Covers XML submission, parsed import/export responses, and stock export helpers.
Install
npm install @vencav/pohoda-client axiosaxios is a peer dependency and must be installed separately.
Usage
import { createPohodaClient } from "@vencav/pohoda-client";
const client = createPohodaClient({
endpoint: "http://192.168.1.102:666",
username: "admin",
password: "secret",
serverName: "TestServer",
ico: "12345678",
});All methods return a Result<T> and never throw.
API
sendXml(xml)
Posts XML to /xml and returns a parsed response.
const result = await client.sendXml(xml);
if (result.status === "ok" && result.data.success) {
console.log(result.data.id, result.data.number);
}sendStockExportXml(xml)
Posts stock export XML to /xml and returns parsed stock items.
const result = await client.sendStockExportXml(xml);
if (result.status === "ok") {
console.log(result.data.items);
}getConfig()
Returns the client config passed to createPohodaClient().
Result type
The package re-exports Result from @vencav/result.
import { Result } from "@vencav/pohoda-client";Notes
- Both
http://andhttps://endpoints are supported. - Embedded credentials in
endpointare rejected. - The client reuses a keep-alive HTTP agent to avoid repeated TCP handshake overhead on mServer requests.
License
MIT
