-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
349 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
open Lwt.Syntax | ||
|
||
let get_inventory ?(profile_ids = []) game domain send = | ||
match profile_ids with | ||
| [] -> Lwt.fail_with "Profile IDs list cannot be empty" | ||
| _ids -> | ||
let base_url = | ||
Uri.make ~scheme:"https" ~host:domain ~path:"/community/achievement/getInventoryByProfileIDs" () | ||
in | ||
let url = | ||
Uri.with_query' base_url [ "title", Data.Game.to_str game; "profileids", Data.Query.encode_lst_i profile_ids ] | ||
in | ||
let* json = send url in | ||
(match json with | ||
| Some j -> | ||
let model = Models.Response.Community.Inventory.from_json j in | ||
Lwt.return @@ Some model | ||
| None -> Lwt.return None) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
type t = | ||
{ result : Stub.Response.t | ||
; item_instances_by_profile_id : (string * Stub.Inventory.t list) list | ||
} | ||
|
||
let to_json r = | ||
`Assoc | ||
[ "result", Stub.Response.to_json r.result | ||
; ( "itemInstancesByProfileID" | ||
, `List | ||
(List.map | ||
(fun (profile_id, items) -> `Assoc [ profile_id, `List (List.map Stub.Inventory.to_json items) ]) | ||
r.item_instances_by_profile_id) ) | ||
] | ||
;; | ||
|
||
let from_json json = | ||
let open Yojson.Basic.Util in | ||
{ result = json |> member "result" |> Stub.Response.from_json | ||
; item_instances_by_profile_id = | ||
json | ||
|> member "itemInstancesByProfileID" | ||
|> to_list | ||
|> List.map (fun json -> | ||
match json with | ||
| `Assoc [ (profile_id, `List items) ] -> profile_id, List.map Stub.Inventory.from_json items | ||
| _ -> failwith "JSON structure mismatch") | ||
} | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
type t = | ||
{ id : int | ||
; entityversion : int | ||
; itemdefinition_id : int | ||
; profile_id : int | ||
; durability : int | ||
; durabilitytype : int | ||
; metadata : string | ||
; creationdate : int | ||
; itemlocation_locationid : int | ||
; itemtrade_id : int | ||
; permissionflags : int | ||
; maxchargesperitem : int | ||
} | ||
|
||
let to_json i = | ||
`Assoc | ||
[ "id", `Int i.id | ||
; "entityversion", `Int i.entityversion | ||
; "itemdefinition_id", `Int i.itemdefinition_id | ||
; "profile_id", `Int i.profile_id | ||
; "durability", `Int i.durability | ||
; "durabilitytype", `Int i.durabilitytype | ||
; "metadata", `String i.metadata | ||
; "creationdate", `Int i.creationdate | ||
; "itemlocation_locationid", `Int i.itemlocation_locationid | ||
; "itemtrade_id", `Int i.itemtrade_id | ||
; "permissionflags", `Int i.permissionflags | ||
; "maxchargesperitem", `Int i.maxchargesperitem | ||
] | ||
;; | ||
|
||
let from_json json = | ||
let open Yojson.Basic.Util in | ||
{ id = json |> member "id" |> to_int | ||
; entityversion = json |> member "entityversion" |> to_int | ||
; itemdefinition_id = json |> member "itemdefinition_id" |> to_int | ||
; profile_id = json |> member "profile_id" |> to_int | ||
; durability = json |> member "durability" |> to_int | ||
; durabilitytype = json |> member "durabilitytype" |> to_int | ||
; metadata = json |> member "metadata" |> to_string | ||
; creationdate = json |> member "creationdate" |> to_int | ||
; itemlocation_locationid = json |> member "itemlocation_locationid" |> to_int | ||
; itemtrade_id = json |> member "itemtrade_id" |> to_int | ||
; permissionflags = json |> member "permissionflags" |> to_int | ||
; maxchargesperitem = json |> member "maxchargesperitem" |> to_int | ||
} | ||
;; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
{ | ||
"result": { | ||
"code": 0, | ||
"message": "SUCCESS" | ||
}, | ||
"itemInstancesByProfileID": [ | ||
{ | ||
"\"196240\"": [ | ||
{ | ||
"id": 60757, | ||
"entityversion": 4, | ||
"itemdefinition_id": 451923, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"sigil_pos\":{\"val\":\"001_centre_large_single\"}}}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 4, | ||
"itemtrade_id": -1, | ||
"permissionflags": 3, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 1261739493, | ||
"entityversion": 7, | ||
"itemdefinition_id": 454688, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "", | ||
"creationdate": 1699988311, | ||
"itemlocation_locationid": 2, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 60758, | ||
"entityversion": 2, | ||
"itemdefinition_id": 451960, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 5, | ||
"itemtrade_id": -1, | ||
"permissionflags": 3, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 333168196, | ||
"entityversion": 5, | ||
"itemdefinition_id": 453145, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}}}", | ||
"creationdate": 1651697316, | ||
"itemlocation_locationid": 5, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 789328289, | ||
"entityversion": 1, | ||
"itemdefinition_id": 453186, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{}", | ||
"creationdate": 1681644640, | ||
"itemlocation_locationid": 5, | ||
"itemtrade_id": -1, | ||
"permissionflags": 3, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 60759, | ||
"entityversion": 247, | ||
"itemdefinition_id": 452595, | ||
"profile_id": 196240, | ||
"durability": 10182420, | ||
"durabilitytype": 0, | ||
"metadata": "{}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 3, | ||
"itemtrade_id": -1, | ||
"permissionflags": 3, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 333152484, | ||
"entityversion": 5, | ||
"itemdefinition_id": 452432, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}}}", | ||
"creationdate": 1651695281, | ||
"itemlocation_locationid": 3, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 60770, | ||
"entityversion": 2, | ||
"itemdefinition_id": 451952, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"eslot\":\"2\"}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 19, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 60784, | ||
"entityversion": 2, | ||
"itemdefinition_id": 452534, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"eslot\":\"10\"}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 19, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 60793, | ||
"entityversion": 2, | ||
"itemdefinition_id": 452547, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"eslot\":\"4\"}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 19, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 60807, | ||
"entityversion": 4, | ||
"itemdefinition_id": 452486, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"eslot\":\"8\"}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 19, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 60810, | ||
"entityversion": 2, | ||
"itemdefinition_id": 452553, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"eslot\":\"6\"}", | ||
"creationdate": 1634470265, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 19, | ||
"maxchargesperitem": 2147483647 | ||
}, | ||
{ | ||
"id": 234628989, | ||
"entityversion": 5, | ||
"itemdefinition_id": 451939, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}},\"eslot\":\"3\"}", | ||
"creationdate": 1639776723, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 334039191, | ||
"entityversion": 5, | ||
"itemdefinition_id": 453329, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}},\"eslot\":\"5\"}", | ||
"creationdate": 1651859675, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 341369934, | ||
"entityversion": 6, | ||
"itemdefinition_id": 453439, | ||
"profile_id": 196240, | ||
"durability": 2, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}},\"eslot\":\"7\"}", | ||
"creationdate": 1653498648, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
}, | ||
{ | ||
"id": 342281892, | ||
"entityversion": 5, | ||
"itemdefinition_id": 453442, | ||
"profile_id": 196240, | ||
"durability": 1, | ||
"durabilitytype": 0, | ||
"metadata": "{\"att\":{\"is_new\":{\"val\":\"0\"}},\"eslot\":\"1\"}", | ||
"creationdate": 1653680895, | ||
"itemlocation_locationid": 60757, | ||
"itemtrade_id": -1, | ||
"permissionflags": 51, | ||
"maxchargesperitem": -1 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters