lineDetection(options?: { channel?: number; }): Resource<LineDetection>
The line crossing document of one channel.
An NVR's second channel
An NVR's second channel
import { assertEquals } from "@std/assert"; import { resolvesNext, spy } from "@std/testing/mock"; import { request } from "../request.ts"; import { lineDetection } from "./line-detection.ts"; assertEquals(lineDetection().path, "/ISAPI/Smart/LineDetection/1"); const fetch = spy(resolvesNext([ new Response("<LineDetection><id>2</id><enabled>true</enabled></LineDetection>"), ])); const line = await request({ baseUrl: "http://192.0.2.21", username: "admin", password: "hunter2", fetch, }, lineDetection({ channel: 2 })); assertEquals(line, { channel: 2, enabled: true, lines: [] }); assertEquals(fetch.calls[0].args[0], "http://192.0.2.21/ISAPI/Smart/LineDetection/2");
A device without the feature
A device without the feature
import { assertThrows } from "@std/assert"; import { IsapiError } from "../status/isapi-error.ts"; import { lineDetection } from "./line-detection.ts"; assertThrows( () => lineDetection().codec.parse( "<ResponseStatus><statusCode>4</statusCode>" + "<subStatusCode>notSupport</subStatusCode></ResponseStatus>", ), IsapiError, );
The resource: its path and the codec that reads it.