summaryrefslogtreecommitdiff
blob: 228d25876aed63dcfec026c2391330c16b876a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module Struct.Flags exposing
   (
      Type,
      maybe_get_param
   )

-- Elm -------------------------------------------------------------------------
import List

-- Map -------------------------------------------------------------------
import Util.List

--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
   {
      user_id : String,
      token : String,
      url_params : (List (List String))
   }

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
maybe_get_param : String -> Type -> (Maybe String)
maybe_get_param param flags =
   case
      (Util.List.get_first
         (\e -> ((List.head e) == (Just param)))
         flags.url_params
      )
   of
      Nothing -> Nothing
      (Just a) ->
         case (List.tail a) of
            Nothing -> Nothing
            (Just b) -> (List.head b)