Skip to content

Commit

Permalink
#10532 add GetNTP
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloo committed Jul 17, 2024
1 parent ed90742 commit 32644c0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/devices/get_ntp.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule Onvif.Devices.GetNTP do
import SweetXml
import XmlBuilder

alias Onvif.Device

def soap_action, do: "http://www.onvif.org/ver10/device/wsdl/GetNTP"

@spec request(Device.t()) :: {:ok, any} | {:error, map()}
def request(device) do
Onvif.Devices.request(device, __MODULE__)
end

def request_body do
element(:"s:Body", [element(:"tds:GetNTP")])
end

def response(xml_response_body) do
xml_response_body
|> parse(namespace_conformant: true, quiet: true)
|> xpath(
~x"//s:Envelope/s:Body/tds:GetNTPResponse/tds:NTPInformation"e
|> add_namespace("s", "http://www.w3.org/2003/05/soap-envelope")
|> add_namespace("tds", "http://www.onvif.org/ver10/device/wsdl")
|> add_namespace("tt", "http://www.onvif.org/ver10/schema")
)
|> Onvif.Devices.NTP.parse()
|> Onvif.Devices.NTP.to_struct()
end

end

0 comments on commit 32644c0

Please sign in to comment.