Skip to content

Commit

Permalink
Merge pull request #36 from mbta/pk/define-elevator-screen-config
Browse files Browse the repository at this point in the history
Define config structure for elevator screens
  • Loading branch information
PaulJKim authored Oct 3, 2024
2 parents 594c88a + e33cd7a commit f4cb272
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/config/screen.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule ScreensConfig.Screen do
| :busway_v2
| :dup
| :dup_v2
| :elevator_v2
| :gl_eink_single
| :gl_eink_double
| :gl_eink_v2
Expand All @@ -22,7 +23,7 @@ defmodule ScreensConfig.Screen do
| :pre_fare_v2

@type t :: %__MODULE__{
vendor: :gds | :mercury | :solari | :c3ms | :outfront | :lg_mri,
vendor: :gds | :mercury | :solari | :c3ms | :outfront | :lg_mri | :mimo,
device_id: String.t(),
name: String.t(),
app_id: app_id(),
Expand All @@ -38,6 +39,7 @@ defmodule ScreensConfig.Screen do
| V2.BusShelter.t()
| V2.Busway.t()
| V2.Dup.t()
| V2.Elevator.t()
| V2.GlEink.t()
| V2.PreFare.t()
| V2.SolariLarge.t(),
Expand All @@ -48,7 +50,7 @@ defmodule ScreensConfig.Screen do
@v2_app_id_suffix "_v2"

@recognized_app_ids ~w[bus_eink dup gl_eink_single gl_eink_double solari solari_large]a
@recognized_v2_app_ids ~w[bus_eink_v2 bus_shelter_v2 busway_v2 dup_v2 gl_eink_v2 solari_large_v2 pre_fare_v2]a
@recognized_v2_app_ids ~w[bus_eink_v2 bus_shelter_v2 busway_v2 dup_v2 elevator_v2 gl_eink_v2 solari_large_v2 pre_fare_v2]a
@recognized_app_id_strings Enum.map(
@recognized_app_ids ++ @recognized_v2_app_ids,
&Atom.to_string/1
Expand All @@ -61,6 +63,7 @@ defmodule ScreensConfig.Screen do
busway_v2: V2.Busway,
dup: Dup,
dup_v2: V2.Dup,
elevator_v2: V2.Elevator,
gl_eink_single: Gl,
gl_eink_double: Gl,
gl_eink_v2: V2.GlEink,
Expand Down Expand Up @@ -119,7 +122,7 @@ defmodule ScreensConfig.Screen do
|> String.ends_with?(@v2_app_id_suffix)
end

for vendor <- ~w[gds mercury solari c3ms outfront]a do
for vendor <- ~w[gds mercury solari mimo c3ms outfront]a do
vendor_string = Atom.to_string(vendor)

defp value_from_json("vendor", unquote(vendor_string), _app_id) do
Expand Down
23 changes: 23 additions & 0 deletions lib/config/v2/elevator.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule ScreensConfig.V2.Elevator do
@moduledoc false

alias ScreensConfig.V2.EvergreenContentItem

@type t :: %__MODULE__{
elevator_id: String.t(),
evergreen_content: list(EvergreenContentItem.t())
}

@enforce_keys [:elevator_id]
defstruct elevator_id: nil,
evergreen_content: []

use ScreensConfig.Struct,
children: [
evergreen_content: {:list, EvergreenContentItem}
]

defp value_from_json(_, value), do: value

defp value_to_json(_, value), do: value
end

0 comments on commit f4cb272

Please sign in to comment.