Skip to content

Commit

Permalink
Add profile ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruhlmann committed May 31, 2024
1 parent 109429f commit d88519a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 21 deletions.
3 changes: 2 additions & 1 deletion lib/api/game/advertisement.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Lwt.Syntax
open Data.Sort

let find_observable ?(start = 1) ?(count = 100) ?(sort = Descending) game domain send =
let find_observable ?(start = 1) ?(count = 100) ?(sort = Descending) ?(profile_ids = []) game domain send =
let should_descend = match sort with Ascending -> 0 | Descending -> 1 in
let base_url = Uri.make ~scheme:"https" ~host:domain ~path:"/game/advertisement/findObservableAdvertisements" () in
let url =
Expand All @@ -20,6 +20,7 @@ let find_observable ?(start = 1) ?(count = 100) ?(sort = Descending) game domain
; "dataChecksum", "-888"
; "appBinaryChecksum", "113358"
; "versionFlags", "56950784"
; "profileids", Data.Query.encode_lst_i profile_ids
]
in
let* json = send url in
Expand Down
18 changes: 14 additions & 4 deletions lib/models/response/game/observable_advertisements.ml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
type t =
{ status : int
; advertisements : Stub.Game.Observable_advertisement.t list (* ; avatars : Yojson.Basic.t list *)
; advertisements : Stub.Game.Observable_advertisement.t list
; members : Stub.Game.Observable_advertisement_member.t list
; tail : Yojson.Basic.t list
}

let to_json a =
`List ([ `Int a.status; `List (List.map Stub.Game.Observable_advertisement.to_json a.advertisements) ] @ a.tail)
`List
([ `Int a.status
; `List (List.map Stub.Game.Observable_advertisement.to_json a.advertisements)
; `List (List.map Stub.Game.Observable_advertisement_member.to_json a.members)
]
@ a.tail)
;;

let from_json json =
match json with
| `List (`Int status :: `List items :: tail) ->
{ status; advertisements = List.map Stub.Game.Observable_advertisement.from_json items; tail }
| `List (`Int status :: `List items :: `List members :: tail) ->
{ status
; advertisements = List.map Stub.Game.Observable_advertisement.from_json items
; members = List.map Stub.Game.Observable_advertisement_member.from_json members
; tail
}
| _ -> failwith "Unexpected JSON format for the observable advertisements response"
;;
56 changes: 56 additions & 0 deletions lib/models/stub/game/observable_advertisement_member.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
type t =
{ int1 : int
; int2 : int
; platform_id : string
; icon : string
; name : string
; string1 : string
; int3 : int
; int4 : int
; int5 : int
; int6 : int
; int_null : int option
; string2 : string
; int7 : int
; list1 : Yojson.Basic.t list
}

let from_json json =
match json with
| `List [ int1; int2; platform_id; icon; name; string1; int3; int4; int5; int6; int_null; string2; int7; list1 ] ->
{ int1 = Yojson.Basic.Util.to_int int1
; int2 = Yojson.Basic.Util.to_int int2
; platform_id = Yojson.Basic.Util.to_string platform_id
; icon = Yojson.Basic.Util.to_string icon
; name = Yojson.Basic.Util.to_string name
; string1 = Yojson.Basic.Util.to_string string1
; int3 = Yojson.Basic.Util.to_int int3
; int4 = Yojson.Basic.Util.to_int int4
; int5 = Yojson.Basic.Util.to_int int5
; int6 = Yojson.Basic.Util.to_int int6
; int_null = Yojson.Basic.Util.to_int_option int_null
; string2 = Yojson.Basic.Util.to_string string2
; int7 = Yojson.Basic.Util.to_int int7
; list1 = Yojson.Basic.Util.to_list list1
}
| _ -> failwith "Unexpected observable advertisement member format"
;;

let to_json n =
`List
[ `Int n.int1
; `Int n.int2
; `String n.platform_id
; `String n.icon
; `String n.name
; `String n.string1
; `Int n.int3
; `Int n.int4
; `Int n.int5
; `Int n.int6
; (match n.int_null with Some i -> `Int i | None -> `Null)
; `String n.string2
; `Int n.int7
; `List n.list1
]
;;
16 changes: 0 additions & 16 deletions lib/models/stub/game/observable_advertisment_member.ml

This file was deleted.

0 comments on commit d88519a

Please sign in to comment.