コード例 #1
0
        private async Task <Result <InboxContainer> > GetDirectInbox(string maxId = null, bool pending = false)
        {
            try
            {
                var directInboxUri =
                    pending ? UriCreator.GetPendingInboxUri(maxId) : UriCreator.GetDirectInboxUri(maxId);
                var response = await _httpClient.GetAsync(directInboxUri);

                var json = await response.Content.ReadAsStringAsync();

                DebugLogger.LogResponse(response);

                if (response.StatusCode != HttpStatusCode.Ok)
                {
                    return(Result <InboxContainer> .Fail(json, response.ReasonPhrase));
                }
                var inbox = JsonConvert.DeserializeObject <InboxContainer>(json);
                return(Result <InboxContainer> .Success(inbox));
            }
            catch (Exception exception)
            {
                DebugLogger.LogException(exception);
                return(Result <InboxContainer> .Except(exception));
            }
        }