public void CreatePresenceBatchRequestBody()
        {
            ulong[] xuids                = new ulong[] { 2580478784034343, 2535771801919068, 2508565379774180 };
            string  expected             = TestData["PresenceBatchRequest.json"];
            PresenceBatchRequest request = new PresenceBatchRequest(
                xuids, PresenceLevel.All, onlineOnly: false);
            string body = NewtonsoftJsonSerializer.Create(JsonNamingStrategy.CamelCase)
                          .Serialize(request);

            Assert.AreEqual(expected, body);
        }
Exemplo n.º 2
0
        public PresenceBatchResponse GetPresenceBatch(ulong[] xuids,
                                                      PresenceLevel level = PresenceLevel.All,
                                                      bool onlineOnly     = false)
        {
            PresenceBatchRequest body    = new PresenceBatchRequest(xuids, level, onlineOnly);
            RestRequestEx        request = new RestRequestEx("users/batch", Method.POST);

            request.AddHeaders(Headers);
            request.AddJsonBody(body, JsonNamingStrategy.CamelCase);

            IRestResponse <PresenceBatchResponse> response = HttpClient.Execute <PresenceBatchResponse>(request);

            return(response.Data);
        }
Exemplo n.º 3
0
        public async Task <PresenceBatchResponse> GetPresenceBatchAsync(ulong[] xuids,
                                                                        PresenceLevel level = PresenceLevel.All,
                                                                        bool onlineOnly     = false)
        {
            PresenceBatchRequest body = new PresenceBatchRequest(xuids, level, onlineOnly);
            var request = new HttpRequestMessage(HttpMethod.Post, "users/batch");

            request.Headers.Add(Headers);
            request.Content = new JsonContent(body, JsonNamingStrategy.CamelCase);

            var response = await HttpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <PresenceBatchResponse>());
        }