Skip to content

Commit

Permalink
Remove system_date_time from device optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
waranlogesh committed Aug 1, 2024
1 parent 56b9038 commit cddae05
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/device.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ defmodule Onvif.Device do
:auth_type,
:time_diff_from_system_secs,
:port,
:device_service_path,
:system_date_time
:device_service_path
]

@type t :: %__MODULE__{}
Expand Down
11 changes: 10 additions & 1 deletion lib/media/ver10/osd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,16 @@ defmodule Onvif.Media.Ver10.OSD do
])
|> cast_embed(:font_color, with: &color_changeset/2)
|> cast_embed(:background_color, with: &color_changeset/2)
|> validate_inclusion(:date_format, ["M/d/yyyy", "MM/dd/yyyy", "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "dddd, MMMM dd, yyyy", "MMMM dd, yyyy", "dd MMMM, yyyy"])
|> validate_inclusion(:date_format, [
"M/d/yyyy",
"MM/dd/yyyy",
"dd/MM/yyyy",
"yyyy/MM/dd",
"yyyy-MM-dd",
"dddd, MMMM dd, yyyy",
"MMMM dd, yyyy",
"dd MMMM, yyyy"
])
|> validate_inclusion(:time_format, ["h:mm:ss tt", "hh:mm:ss tt", "H:mm:ss", "HH:mm:ss"])
end

Expand Down
13 changes: 13 additions & 0 deletions test/device_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Onvif.DeviceTest do
use ExUnit.Case, async: true

@moduletag capture_log: true

describe "to_struct/1" do
test "should parse given map to a valid device struct" do
device_map = Onvif.Factory.device() |> Jason.encode!() |> Jason.decode!()
{:ok, device} = Onvif.Device.to_struct(device_map)
assert device == Onvif.Factory.device()
end
end
end

0 comments on commit cddae05

Please sign in to comment.