Пример #1
0
        public async Task <RunCardResult> RunCard(CardId card)
        {
            HttpRequestMessage request() => new HttpRequestMessage(HttpMethod.Post, new Uri($"/api/card/{card}/query", UriKind.Relative));

            var response = await sessionManager.Send(request);

            return(JsonConvert.DeserializeObject <RunCardResult>(response));
        }
Пример #2
0
        public async Task <RunCardResult> RunCard(CardId card)
        {
            HttpRequestMessage request() => new HttpRequestMessage(HttpMethod.Post, new Uri($"/api/card/{card}/query", UriKind.Relative));

            var response = await sessionManager.Send(request);

            try
            {
                return(JsonConvert.DeserializeObject <RunCardResult>(response));
            }
            catch (JsonSerializationException e)
            {
                throw new MetabaseApiException($"Error parsing response for {nameof(RunCardResult)} from:\n{response}", e);
            }
        }
Пример #3
0
        async Task <DashboardCard> AddCardToDashboard(CardId cardId, DashboardId dashboardId)
        {
            var content1 = JObj.Obj(new[] { JObj.Prop("cardId", cardId.Value) });

            HttpRequestMessage request1() =>
            new HttpRequestMessage(HttpMethod.Post, new Uri($"/api/dashboard/{dashboardId}/cards", UriKind.Relative))
            {
                Content = ToJsonContent(content1).HttpContent
            };
            var response = await sessionManager.Send(request1);

            var dashboardCard = JsonConvert.DeserializeObject <DashboardCard>(response);

            return(dashboardCard);
        }
Пример #4
0
        async Task <DashboardCard> AddCardToDashboard(CardId cardId, DashboardId dashboardId)
        {
            var content1 = JObj.Obj(new[] { JObj.Prop("cardId", cardId.Value) });

            HttpRequestMessage request1() =>
            new HttpRequestMessage(HttpMethod.Post, new Uri($"/api/dashboard/{dashboardId}/cards", UriKind.Relative))
            {
                Content = ToJsonContent(content1).HttpContent
            };
            var response = await sessionManager.Send(request1);

            try
            {
                return(JsonConvert.DeserializeObject <DashboardCard>(response));
            }
            catch (JsonSerializationException e)
            {
                throw new MetabaseApiException($"Error parsing response for {nameof(DashboardCard)} from:\n{response}", e);
            }
        }
Пример #5
0
        public async Task DeleteCard(CardId cardId)
        {
            HttpRequestMessage request() => new HttpRequestMessage(HttpMethod.Delete, new Uri("/api/card/" + cardId, UriKind.Relative));

            var response = await sessionManager.Send(request);
        }