From f5b3ff3694d6f099094689f52ad449ef2799c83c Mon Sep 17 00:00:00 2001 From: Matthias Langhard Date: Wed, 9 Dec 2020 19:56:40 +0100 Subject: [PATCH] chore: fixes api base-url --- src/Extensions/PaymoApiOptions.cs | 2 +- src/Novaloop.PaymoApi.csproj | 2 +- src/Tasks/IPaymoTasksApiService.cs | 1 + src/Tasks/Models/CreateTaskRequest.cs | 8 ++++++++ src/Tasks/PaymoTasksApiService.cs | 19 ++++++++++++++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Extensions/PaymoApiOptions.cs b/src/Extensions/PaymoApiOptions.cs index f56d6f0..81f66fe 100644 --- a/src/Extensions/PaymoApiOptions.cs +++ b/src/Extensions/PaymoApiOptions.cs @@ -2,7 +2,7 @@ namespace Novaloop.PaymoApi.Extensions { public class PaymoApiOptions { - public string BaseUrl { get; set; } = "https://app.paymoapp.com/api"; + public string BaseUrl { get; set; } = "https://app.paymoapp.com/"; public string ApiToken { get; set; } } } \ No newline at end of file diff --git a/src/Novaloop.PaymoApi.csproj b/src/Novaloop.PaymoApi.csproj index 3b1c8b5..7060951 100644 --- a/src/Novaloop.PaymoApi.csproj +++ b/src/Novaloop.PaymoApi.csproj @@ -5,7 +5,7 @@ Novaloop.PaymoApi Access your paymo instance for asp.net core api;paymo;asp.net core; - 0.1.0 + 0.1.9 Matthias Langhard Novaloop AG https://gitlab.com/novaloop-oss/novaloop.paymoapi diff --git a/src/Tasks/IPaymoTasksApiService.cs b/src/Tasks/IPaymoTasksApiService.cs index 544cbb1..e86d866 100644 --- a/src/Tasks/IPaymoTasksApiService.cs +++ b/src/Tasks/IPaymoTasksApiService.cs @@ -5,6 +5,7 @@ namespace Novaloop.PaymoApi.Tasks { public interface IPaymoTasksApiService { + Task GetTasks(); Task GetTask(int taskId); Task CreateTask(CreateTaskRequest createTask); } diff --git a/src/Tasks/Models/CreateTaskRequest.cs b/src/Tasks/Models/CreateTaskRequest.cs index e8d8e50..880c501 100644 --- a/src/Tasks/Models/CreateTaskRequest.cs +++ b/src/Tasks/Models/CreateTaskRequest.cs @@ -1,12 +1,20 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Novaloop.PaymoApi.Tasks.Models { public class CreateTaskRequest { + [JsonProperty(PropertyName = "name")] public string Name { get; set; } + + [JsonProperty(PropertyName = "description")] public string Description { get; set; } + + [JsonProperty(PropertyName = "tasklist_id")] public int TasklistId { get; set; } + + [JsonProperty(PropertyName = "users")] public List Users { get; set; } } } \ No newline at end of file diff --git a/src/Tasks/PaymoTasksApiService.cs b/src/Tasks/PaymoTasksApiService.cs index 6509896..6dc4e57 100644 --- a/src/Tasks/PaymoTasksApiService.cs +++ b/src/Tasks/PaymoTasksApiService.cs @@ -19,12 +19,25 @@ namespace Novaloop.PaymoApi.Tasks } /// - /// Get an existing Task + /// Receive all existing tasks /// + public async Task GetTasks() + { + _client.SetApiKeyHeader(_options.ApiToken); + var response = await _client.GetAsync($"api/tasks"); + await response.ThrowExceptionWithDetailsIfUnsuccessful(); + return await response.Content.ReadAsAsync(); + } + + /// + /// Retrieve an existing Task by id + /// + /// id of the task + /// public async Task GetTask(int taskId) { _client.SetApiKeyHeader(_options.ApiToken); - var response = await _client.GetAsync($"/tasks/{taskId}"); + var response = await _client.GetAsync($"api/tasks/{taskId}"); await response.ThrowExceptionWithDetailsIfUnsuccessful(); return await response.Content.ReadAsAsync(); } @@ -36,7 +49,7 @@ namespace Novaloop.PaymoApi.Tasks public async Task CreateTask(CreateTaskRequest createTaskRequest) { _client.SetApiKeyHeader(_options.ApiToken); - var response = await _client.PostAsJsonAsync("/tasks", createTaskRequest); + var response = await _client.PostAsJsonAsync("api/tasks", createTaskRequest); await response.ThrowExceptionWithDetailsIfUnsuccessful(); return await response.Content.ReadAsAsync(); }