From f2e170e56a03f64b222cb7259eb81cc9b06e830d Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 12 Apr 2024 16:16:25 +0200 Subject: [PATCH] Prepare for authentication --- lib/authentication/session.ml | 6 ++++++ lib/client.ml | 3 ++- lib/data/game.ml | 1 + lib/data/game.mli | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 lib/authentication/session.ml diff --git a/lib/authentication/session.ml b/lib/authentication/session.ml new file mode 100644 index 0000000..c1209c1 --- /dev/null +++ b/lib/authentication/session.ml @@ -0,0 +1,6 @@ +type t = + { id : string + ; last_update : int + } + +let minutes_before_expiration = 45 diff --git a/lib/client.ml b/lib/client.ml index 1e6e88c..cc798b5 100644 --- a/lib/client.ml +++ b/lib/client.ml @@ -3,9 +3,10 @@ open Lwt.Syntax type t = { domain : string ; game : Data.Game.t + ; session : Authentication.Session.t option } -let create domain game = { domain; game } +let create domain game = { domain; game; session = None } let get_json (url : Uri.t) = let* resp, body = Cohttp_lwt_unix.Client.get url in diff --git a/lib/data/game.ml b/lib/data/game.ml index 23983f1..9ac7894 100644 --- a/lib/data/game.ml +++ b/lib/data/game.ml @@ -5,3 +5,4 @@ type t = | Age4 let to_str = function Age1 -> "age1" | Age2 -> "age2" | Age3 -> "age3" | Age4 -> "age4" +let to_app_id = function Age1 -> 1017900 | Age2 -> 813780 | Age3 -> 933110 | Age4 -> 1466860 diff --git a/lib/data/game.mli b/lib/data/game.mli index 33e7a2e..068a2d9 100644 --- a/lib/data/game.mli +++ b/lib/data/game.mli @@ -13,3 +13,5 @@ type t = (** [to_str g] converts a game [g] into its string representation for use in the relic-link API *) val to_str : t -> string +(** [to_str g] converts a game [g] into its steam app id *) +val to_app_id : t -> int