summaryrefslogtreecommitdiff
blob: 14d668c2d4d824d13cd0f3b6aa4646097e14daa7 (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
43
module Comm.GetID exposing (try)

-- Elm -------------------------------------------------------------------------
import Json.Encode

-- Extension -------------------------------------------------------------------
import Comm.Send

import Constants.IO

import Struct.Event
import Struct.Model

--------------------------------------------------------------------------------
-- TYPES ------------------------------------------------------------------------
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
try_encoding : String -> Struct.Model.Type -> (Maybe Json.Encode.Value)
try_encoding player_id model =
   let
      encoded_player_id = (Json.Encode.string player_id)
   in
      (Just
         (Json.Encode.object
            [
               ("id", encoded_player_id)
            ]
         )
      )

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
try : Struct.Model.Type -> String -> (Maybe (Cmd Struct.Event.Type))
try model =
   (Comm.Send.try_sending
      model
      Constants.IO.get_battles_handler
      (try_encoding player_id)
   )