Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a4414ad2c | ||
|
|
75288e625a | ||
|
|
f5e33d3a2f | ||
|
|
c6c4b7ebc8 | ||
|
|
b1d4c35f11 | ||
|
|
89e7ce8449 | ||
|
|
ac20e2e1d4 |
49
src/ClientContacts/ClientContactsApi.cs
Normal file
49
src/ClientContacts/ClientContactsApi.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.ClientContacts
|
||||||
|
{
|
||||||
|
public class ClientContactsApi : IClientContactsApi
|
||||||
|
{
|
||||||
|
private readonly IBaseApi<ClientContactsResponse, ClientContact> _baseApi;
|
||||||
|
|
||||||
|
public ClientContactsApi(IBaseApi<ClientContactsResponse, ClientContact> baseApi)
|
||||||
|
{
|
||||||
|
_baseApi = baseApi;
|
||||||
|
_baseApi.ResourceUri = "clientcontacts";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<ClientContact>> GetClientContacts()
|
||||||
|
{
|
||||||
|
return (await _baseApi.GetAll()).ClientContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<ClientContact> GetClientContact(int clientContactId)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Get(clientContactId)).ClientContacts.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<ClientContact> CreateClientContact(ClientContact clientContact)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Create(clientContact)).ClientContacts.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteClientContact(int clientContactId)
|
||||||
|
{
|
||||||
|
await _baseApi.Delete(clientContactId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateClientContact(ClientContact clientContact, int clientContactId)
|
||||||
|
{
|
||||||
|
await _baseApi.Update(clientContact, clientContactId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/ClientContacts/IClientContactsApi.cs
Normal file
41
src/ClientContacts/IClientContactsApi.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts.Models;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.ClientContacts
|
||||||
|
{
|
||||||
|
public interface IClientContactsApi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Receive all existing client contacts
|
||||||
|
/// </summary>
|
||||||
|
Task<IEnumerable<ClientContact>> GetClientContacts();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an existing client contact by id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientContactId">id of the contact</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ClientContact> GetClientContact(int clientContactId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new client contact
|
||||||
|
/// </summary>
|
||||||
|
Task<ClientContact> CreateClientContact(ClientContact clientContact);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a client contact
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientContactId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task DeleteClientContact(int clientContactId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an existing client contact
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientContact"></param>
|
||||||
|
/// <param name="clientContactId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateClientContact(ClientContact clientContact, int clientContactId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Novaloop.PaymoApi.ClientContacts.Models;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts
|
|
||||||
{
|
|
||||||
public interface IPaymoClientContactsApi
|
|
||||||
{
|
|
||||||
Task<IEnumerable<PaymoClientContact>> GetClientContacts();
|
|
||||||
Task<PaymoClientContact> GetClientContact(int contactId);
|
|
||||||
Task<PaymoClientContact> CreateClientContact(PaymoClientContact clientContact);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deleta a client contact
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clientContactId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task DeleteClientContact(int clientContactId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts.Models
|
namespace Novaloop.PaymoApi.ClientContacts.Models
|
||||||
{
|
{
|
||||||
public class PaymoClientContact : BasePaymoModel
|
public class ClientContact : BaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("client_id")]
|
[JsonProperty("client_id")]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
11
src/ClientContacts/Models/ClientContactsResponse.cs
Normal file
11
src/ClientContacts/Models/ClientContactsResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.ClientContacts.Models
|
||||||
|
{
|
||||||
|
public class ClientContactsResponse
|
||||||
|
{
|
||||||
|
[JsonProperty("clientcontacts")]
|
||||||
|
public IEnumerable<ClientContact> ClientContacts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts.Models
|
|
||||||
{
|
|
||||||
public class GetClientContactsResponse
|
|
||||||
{
|
|
||||||
public IEnumerable<PaymoClientContact> ClientContacts { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Novaloop.PaymoApi.ClientContacts.Models;
|
|
||||||
using Novaloop.PaymoApi.Extensions;
|
|
||||||
using Novaloop.PaymoApi.Shared;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts
|
|
||||||
{
|
|
||||||
public class PaymoClientContactsApi : IPaymoClientContactsApi
|
|
||||||
{
|
|
||||||
private readonly PaymoApiOptions _options;
|
|
||||||
private readonly HttpClient _client;
|
|
||||||
private const string ResourceUri = "clientcontacts";
|
|
||||||
|
|
||||||
public PaymoClientContactsApi(PaymoApiClient paymoApiClient, IOptions<PaymoApiOptions> options)
|
|
||||||
{
|
|
||||||
_options = options.Value;
|
|
||||||
_client = paymoApiClient.Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Receive all existing client contacts
|
|
||||||
/// </summary>
|
|
||||||
public async Task<IEnumerable<PaymoClientContact>> GetClientContacts()
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientContactsResponse>()).ClientContacts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve an existing client contact by id
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clientContactId">id of the contact</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<PaymoClientContact> GetClientContact(int clientContactId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}/{clientContactId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientContactsResponse>()).ClientContacts.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new client contact
|
|
||||||
/// </summary>
|
|
||||||
public async Task<PaymoClientContact> CreateClientContact(PaymoClientContact clientContact)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.PostAsJsonAsync($"api/{ResourceUri}", clientContact);
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientContactsResponse>()).ClientContacts.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deleta a client contact
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clientContactId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task DeleteClientContact(int clientContactId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.DeleteAsync($"api/{ResourceUri}/{clientContactId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
49
src/Clients/ClientsApi.cs
Normal file
49
src/Clients/ClientsApi.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Clients
|
||||||
|
{
|
||||||
|
public class ClientsApi : IClientsApi
|
||||||
|
{
|
||||||
|
private readonly IBaseApi<ClientsResponse, Client> _baseApi;
|
||||||
|
|
||||||
|
public ClientsApi(IBaseApi<ClientsResponse, Client> baseApi)
|
||||||
|
{
|
||||||
|
_baseApi = baseApi;
|
||||||
|
_baseApi.ResourceUri = "clients";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<Client>> GetClients()
|
||||||
|
{
|
||||||
|
return (await _baseApi.GetAll()).Clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<Client> GetClient(int clientId)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Get(clientId)).Clients.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<Client> CreateClient(Client client)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Create(client)).Clients.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteClient(int clientId)
|
||||||
|
{
|
||||||
|
await _baseApi.Delete(clientId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateClient(Client client, int clientId)
|
||||||
|
{
|
||||||
|
await _baseApi.Update(client, clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/Clients/IClientsApi.cs
Normal file
41
src/Clients/IClientsApi.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Clients
|
||||||
|
{
|
||||||
|
public interface IClientsApi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Receive all existing clients
|
||||||
|
/// </summary>
|
||||||
|
Task<IEnumerable<Client>> GetClients();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an existing client by id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientId">id of the contact</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<Client> GetClient(int clientId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new client
|
||||||
|
/// </summary>
|
||||||
|
Task<Client> CreateClient(Client client);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task DeleteClient(int clientId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an existing client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="clientId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateClient(Client client, int clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Novaloop.PaymoApi.Clients.Models;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients
|
|
||||||
{
|
|
||||||
public interface IPaymoClientsApi
|
|
||||||
{
|
|
||||||
Task<IEnumerable<PaymoClient>> GetClients();
|
|
||||||
Task<PaymoClient> GetClient(int clientId);
|
|
||||||
Task<PaymoClient> CreateClient(PaymoClient client);
|
|
||||||
Task DeleteClient(int clientId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients.Models
|
namespace Novaloop.PaymoApi.Clients.Models
|
||||||
{
|
{
|
||||||
public class PaymoClient : BasePaymoModel
|
public class Client : BaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -42,7 +42,7 @@ namespace Novaloop.PaymoApi.Clients.Models
|
|||||||
public string FiscalInformation { get; set; }
|
public string FiscalInformation { get; set; }
|
||||||
|
|
||||||
[JsonProperty("active")]
|
[JsonProperty("active")]
|
||||||
public bool Active { get; set; }
|
public bool Active { get; set; } = true;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
11
src/Clients/Models/ClientsResponse.cs
Normal file
11
src/Clients/Models/ClientsResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Clients.Models
|
||||||
|
{
|
||||||
|
public class ClientsResponse
|
||||||
|
{
|
||||||
|
[JsonProperty("clients")]
|
||||||
|
public IEnumerable<Client> Clients { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients.Models
|
|
||||||
{
|
|
||||||
public class GetClientsResponse
|
|
||||||
{
|
|
||||||
public IEnumerable<PaymoClient> Clients { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Novaloop.PaymoApi.Clients.Models;
|
|
||||||
using Novaloop.PaymoApi.Extensions;
|
|
||||||
using Novaloop.PaymoApi.Shared;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients
|
|
||||||
{
|
|
||||||
public class PaymoClientsApi : IPaymoClientsApi
|
|
||||||
{
|
|
||||||
private readonly PaymoApiOptions _options;
|
|
||||||
private readonly HttpClient _client;
|
|
||||||
private const string ResourceUri = "clients";
|
|
||||||
|
|
||||||
public PaymoClientsApi(PaymoApiClient paymoApiClient, IOptions<PaymoApiOptions> options)
|
|
||||||
{
|
|
||||||
_options = options.Value;
|
|
||||||
_client = paymoApiClient.Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Receive all existing clients
|
|
||||||
/// </summary>
|
|
||||||
public async Task<IEnumerable<PaymoClient>> GetClients()
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientsResponse>()).Clients;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve an existing client by id
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clientId">id of the contact</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<PaymoClient> GetClient(int clientId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}/{clientId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientsResponse>()).Clients.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new client
|
|
||||||
/// </summary>
|
|
||||||
public async Task<PaymoClient> CreateClient(PaymoClient client)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.PostAsJsonAsync($"api/{ResourceUri}", client);
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetClientsResponse>()).Clients.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete a client
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clientId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task DeleteClient(int clientId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.DeleteAsync($"api/{ResourceUri}/{clientId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,9 @@ using System;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Exceptions
|
namespace Novaloop.PaymoApi.Exceptions
|
||||||
{
|
{
|
||||||
public class PaymoApiException : Exception
|
public class ApiException : Exception
|
||||||
{
|
{
|
||||||
public PaymoApiException(int statusCode, string message) : base($"[{statusCode}]: {message})")
|
public ApiException(int statusCode, string message) : base($"[{statusCode}]: {message})")
|
||||||
{
|
{
|
||||||
StatusCode = statusCode;
|
StatusCode = statusCode;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Novaloop.PaymoApi.Extensions
|
namespace Novaloop.PaymoApi.Extensions
|
||||||
{
|
{
|
||||||
public class PaymoApiOptions
|
public class ApiOptions
|
||||||
{
|
{
|
||||||
public string BaseUrl { get; set; } = "https://app.paymoapp.com/";
|
public string BaseUrl { get; set; } = "https://app.paymoapp.com/";
|
||||||
public string ApiToken { get; set; }
|
public string ApiToken { get; set; }
|
||||||
@@ -10,7 +10,7 @@ namespace Novaloop.PaymoApi.Extensions
|
|||||||
{
|
{
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
throw new PaymoApiException((int) response.StatusCode, await response.Content.ReadAsStringAsync());
|
throw new ApiException((int) response.StatusCode, await response.Content.ReadAsStringAsync());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,35 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Novaloop.PaymoApi.ClientContacts;
|
using Novaloop.PaymoApi.ClientContacts;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts.Models;
|
||||||
using Novaloop.PaymoApi.Clients;
|
using Novaloop.PaymoApi.Clients;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
using Novaloop.PaymoApi.Shared;
|
using Novaloop.PaymoApi.Shared;
|
||||||
using Novaloop.PaymoApi.Tasks;
|
using Novaloop.PaymoApi.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Tasks.Models;
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Extensions
|
namespace Novaloop.PaymoApi.Extensions
|
||||||
{
|
{
|
||||||
public static class PaymoApiExtensions
|
public static class PaymoApiExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddPaymoApi(this IServiceCollection services, Action<PaymoApiOptions> options)
|
public static IServiceCollection AddPaymoApi(this IServiceCollection services, Action<ApiOptions> options)
|
||||||
{
|
{
|
||||||
services.Configure(options);
|
services.Configure(options);
|
||||||
var resolvedOptions = (IOptions<PaymoApiOptions>) services.BuildServiceProvider().GetService(typeof(IOptions<PaymoApiOptions>));
|
var resolvedOptions = (IOptions<ApiOptions>) services.BuildServiceProvider().GetService(typeof(IOptions<ApiOptions>));
|
||||||
services.AddHttpClient<PaymoApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); });
|
services.AddHttpClient<ApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); });
|
||||||
services.AddTransient<IPaymoTasksApi, PaymoTasksApi>();
|
|
||||||
services.AddTransient<IPaymoClientContactsApi, PaymoClientContactsApi>();
|
// ClientContacts
|
||||||
services.AddTransient<IPaymoClientsApi, PaymoClientsApi>();
|
services.AddTransient<IBaseApi<ClientContactsResponse, ClientContact>, BaseApi<ClientContactsResponse, ClientContact>>();
|
||||||
|
services.AddTransient<IClientsApi, ClientsApi>();
|
||||||
|
|
||||||
|
// Tasks
|
||||||
|
services.AddTransient<IBaseApi<TasksResponse, Task>, BaseApi<TasksResponse, Task>>();
|
||||||
|
services.AddTransient<ITasksApi, TasksApi>();
|
||||||
|
|
||||||
|
// Contacts
|
||||||
|
services.AddTransient<IBaseApi<ClientsResponse, Client>, BaseApi<ClientsResponse, Client>>();
|
||||||
|
services.AddTransient<IClientContactsApi, ClientContactsApi>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<PackageId>Novaloop.PaymoApi</PackageId>
|
<PackageId>Novaloop.PaymoApi</PackageId>
|
||||||
<title>Access your paymo instance for asp.net core</title>
|
<title>Access your paymo instance for asp.net core</title>
|
||||||
<PackageTags>api;paymo;asp.net core;</PackageTags>
|
<PackageTags>api;paymo;asp.net core;</PackageTags>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.1.5</Version>
|
||||||
<Authors>Matthias Langhard</Authors>
|
<Authors>Matthias Langhard</Authors>
|
||||||
<Company>Novaloop AG</Company>
|
<Company>Novaloop AG</Company>
|
||||||
<PackageProjectUrl>https://gitlab.com/novaloop-oss/novaloop.paymoapi</PackageProjectUrl>
|
<PackageProjectUrl>https://gitlab.com/novaloop-oss/novaloop.paymoapi</PackageProjectUrl>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ using System.Net.Http;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class PaymoApiClient : IPaymoApiClient
|
public class ApiClient : IApiClient
|
||||||
{
|
{
|
||||||
public PaymoApiClient(HttpClient client)
|
public ApiClient(HttpClient client)
|
||||||
{
|
{
|
||||||
Client = client;
|
Client = client;
|
||||||
}
|
}
|
||||||
80
src/Shared/BaseApi.cs
Normal file
80
src/Shared/BaseApi.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Novaloop.PaymoApi.Extensions;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Shared
|
||||||
|
{
|
||||||
|
public class BaseApi<TReturnType, TCreatType> : IBaseApi<TReturnType, TCreatType>
|
||||||
|
{
|
||||||
|
public string ResourceUri { get; set; }
|
||||||
|
private readonly ApiOptions _options;
|
||||||
|
private readonly HttpClient _client;
|
||||||
|
|
||||||
|
public BaseApi(ApiClient apiClient, IOptions<ApiOptions> options)
|
||||||
|
{
|
||||||
|
_options = options.Value;
|
||||||
|
_client = apiClient.Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Receive all entities
|
||||||
|
/// </summary>
|
||||||
|
public async Task<TReturnType> GetAll()
|
||||||
|
{
|
||||||
|
_client.SetApiKeyHeader(_options.ApiToken);
|
||||||
|
var response = await _client.GetAsync($"api/{ResourceUri}");
|
||||||
|
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
||||||
|
return await response.Content.ReadAsAsync<TReturnType>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an existing entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">id of the entity</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<TReturnType> Get(int entityId)
|
||||||
|
{
|
||||||
|
_client.SetApiKeyHeader(_options.ApiToken);
|
||||||
|
var response = await _client.GetAsync($"api/{ResourceUri}/{entityId}");
|
||||||
|
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
||||||
|
return await response.Content.ReadAsAsync<TReturnType>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new entity
|
||||||
|
/// </summary>
|
||||||
|
public async Task<TReturnType> Create(TCreatType entity)
|
||||||
|
{
|
||||||
|
_client.SetApiKeyHeader(_options.ApiToken);
|
||||||
|
var response = await _client.PostAsJsonAsync($"api/{ResourceUri}", entity);
|
||||||
|
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
||||||
|
return await response.Content.ReadAsAsync<TReturnType>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete an entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">id of the entity</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task Delete(int entityId)
|
||||||
|
{
|
||||||
|
_client.SetApiKeyHeader(_options.ApiToken);
|
||||||
|
var response = await _client.DeleteAsync($"api/{ResourceUri}/{entityId}");
|
||||||
|
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">entity information to update the entity with</param>
|
||||||
|
/// <param name="id">id of the entity to update</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task Update(TCreatType entity, int id)
|
||||||
|
{
|
||||||
|
_client.SetApiKeyHeader(_options.ApiToken);
|
||||||
|
var response = await _client.PutAsJsonAsync($"api/{ResourceUri}/{id}", entity);
|
||||||
|
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class BasePaymoModel
|
public class BaseModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public interface IPaymoApiClient
|
public interface IApiClient
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
41
src/Shared/IBaseApi.cs
Normal file
41
src/Shared/IBaseApi.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Shared
|
||||||
|
{
|
||||||
|
public interface IBaseApi<TReturnType, TCreatType>
|
||||||
|
{
|
||||||
|
string ResourceUri { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Receive all entities
|
||||||
|
/// </summary>
|
||||||
|
Task<TReturnType> GetAll();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an existing entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">id of the entity</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TReturnType> Get(int entityId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new entity
|
||||||
|
/// </summary>
|
||||||
|
Task<TReturnType> Create( TCreatType entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete an entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">id of the entity</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task Delete(int entityId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">entity information to update the entity with</param>
|
||||||
|
/// <param name="id">id of the entity to update</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task Update( TCreatType entity, int id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Novaloop.PaymoApi.Tasks.Models;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks
|
|
||||||
{
|
|
||||||
public interface IPaymoTasksApi
|
|
||||||
{
|
|
||||||
Task<IEnumerable<PaymoTask>> GetTasks();
|
|
||||||
Task<PaymoTask> GetTask(int taskId);
|
|
||||||
Task<PaymoTask> CreateTask(PaymoTask task);
|
|
||||||
Task DeleteTask(int taskId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
40
src/Tasks/ITasksApi.cs
Normal file
40
src/Tasks/ITasksApi.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tasks
|
||||||
|
{
|
||||||
|
public interface ITasksApi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Receive all existing tasks
|
||||||
|
/// </summary>
|
||||||
|
Task<IEnumerable<Novaloop.PaymoApi.Tasks.Models.Task>> GetTasks();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an existing Task by id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="taskId">id of the task</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<Novaloop.PaymoApi.Tasks.Models.Task> GetTask(int taskId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new Task
|
||||||
|
/// </summary>
|
||||||
|
Task<Novaloop.PaymoApi.Tasks.Models.Task> CreateTask(Novaloop.PaymoApi.Tasks.Models.Task task);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a task
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="taskId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task DeleteTask(int taskId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an existing task
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task"></param>
|
||||||
|
/// <param name="taskId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateTask(Novaloop.PaymoApi.Tasks.Models.Task task, int taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks.Models
|
|
||||||
{
|
|
||||||
public class GetTasksResponse
|
|
||||||
{
|
|
||||||
public IEnumerable<PaymoTask> Tasks { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks.Models
|
namespace Novaloop.PaymoApi.Tasks.Models
|
||||||
{
|
{
|
||||||
public class PaymoTask : BasePaymoModel
|
public class Task : BaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
11
src/Tasks/Models/TasksResponse.cs
Normal file
11
src/Tasks/Models/TasksResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tasks.Models
|
||||||
|
{
|
||||||
|
public class TasksResponse
|
||||||
|
{
|
||||||
|
[JsonProperty("tasks")]
|
||||||
|
public IEnumerable<Task> Tasks { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Novaloop.PaymoApi.Extensions;
|
|
||||||
using Novaloop.PaymoApi.Shared;
|
|
||||||
using Novaloop.PaymoApi.Tasks.Models;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks
|
|
||||||
{
|
|
||||||
public class PaymoTasksApi : IPaymoTasksApi
|
|
||||||
{
|
|
||||||
private readonly PaymoApiOptions _options;
|
|
||||||
private readonly HttpClient _client;
|
|
||||||
private const string ResourceUri = "tasks";
|
|
||||||
|
|
||||||
|
|
||||||
public PaymoTasksApi(PaymoApiClient paymoApiClient, IOptions<PaymoApiOptions> options)
|
|
||||||
{
|
|
||||||
_options = options.Value;
|
|
||||||
_client = paymoApiClient.Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Receive all existing tasks
|
|
||||||
/// </summary>
|
|
||||||
public async Task<IEnumerable<PaymoTask>> GetTasks()
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetTasksResponse>()).Tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve an existing Task by id
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="taskId">id of the task</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<PaymoTask> GetTask(int taskId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.GetAsync($"api/{ResourceUri}/{taskId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetTasksResponse>()).Tasks.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new Task
|
|
||||||
/// </summary>
|
|
||||||
public async Task<PaymoTask> CreateTask(PaymoTask task)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.PostAsJsonAsync($"api/{ResourceUri}", task);
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
return (await response.Content.ReadAsAsync<GetTasksResponse>()).Tasks.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete a task
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="taskId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task DeleteTask(int taskId)
|
|
||||||
{
|
|
||||||
_client.SetApiKeyHeader(_options.ApiToken);
|
|
||||||
var response = await _client.DeleteAsync($"api/{ResourceUri}/{taskId}");
|
|
||||||
await response.ThrowExceptionWithDetailsIfUnsuccessful();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
53
src/Tasks/TasksApi.cs
Normal file
53
src/Tasks/TasksApi.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
using Novaloop.PaymoApi.Tasks.Models;
|
||||||
|
using Task = System.Threading.Tasks.Task;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tasks
|
||||||
|
{
|
||||||
|
public class TasksApi : ITasksApi
|
||||||
|
{
|
||||||
|
private readonly IBaseApi<TasksResponse, Novaloop.PaymoApi.Tasks.Models.Task> _baseApi;
|
||||||
|
|
||||||
|
public TasksApi(IBaseApi<TasksResponse, Novaloop.PaymoApi.Tasks.Models.Task> baseApi)
|
||||||
|
{
|
||||||
|
_baseApi = baseApi;
|
||||||
|
_baseApi.ResourceUri = "tasks";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<Novaloop.PaymoApi.Tasks.Models.Task>> GetTasks()
|
||||||
|
{
|
||||||
|
return (await _baseApi.GetAll()).Tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<Novaloop.PaymoApi.Tasks.Models.Task> GetTask(int taskId)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Get(taskId)).Tasks.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<Novaloop.PaymoApi.Tasks.Models.Task> CreateTask(Novaloop.PaymoApi.Tasks.Models.Task task)
|
||||||
|
{
|
||||||
|
return (await _baseApi.Create(task)).Tasks.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteTask(int taskId)
|
||||||
|
{
|
||||||
|
await _baseApi.Delete(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateTask(Novaloop.PaymoApi.Tasks.Models.Task task, int taskId)
|
||||||
|
{
|
||||||
|
await _baseApi.Update(task, taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
91
tests/ClientContactsApiTests.cs
Normal file
91
tests/ClientContactsApiTests.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts.Models;
|
||||||
|
using Novaloop.PaymoApi.Clients;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tests
|
||||||
|
{
|
||||||
|
public class ClientContactsApiTests
|
||||||
|
{
|
||||||
|
private readonly ClientContactsApi _clientContactsApi;
|
||||||
|
private readonly ClientsApi _clientsApi;
|
||||||
|
|
||||||
|
private readonly ClientContact _testClientContact = new ClientContact
|
||||||
|
{
|
||||||
|
Name = "Testclient",
|
||||||
|
Email = "test@client.de"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public ClientContactsApiTests()
|
||||||
|
{
|
||||||
|
_clientContactsApi = new ClientContactsApi(new BaseApi<ClientContactsResponse, ClientContact>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
|
_clientsApi = new ClientsApi(new BaseApi<ClientsResponse, Client>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetClientContacts()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotEmpty(clientContacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetClientContact()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
||||||
|
var clientContact = await _clientContactsApi.GetClientContact(clientContacts.First().Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotNull(clientContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void CreateClientContact()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var existingClientContact = (await _clientsApi.GetClients()).First();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testClientContact.ClientId = existingClientContact.Id;
|
||||||
|
var createdClientContact = await _clientContactsApi.CreateClientContact(_testClientContact);
|
||||||
|
var clientContact = await _clientContactsApi.GetClientContact(createdClientContact.Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(_testClientContact.Name, clientContact.Name);
|
||||||
|
Assert.Equal(_testClientContact.Email, clientContact.Email);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
await _clientContactsApi.DeleteClientContact(createdClientContact.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void DeleteClientContact()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var existingClientContact = (await _clientsApi.GetClients()).First();
|
||||||
|
_testClientContact.ClientId = existingClientContact.Id;
|
||||||
|
var createdClientContact = await _clientContactsApi.CreateClientContact(_testClientContact);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _clientContactsApi.DeleteClientContact(createdClientContact.Id);
|
||||||
|
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Empty(clientContacts.Where(c => c.Id == createdClientContact.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
98
tests/ClientsApiTests.cs
Normal file
98
tests/ClientsApiTests.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Novaloop.PaymoApi.Clients;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tests
|
||||||
|
{
|
||||||
|
public class ClientsApiTests
|
||||||
|
{
|
||||||
|
private readonly ClientsApi _clientsApi;
|
||||||
|
|
||||||
|
private readonly Client _testClient = new Client
|
||||||
|
{
|
||||||
|
Name = "Testclient",
|
||||||
|
Email = "test@client.de"
|
||||||
|
};
|
||||||
|
|
||||||
|
public ClientsApiTests()
|
||||||
|
{
|
||||||
|
_clientsApi = new ClientsApi(new BaseApi<ClientsResponse, Client>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetClients()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var clients = (await _clientsApi.GetClients()).ToList();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotEmpty(clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetClient()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var clients = (await _clientsApi.GetClients()).ToList();
|
||||||
|
var client = await _clientsApi.GetClient(clients.First().Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotNull(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void CreateClient()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var createdClient = await _clientsApi.CreateClient(_testClient);
|
||||||
|
var client = await _clientsApi.GetClient(createdClient.Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(_testClient.Name, client.Name);
|
||||||
|
Assert.Equal(_testClient.Email, client.Email);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
await _clientsApi.DeleteClient(createdClient.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void DeleteClient()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var createdClient = await _clientsApi.CreateClient(_testClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _clientsApi.DeleteClient(createdClient.Id);
|
||||||
|
var clients = (await _clientsApi.GetClients()).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Empty(clients.Where(c => c.Id == createdClient.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void UpdateClient()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var createdClient = await _clientsApi.CreateClient(_testClient);
|
||||||
|
var clientUpdateInfo = new Client {Name = "Updated"};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _clientsApi.UpdateClient(clientUpdateInfo, createdClient.Id);
|
||||||
|
var updatedClient = await _clientsApi.GetClient(createdClient.Id);
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(clientUpdateInfo.Name, updatedClient.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,12 +9,12 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
{
|
{
|
||||||
public static class DependencyFactory
|
public static class DependencyFactory
|
||||||
{
|
{
|
||||||
public static PaymoApiClient GeneratePaymoApiClient()
|
public static ApiClient GeneratePaymoApiClient()
|
||||||
{
|
{
|
||||||
return new PaymoApiClient(new HttpClient {BaseAddress = new Uri("https://app.paymoapp.com/")});
|
return new ApiClient(new HttpClient {BaseAddress = new Uri("https://app.paymoapp.com/")});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IOptions<PaymoApiOptions> GenerateOptions()
|
public static IOptions<ApiOptions> GenerateOptions()
|
||||||
{
|
{
|
||||||
var paymoToken = new ConfigurationBuilder()
|
var paymoToken = new ConfigurationBuilder()
|
||||||
.SetBasePath(AppContext.BaseDirectory)
|
.SetBasePath(AppContext.BaseDirectory)
|
||||||
@@ -28,7 +28,7 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
throw new ArgumentException("Please set the environment variable 'PAYMOAPIINTEGRATIONTESTS__PAYMOTESTPROJECTTOKEN' with the token of your paymo test-project. Look inside Bitwarden if you work @ Novaloop.");
|
throw new ArgumentException("Please set the environment variable 'PAYMOAPIINTEGRATIONTESTS__PAYMOTESTPROJECTTOKEN' with the token of your paymo test-project. Look inside Bitwarden if you work @ Novaloop.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Options.Create(new PaymoApiOptions {ApiToken = paymoToken});
|
return Options.Create(new ApiOptions {ApiToken = paymoToken});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Novaloop.PaymoApi.ClientContacts;
|
|
||||||
using Novaloop.PaymoApi.ClientContacts.Models;
|
|
||||||
using Novaloop.PaymoApi.Clients;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tests
|
|
||||||
{
|
|
||||||
public class PaymoClientContactsApiTests
|
|
||||||
{
|
|
||||||
private readonly PaymoClientContactsApi _paymoClientContactsApi;
|
|
||||||
private readonly PaymoClientsApi _paymoClientsApi;
|
|
||||||
|
|
||||||
private readonly PaymoClientContact _testClientContact = new PaymoClientContact
|
|
||||||
{
|
|
||||||
Name = "Testclient",
|
|
||||||
Email = "test@client.de"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public PaymoClientContactsApiTests()
|
|
||||||
{
|
|
||||||
_paymoClientContactsApi = new PaymoClientContactsApi(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions());
|
|
||||||
_paymoClientsApi = new PaymoClientsApi(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetClientContacts()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(clientContacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetClientContact()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
|
||||||
var clientContact = await _paymoClientContactsApi.GetClientContact(clientContacts.First().Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotNull(clientContact);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void CreateClientContact()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var existingClientContact = (await _paymoClientsApi.GetClients()).First();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
_testClientContact.ClientId = existingClientContact.Id;
|
|
||||||
var createdClientContact = await _paymoClientContactsApi.CreateClientContact(_testClientContact);
|
|
||||||
var clientContact = await _paymoClientContactsApi.GetClientContact(createdClientContact.Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(_testClientContact.Name, clientContact.Name);
|
|
||||||
Assert.Equal(_testClientContact.Email, clientContact.Email);
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
await _paymoClientContactsApi.DeleteClientContact(createdClientContact.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void DeleteClientContact()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var existingClientContact = (await _paymoClientsApi.GetClients()).First();
|
|
||||||
_testClientContact.ClientId = existingClientContact.Id;
|
|
||||||
var createdClientContact = await _paymoClientContactsApi.CreateClientContact(_testClientContact);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await _paymoClientContactsApi.DeleteClientContact(createdClientContact.Id);
|
|
||||||
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(clientContacts.Where(c => c.Id == createdClientContact.Id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Novaloop.PaymoApi.Clients;
|
|
||||||
using Novaloop.PaymoApi.Clients.Models;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tests
|
|
||||||
{
|
|
||||||
public class PaymoClientsApiTests
|
|
||||||
{
|
|
||||||
private readonly PaymoClientsApi _paymoClientsApi;
|
|
||||||
|
|
||||||
private readonly PaymoClient _testClient = new PaymoClient
|
|
||||||
{
|
|
||||||
Name = "Testclient",
|
|
||||||
Email = "test@client.de"
|
|
||||||
};
|
|
||||||
|
|
||||||
public PaymoClientsApiTests()
|
|
||||||
{
|
|
||||||
_paymoClientsApi = new PaymoClientsApi(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetClients()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var clients = (await _paymoClientsApi.GetClients()).ToList();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(clients);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetClient()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var clients = (await _paymoClientsApi.GetClients()).ToList();
|
|
||||||
var client = await _paymoClientsApi.GetClient(clients.First().Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotNull(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void CreateClient()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var createdClient = await _paymoClientsApi.CreateClient(_testClient);
|
|
||||||
var client = await _paymoClientsApi.GetClient(createdClient.Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(_testClient.Name, client.Name);
|
|
||||||
Assert.Equal(_testClient.Email, client.Email);
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
await _paymoClientsApi.DeleteClient(createdClient.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void DeleteClient()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var createdClient = await _paymoClientsApi.CreateClient(_testClient);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await _paymoClientsApi.DeleteClient(createdClient.Id);
|
|
||||||
var clients = (await _paymoClientsApi.GetClients()).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(clients.Where(c => c.Id == createdClient.Id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Novaloop.PaymoApi.Tasks;
|
|
||||||
using Novaloop.PaymoApi.Tasks.Models;
|
|
||||||
using Xunit;
|
|
||||||
using Xunit.Abstractions;
|
|
||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tests
|
|
||||||
{
|
|
||||||
public class PaymoTasksApiTests
|
|
||||||
{
|
|
||||||
private readonly ITestOutputHelper _testOutputHelper;
|
|
||||||
private readonly PaymoTasksApi _paymoTasksApi;
|
|
||||||
private readonly PaymoTask _testTask;
|
|
||||||
|
|
||||||
public PaymoTasksApiTests(ITestOutputHelper testOutputHelper)
|
|
||||||
{
|
|
||||||
_testOutputHelper = testOutputHelper;
|
|
||||||
_paymoTasksApi = new PaymoTasksApi(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions());
|
|
||||||
_testTask = new PaymoTask
|
|
||||||
{
|
|
||||||
Name = "Testtask",
|
|
||||||
Description = "Just a little task"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetTasks()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(tasks);
|
|
||||||
_testOutputHelper.WriteLine(string.Join(",", tasks));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetTask()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
|
||||||
var task = await _paymoTasksApi.GetTask(tasks.First().Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotNull(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void CreateTask()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var existingTaskListId = (await _paymoTasksApi.GetTasks()).First().TasklistId;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
_testTask.TasklistId = existingTaskListId;
|
|
||||||
var createdTask = await _paymoTasksApi.CreateTask(_testTask);
|
|
||||||
var task = await _paymoTasksApi.GetTask(createdTask.Id);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(_testTask.Name, task.Name);
|
|
||||||
Assert.Equal(_testTask.Description, task.Description);
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
await _paymoTasksApi.DeleteTask(createdTask.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void DeleteTask()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var existingTaskListId = (await _paymoTasksApi.GetTasks()).First().TasklistId;
|
|
||||||
_testTask.TasklistId = existingTaskListId;
|
|
||||||
var createdTask = await _paymoTasksApi.CreateTask(_testTask);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await _paymoTasksApi.DeleteTask(createdTask.Id);
|
|
||||||
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(tasks.Where(c => c.Id == createdTask.Id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
109
tests/TasksApiTests.cs
Normal file
109
tests/TasksApiTests.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
using Novaloop.PaymoApi.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Tasks.Models;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Tests
|
||||||
|
{
|
||||||
|
public class TasksApiTests
|
||||||
|
{
|
||||||
|
private readonly ITestOutputHelper _testOutputHelper;
|
||||||
|
private readonly TasksApi _tasksApi;
|
||||||
|
private readonly Task _testTask;
|
||||||
|
|
||||||
|
public TasksApiTests(ITestOutputHelper testOutputHelper)
|
||||||
|
{
|
||||||
|
_testOutputHelper = testOutputHelper;
|
||||||
|
_tasksApi = new TasksApi(new BaseApi<TasksResponse, Task>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
|
|
||||||
|
_testTask = new Task
|
||||||
|
{
|
||||||
|
Name = "Testtask",
|
||||||
|
Description = "Just a little task"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetTasks()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var tasks = (await _tasksApi.GetTasks()).ToList();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotEmpty(tasks);
|
||||||
|
_testOutputHelper.WriteLine(string.Join(",", tasks));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void GetTask()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var tasks = (await _tasksApi.GetTasks()).ToList();
|
||||||
|
var task = await _tasksApi.GetTask(tasks.First().Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.NotNull(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void CreateTask()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testTask.TasklistId = existingTaskListId;
|
||||||
|
var createdTask = await _tasksApi.CreateTask(_testTask);
|
||||||
|
var task = await _tasksApi.GetTask(createdTask.Id);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(_testTask.Name, task.Name);
|
||||||
|
Assert.Equal(_testTask.Description, task.Description);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
await _tasksApi.DeleteTask(createdTask.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void DeleteTask()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
||||||
|
_testTask.TasklistId = existingTaskListId;
|
||||||
|
var createdTask = await _tasksApi.CreateTask(_testTask);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _tasksApi.DeleteTask(createdTask.Id);
|
||||||
|
var tasks = (await _tasksApi.GetTasks()).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Empty(tasks.Where(c => c.Id == createdTask.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void UpdateTask()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
||||||
|
_testTask.TasklistId = existingTaskListId;
|
||||||
|
var createdTask = await _tasksApi.CreateTask(_testTask);
|
||||||
|
var taskUpdateInfo = new Task {Name = "Updated", TasklistId = _testTask.TasklistId};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await _tasksApi.UpdateTask(taskUpdateInfo, createdTask.Id);
|
||||||
|
var updatedTask = await _tasksApi.GetTask(createdTask.Id);
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(taskUpdateInfo.Name, updatedTask.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user