chore: re-adding 'Paymo' prefix in front of all classes
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Dynamic;
|
|
||||||
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(ExpandoObject clientContact, int clientContactId)
|
|
||||||
{
|
|
||||||
await _baseApi.Update(clientContact, clientContactId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,24 +5,24 @@ using Novaloop.PaymoApi.ClientContacts.Models;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts
|
namespace Novaloop.PaymoApi.ClientContacts
|
||||||
{
|
{
|
||||||
public interface IClientContactsApi
|
public interface IPaymoClientContactsApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Receive all existing client contacts
|
/// Receive all existing client contacts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<IEnumerable<ClientContact>> GetClientContacts();
|
Task<IEnumerable<PaymoClientContact>> GetClientContacts();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an existing client contact by id
|
/// Retrieve an existing client contact by id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clientContactId">id of the contact</param>
|
/// <param name="clientContactId">id of the contact</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ClientContact> GetClientContact(int clientContactId);
|
Task<PaymoClientContact> GetClientContact(int clientContactId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new client contact
|
/// Create a new client contact
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<ClientContact> CreateClientContact(ClientContact clientContact);
|
Task<PaymoClientContact> CreateClientContact(PaymoClientContact paymoClientContact);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a client contact
|
/// Delete a client contact
|
||||||
@@ -3,7 +3,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts.Models
|
namespace Novaloop.PaymoApi.ClientContacts.Models
|
||||||
{
|
{
|
||||||
public class ClientContact : BaseModel
|
public class PaymoClientContact : PaymoBaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("client_id")]
|
[JsonProperty("client_id")]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
@@ -3,9 +3,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.ClientContacts.Models
|
namespace Novaloop.PaymoApi.ClientContacts.Models
|
||||||
{
|
{
|
||||||
public class ClientContactsResponse
|
public class PaymoClientContactsResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("clientcontacts")]
|
[JsonProperty("clientcontacts")]
|
||||||
public IEnumerable<ClientContact> ClientContacts { get; set; }
|
public IEnumerable<PaymoClientContact> ClientContacts { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
src/ClientContacts/PaymoClientContactsApi.cs
Normal file
50
src/ClientContacts/PaymoClientContactsApi.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.ClientContacts.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.ClientContacts
|
||||||
|
{
|
||||||
|
public class PaymoClientContactsApi : IPaymoClientContactsApi
|
||||||
|
{
|
||||||
|
private readonly IPaymoBaseApi<PaymoClientContactsResponse, PaymoClientContact> _paymoBaseApi;
|
||||||
|
|
||||||
|
public PaymoClientContactsApi(IPaymoBaseApi<PaymoClientContactsResponse, PaymoClientContact> paymoBaseApi)
|
||||||
|
{
|
||||||
|
_paymoBaseApi = paymoBaseApi;
|
||||||
|
_paymoBaseApi.ResourceUri = "clientcontacts";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<PaymoClientContact>> GetClientContacts()
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.GetAll()).ClientContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoClientContact> GetClientContact(int clientContactId)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Get(clientContactId)).ClientContacts.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoClientContact> CreateClientContact(PaymoClientContact paymoClientContact)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Create(paymoClientContact)).ClientContacts.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteClientContact(int clientContactId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Delete(clientContactId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateClientContact(ExpandoObject clientContact, int clientContactId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Update(clientContact, clientContactId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Dynamic;
|
|
||||||
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(ExpandoObject client, int clientId)
|
|
||||||
{
|
|
||||||
await _baseApi.Update(client, clientId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,24 +5,24 @@ using Novaloop.PaymoApi.Clients.Models;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients
|
namespace Novaloop.PaymoApi.Clients
|
||||||
{
|
{
|
||||||
public interface IClientsApi
|
public interface IPaymoClientsApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Receive all existing clients
|
/// Receive all existing clients
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<IEnumerable<Client>> GetClients();
|
Task<IEnumerable<PaymoClient>> GetClients();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an existing client by id
|
/// Retrieve an existing client by id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clientId">id of the contact</param>
|
/// <param name="clientId">id of the contact</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Client> GetClient(int clientId);
|
Task<PaymoClient> GetClient(int clientId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new client
|
/// Create a new client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<Client> CreateClient(Client client);
|
Task<PaymoClient> CreateClient(PaymoClient paymoClient);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a client
|
/// Delete a client
|
||||||
@@ -3,7 +3,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients.Models
|
namespace Novaloop.PaymoApi.Clients.Models
|
||||||
{
|
{
|
||||||
public class Client : BaseModel
|
public class PaymoClient : PaymoBaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -3,9 +3,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Clients.Models
|
namespace Novaloop.PaymoApi.Clients.Models
|
||||||
{
|
{
|
||||||
public class ClientsResponse
|
public class PaymoClientsResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("clients")]
|
[JsonProperty("clients")]
|
||||||
public IEnumerable<Client> Clients { get; set; }
|
public IEnumerable<PaymoClient> Clients { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
src/Clients/PaymoPaymoClientsApi.cs
Normal file
50
src/Clients/PaymoPaymoClientsApi.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Novaloop.PaymoApi.Clients.Models;
|
||||||
|
using Novaloop.PaymoApi.Shared;
|
||||||
|
|
||||||
|
namespace Novaloop.PaymoApi.Clients
|
||||||
|
{
|
||||||
|
public class PaymoPaymoClientsApi : IPaymoClientsApi
|
||||||
|
{
|
||||||
|
private readonly IPaymoBaseApi<PaymoClientsResponse, PaymoClient> _paymoBaseApi;
|
||||||
|
|
||||||
|
public PaymoPaymoClientsApi(IPaymoBaseApi<PaymoClientsResponse, PaymoClient> paymoBaseApi)
|
||||||
|
{
|
||||||
|
_paymoBaseApi = paymoBaseApi;
|
||||||
|
_paymoBaseApi.ResourceUri = "clients";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<PaymoClient>> GetClients()
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.GetAll()).Clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoClient> GetClient(int clientId)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Get(clientId)).Clients.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoClient> CreateClient(PaymoClient paymoClient)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Create(paymoClient)).Clients.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteClient(int clientId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Delete(clientId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateClient(ExpandoObject client, int clientId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Update(client, clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@ using System;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Exceptions
|
namespace Novaloop.PaymoApi.Exceptions
|
||||||
{
|
{
|
||||||
public class ApiException : Exception
|
public class PaymoApiException : Exception
|
||||||
{
|
{
|
||||||
public ApiException(int statusCode, string message) : base($"[{statusCode}]: {message})")
|
public PaymoApiException(int statusCode, string message) : base($"[{statusCode}]: {message})")
|
||||||
{
|
{
|
||||||
StatusCode = statusCode;
|
StatusCode = statusCode;
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ namespace Novaloop.PaymoApi.Extensions
|
|||||||
{
|
{
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
throw new ApiException((int) response.StatusCode, await response.Content.ReadAsStringAsync());
|
throw new PaymoApiException((int) response.StatusCode, await response.Content.ReadAsStringAsync());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,27 +13,27 @@ namespace Novaloop.PaymoApi.Extensions
|
|||||||
{
|
{
|
||||||
public static class PaymoApiExtensions
|
public static class PaymoApiExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddPaymoApi(this IServiceCollection services, Action<ApiOptions> options)
|
public static IServiceCollection AddPaymoApi(this IServiceCollection services, Action<PaymoApiOptions> options)
|
||||||
{
|
{
|
||||||
services.Configure(options);
|
services.Configure(options);
|
||||||
var resolvedOptions = (IOptions<ApiOptions>) services.BuildServiceProvider().GetService(typeof(IOptions<ApiOptions>));
|
var resolvedOptions = (IOptions<PaymoApiOptions>) services.BuildServiceProvider().GetService(typeof(IOptions<PaymoApiOptions>));
|
||||||
services.AddHttpClient<ApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); })
|
services.AddHttpClient<PaymoPaymoIApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); })
|
||||||
.AddHttpMessageHandler(s => s.GetService<LoggingHandler>());
|
.AddHttpMessageHandler(s => s.GetService<PaymoLoggingHandler>());
|
||||||
|
|
||||||
// ClientContacts
|
// ClientContacts
|
||||||
services.AddTransient<IBaseApi<ClientContactsResponse, ClientContact>, BaseApi<ClientContactsResponse, ClientContact>>();
|
services.AddTransient<IPaymoBaseApi<PaymoClientContactsResponse, PaymoClientContact>, PaymoBaseApi<PaymoClientContactsResponse, PaymoClientContact>>();
|
||||||
services.AddTransient<IClientsApi, ClientsApi>();
|
services.AddTransient<IPaymoClientsApi, PaymoPaymoClientsApi>();
|
||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
services.AddTransient<IBaseApi<TasksResponse, Task>, BaseApi<TasksResponse, Task>>();
|
services.AddTransient<IPaymoBaseApi<PaymoTasksResponse, PaymoTask>, PaymoBaseApi<PaymoTasksResponse, PaymoTask>>();
|
||||||
services.AddTransient<ITasksApi, TasksApi>();
|
services.AddTransient<IPaymoTasksApi, PaymoTasksApi>();
|
||||||
|
|
||||||
// Contacts
|
// Contacts
|
||||||
services.AddTransient<IBaseApi<ClientsResponse, Client>, BaseApi<ClientsResponse, Client>>();
|
services.AddTransient<IPaymoBaseApi<PaymoClientsResponse, PaymoClient>, PaymoBaseApi<PaymoClientsResponse, PaymoClient>>();
|
||||||
services.AddTransient<IClientContactsApi, ClientContactsApi>();
|
services.AddTransient<IPaymoClientContactsApi, PaymoClientContactsApi>();
|
||||||
|
|
||||||
// Shared
|
// Shared
|
||||||
services.AddTransient<LoggingHandler>();
|
services.AddTransient<PaymoLoggingHandler>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Novaloop.PaymoApi.Extensions
|
namespace Novaloop.PaymoApi.Extensions
|
||||||
{
|
{
|
||||||
public class ApiOptions
|
public class PaymoApiOptions
|
||||||
{
|
{
|
||||||
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; }
|
||||||
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public interface IBaseApi<TReturnType, TCreatType>
|
public interface IPaymoBaseApi<TReturnType, TCreatType>
|
||||||
{
|
{
|
||||||
string ResourceUri { get; set; }
|
string ResourceUri { get; set; }
|
||||||
|
|
||||||
@@ -9,16 +9,16 @@ using Novaloop.PaymoApi.Extensions;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class BaseApi<TReturnType, TCreatType> : IBaseApi<TReturnType, TCreatType>
|
public class PaymoBaseApi<TReturnType, TCreatType> : IPaymoBaseApi<TReturnType, TCreatType>
|
||||||
{
|
{
|
||||||
public string ResourceUri { get; set; }
|
public string ResourceUri { get; set; }
|
||||||
private readonly ApiOptions _options;
|
private readonly PaymoApiOptions _options;
|
||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
|
|
||||||
public BaseApi(ApiClient apiClient, IOptions<ApiOptions> options)
|
public PaymoBaseApi(PaymoPaymoIApiClient paymoPaymoIApiClient, IOptions<PaymoApiOptions> options)
|
||||||
{
|
{
|
||||||
_options = options.Value;
|
_options = options.Value;
|
||||||
_client = apiClient.Client;
|
_client = paymoPaymoIApiClient.Client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class BaseModel
|
public class PaymoBaseModel
|
||||||
{
|
{
|
||||||
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 IApiClient
|
public interface PaymoIApiClient
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,16 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class LoggingHandler : DelegatingHandler
|
public class PaymoLoggingHandler : DelegatingHandler
|
||||||
{
|
{
|
||||||
private readonly ILogger<LoggingHandler> _logger;
|
private readonly ILogger<PaymoLoggingHandler> _logger;
|
||||||
|
|
||||||
public LoggingHandler(ILogger<LoggingHandler> logger)
|
public PaymoLoggingHandler(ILogger<PaymoLoggingHandler> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoggingHandler(HttpMessageHandler innerHandler, ILogger<LoggingHandler> logger)
|
public PaymoLoggingHandler(HttpMessageHandler innerHandler, ILogger<PaymoLoggingHandler> logger)
|
||||||
: base(innerHandler)
|
: base(innerHandler)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -2,9 +2,9 @@ using System.Net.Http;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Shared
|
namespace Novaloop.PaymoApi.Shared
|
||||||
{
|
{
|
||||||
public class ApiClient : IApiClient
|
public class PaymoPaymoIApiClient : PaymoIApiClient
|
||||||
{
|
{
|
||||||
public ApiClient(HttpClient client)
|
public PaymoPaymoIApiClient(HttpClient client)
|
||||||
{
|
{
|
||||||
Client = client;
|
Client = client;
|
||||||
}
|
}
|
||||||
@@ -4,24 +4,24 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks
|
namespace Novaloop.PaymoApi.Tasks
|
||||||
{
|
{
|
||||||
public interface ITasksApi
|
public interface IPaymoTasksApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Receive all existing tasks
|
/// Receive all existing tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<IEnumerable<Novaloop.PaymoApi.Tasks.Models.Task>> GetTasks();
|
Task<IEnumerable<Models.PaymoTask>> GetTasks();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an existing Task by id
|
/// Retrieve an existing Task by id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="taskId">id of the task</param>
|
/// <param name="taskId">id of the task</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Novaloop.PaymoApi.Tasks.Models.Task> GetTask(int taskId);
|
Task<Models.PaymoTask> GetTask(int taskId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new Task
|
/// Create a new Task
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<Novaloop.PaymoApi.Tasks.Models.Task> CreateTask(Novaloop.PaymoApi.Tasks.Models.Task task);
|
Task<Models.PaymoTask> CreateTask(Models.PaymoTask paymoTask);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a task
|
/// Delete a task
|
||||||
@@ -4,7 +4,7 @@ using Novaloop.PaymoApi.Shared;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks.Models
|
namespace Novaloop.PaymoApi.Tasks.Models
|
||||||
{
|
{
|
||||||
public class Task : BaseModel
|
public class PaymoTask : PaymoBaseModel
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -3,9 +3,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Novaloop.PaymoApi.Tasks.Models
|
namespace Novaloop.PaymoApi.Tasks.Models
|
||||||
{
|
{
|
||||||
public class TasksResponse
|
public class PaymoTasksResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("tasks")]
|
[JsonProperty("tasks")]
|
||||||
public IEnumerable<Task> Tasks { get; set; }
|
public IEnumerable<PaymoTask> Tasks { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
54
src/Tasks/PaymoTasksApi.cs
Normal file
54
src/Tasks/PaymoTasksApi.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
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 PaymoTasksApi : IPaymoTasksApi
|
||||||
|
{
|
||||||
|
private readonly IPaymoBaseApi<PaymoTasksResponse, PaymoTask> _paymoBaseApi;
|
||||||
|
|
||||||
|
public PaymoTasksApi(IPaymoBaseApi<PaymoTasksResponse, PaymoTask> paymoBaseApi)
|
||||||
|
{
|
||||||
|
_paymoBaseApi = paymoBaseApi;
|
||||||
|
_paymoBaseApi.ResourceUri = "tasks";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IEnumerable<PaymoTask>> GetTasks()
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.GetAll()).Tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoTask> GetTask(int taskId)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Get(taskId)).Tasks.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PaymoTask> CreateTask(PaymoTask paymoTask)
|
||||||
|
{
|
||||||
|
return (await _paymoBaseApi.Create(paymoTask)).Tasks.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task DeleteTask(int taskId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Delete(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task UpdateTask(ExpandoObject task, int taskId)
|
||||||
|
{
|
||||||
|
await _paymoBaseApi.Update(task, taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Dynamic;
|
|
||||||
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(ExpandoObject task, int taskId)
|
|
||||||
{
|
|
||||||
await _baseApi.Update(task, taskId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,10 +10,10 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
{
|
{
|
||||||
public class ClientContactsApiTests
|
public class ClientContactsApiTests
|
||||||
{
|
{
|
||||||
private readonly ClientContactsApi _clientContactsApi;
|
private readonly PaymoClientContactsApi _paymoClientContactsApi;
|
||||||
private readonly ClientsApi _clientsApi;
|
private readonly PaymoPaymoClientsApi _paymoPaymoClientsApi;
|
||||||
|
|
||||||
private readonly ClientContact _testClientContact = new ClientContact
|
private readonly PaymoClientContact _testPaymoClientContact = new PaymoClientContact
|
||||||
{
|
{
|
||||||
Name = "Testclient",
|
Name = "Testclient",
|
||||||
Email = "test@client.de"
|
Email = "test@client.de"
|
||||||
@@ -22,8 +22,8 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
|
|
||||||
public ClientContactsApiTests()
|
public ClientContactsApiTests()
|
||||||
{
|
{
|
||||||
_clientContactsApi = new ClientContactsApi(new BaseApi<ClientContactsResponse, ClientContact>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
_paymoClientContactsApi = new PaymoClientContactsApi(new PaymoBaseApi<PaymoClientContactsResponse, PaymoClientContact>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
_clientsApi = new ClientsApi(new BaseApi<ClientsResponse, Client>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
_paymoPaymoClientsApi = new PaymoPaymoClientsApi(new PaymoBaseApi<PaymoClientsResponse, PaymoClient>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotEmpty(clientContacts);
|
Assert.NotEmpty(clientContacts);
|
||||||
@@ -45,8 +45,8 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
||||||
var clientContact = await _clientContactsApi.GetClientContact(clientContacts.First().Id);
|
var clientContact = await _paymoClientContactsApi.GetClientContact(clientContacts.First().Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(clientContact);
|
Assert.NotNull(clientContact);
|
||||||
@@ -56,32 +56,32 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
public async void CreateClientContact()
|
public async void CreateClientContact()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var existingClientContact = (await _clientsApi.GetClients()).First();
|
var existingClientContact = (await _paymoPaymoClientsApi.GetClients()).First();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testClientContact.ClientId = existingClientContact.Id;
|
_testPaymoClientContact.ClientId = existingClientContact.Id;
|
||||||
var createdClientContact = await _clientContactsApi.CreateClientContact(_testClientContact);
|
var createdClientContact = await _paymoClientContactsApi.CreateClientContact(_testPaymoClientContact);
|
||||||
var clientContact = await _clientContactsApi.GetClientContact(createdClientContact.Id);
|
var clientContact = await _paymoClientContactsApi.GetClientContact(createdClientContact.Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(_testClientContact.Name, clientContact.Name);
|
Assert.Equal(_testPaymoClientContact.Name, clientContact.Name);
|
||||||
Assert.Equal(_testClientContact.Email, clientContact.Email);
|
Assert.Equal(_testPaymoClientContact.Email, clientContact.Email);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
await _clientContactsApi.DeleteClientContact(createdClientContact.Id);
|
await _paymoClientContactsApi.DeleteClientContact(createdClientContact.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void DeleteClientContact()
|
public async void DeleteClientContact()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var existingClientContact = (await _clientsApi.GetClients()).First();
|
var existingClientContact = (await _paymoPaymoClientsApi.GetClients()).First();
|
||||||
_testClientContact.ClientId = existingClientContact.Id;
|
_testPaymoClientContact.ClientId = existingClientContact.Id;
|
||||||
var createdClientContact = await _clientContactsApi.CreateClientContact(_testClientContact);
|
var createdClientContact = await _paymoClientContactsApi.CreateClientContact(_testPaymoClientContact);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await _clientContactsApi.DeleteClientContact(createdClientContact.Id);
|
await _paymoClientContactsApi.DeleteClientContact(createdClientContact.Id);
|
||||||
var clientContacts = (await _clientContactsApi.GetClientContacts()).ToList();
|
var clientContacts = (await _paymoClientContactsApi.GetClientContacts()).ToList();
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
{
|
{
|
||||||
public class ClientsApiTests
|
public class ClientsApiTests
|
||||||
{
|
{
|
||||||
private readonly ClientsApi _clientsApi;
|
private readonly PaymoPaymoClientsApi _paymoPaymoClientsApi;
|
||||||
|
|
||||||
private readonly Client _testClient = new Client
|
private readonly PaymoClient _testPaymoClient = new PaymoClient
|
||||||
{
|
{
|
||||||
Name = "Testclient",
|
Name = "Testclient",
|
||||||
Email = "test@client.de"
|
Email = "test@client.de"
|
||||||
@@ -19,7 +19,7 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
|
|
||||||
public ClientsApiTests()
|
public ClientsApiTests()
|
||||||
{
|
{
|
||||||
_clientsApi = new ClientsApi(new BaseApi<ClientsResponse, Client>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
_paymoPaymoClientsApi = new PaymoPaymoClientsApi(new PaymoBaseApi<PaymoClientsResponse, PaymoClient>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var clients = (await _clientsApi.GetClients()).ToList();
|
var clients = (await _paymoPaymoClientsApi.GetClients()).ToList();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotEmpty(clients);
|
Assert.NotEmpty(clients);
|
||||||
@@ -41,8 +41,8 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var clients = (await _clientsApi.GetClients()).ToList();
|
var clients = (await _paymoPaymoClientsApi.GetClients()).ToList();
|
||||||
var client = await _clientsApi.GetClient(clients.First().Id);
|
var client = await _paymoPaymoClientsApi.GetClient(clients.First().Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(client);
|
Assert.NotNull(client);
|
||||||
@@ -54,26 +54,26 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var createdClient = await _clientsApi.CreateClient(_testClient);
|
var createdClient = await _paymoPaymoClientsApi.CreateClient(_testPaymoClient);
|
||||||
var client = await _clientsApi.GetClient(createdClient.Id);
|
var client = await _paymoPaymoClientsApi.GetClient(createdClient.Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(_testClient.Name, client.Name);
|
Assert.Equal(_testPaymoClient.Name, client.Name);
|
||||||
Assert.Equal(_testClient.Email, client.Email);
|
Assert.Equal(_testPaymoClient.Email, client.Email);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
await _clientsApi.DeleteClient(createdClient.Id);
|
await _paymoPaymoClientsApi.DeleteClient(createdClient.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void DeleteClient()
|
public async void DeleteClient()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var createdClient = await _clientsApi.CreateClient(_testClient);
|
var createdClient = await _paymoPaymoClientsApi.CreateClient(_testPaymoClient);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await _clientsApi.DeleteClient(createdClient.Id);
|
await _paymoPaymoClientsApi.DeleteClient(createdClient.Id);
|
||||||
var clients = (await _clientsApi.GetClients()).ToList();
|
var clients = (await _paymoPaymoClientsApi.GetClients()).ToList();
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
@@ -84,13 +84,13 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
public async void UpdateClient()
|
public async void UpdateClient()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var createdClient = await _clientsApi.CreateClient(_testClient);
|
var createdClient = await _paymoPaymoClientsApi.CreateClient(_testPaymoClient);
|
||||||
dynamic clientUpdateInfo = new ExpandoObject();
|
dynamic clientUpdateInfo = new ExpandoObject();
|
||||||
clientUpdateInfo.Name = "Updated";
|
clientUpdateInfo.Name = "Updated";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await _clientsApi.UpdateClient(clientUpdateInfo, createdClient.Id);
|
await _paymoPaymoClientsApi.UpdateClient(clientUpdateInfo, createdClient.Id);
|
||||||
var updatedClient = await _clientsApi.GetClient(createdClient.Id);
|
var updatedClient = await _paymoPaymoClientsApi.GetClient(createdClient.Id);
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
{
|
{
|
||||||
public static class DependencyFactory
|
public static class DependencyFactory
|
||||||
{
|
{
|
||||||
public static ApiClient GeneratePaymoApiClient()
|
public static PaymoPaymoIApiClient GeneratePaymoApiClient()
|
||||||
{
|
{
|
||||||
return new ApiClient(new HttpClient(new LoggingHandler(new HttpClientHandler(), new NullLogger<LoggingHandler>())) {BaseAddress = new Uri("https://app.paymoapp.com/")});
|
return new PaymoPaymoIApiClient(new HttpClient(new PaymoLoggingHandler(new HttpClientHandler(), new NullLogger<PaymoLoggingHandler>())) {BaseAddress = new Uri("https://app.paymoapp.com/")});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IOptions<ApiOptions> GenerateOptions()
|
public static IOptions<PaymoApiOptions> GenerateOptions()
|
||||||
{
|
{
|
||||||
var paymoToken = new ConfigurationBuilder()
|
var paymoToken = new ConfigurationBuilder()
|
||||||
.SetBasePath(AppContext.BaseDirectory)
|
.SetBasePath(AppContext.BaseDirectory)
|
||||||
@@ -29,7 +29,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 ApiOptions {ApiToken = paymoToken});
|
return Options.Create(new PaymoApiOptions {ApiToken = paymoToken});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,15 +11,15 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
public class TasksApiTests
|
public class TasksApiTests
|
||||||
{
|
{
|
||||||
private readonly ITestOutputHelper _testOutputHelper;
|
private readonly ITestOutputHelper _testOutputHelper;
|
||||||
private readonly TasksApi _tasksApi;
|
private readonly PaymoTasksApi _paymoTasksApi;
|
||||||
private readonly Task _testTask;
|
private readonly PaymoTask _testPaymoTask;
|
||||||
|
|
||||||
public TasksApiTests(ITestOutputHelper testOutputHelper)
|
public TasksApiTests(ITestOutputHelper testOutputHelper)
|
||||||
{
|
{
|
||||||
_testOutputHelper = testOutputHelper;
|
_testOutputHelper = testOutputHelper;
|
||||||
_tasksApi = new TasksApi(new BaseApi<TasksResponse, Task>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
_paymoTasksApi = new PaymoTasksApi(new PaymoBaseApi<PaymoTasksResponse, PaymoTask>(DependencyFactory.GeneratePaymoApiClient(), DependencyFactory.GenerateOptions()));
|
||||||
|
|
||||||
_testTask = new Task
|
_testPaymoTask = new PaymoTask
|
||||||
{
|
{
|
||||||
Name = "Testtask",
|
Name = "Testtask",
|
||||||
Description = "Just a little task"
|
Description = "Just a little task"
|
||||||
@@ -33,7 +33,7 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var tasks = (await _tasksApi.GetTasks()).ToList();
|
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotEmpty(tasks);
|
Assert.NotEmpty(tasks);
|
||||||
@@ -46,8 +46,8 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
// Arrange
|
// Arrange
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var tasks = (await _tasksApi.GetTasks()).ToList();
|
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
||||||
var task = await _tasksApi.GetTask(tasks.First().Id);
|
var task = await _paymoTasksApi.GetTask(tasks.First().Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(task);
|
Assert.NotNull(task);
|
||||||
@@ -57,32 +57,32 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
public async void CreateTask()
|
public async void CreateTask()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
var existingTaskListId = (await _paymoTasksApi.GetTasks()).First().TasklistId;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testTask.TasklistId = existingTaskListId;
|
_testPaymoTask.TasklistId = existingTaskListId;
|
||||||
var createdTask = await _tasksApi.CreateTask(_testTask);
|
var createdTask = await _paymoTasksApi.CreateTask(_testPaymoTask);
|
||||||
var task = await _tasksApi.GetTask(createdTask.Id);
|
var task = await _paymoTasksApi.GetTask(createdTask.Id);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(_testTask.Name, task.Name);
|
Assert.Equal(_testPaymoTask.Name, task.Name);
|
||||||
Assert.Equal(_testTask.Description, task.Description);
|
Assert.Equal(_testPaymoTask.Description, task.Description);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
await _tasksApi.DeleteTask(createdTask.Id);
|
await _paymoTasksApi.DeleteTask(createdTask.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void DeleteTask()
|
public async void DeleteTask()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
var existingTaskListId = (await _paymoTasksApi.GetTasks()).First().TasklistId;
|
||||||
_testTask.TasklistId = existingTaskListId;
|
_testPaymoTask.TasklistId = existingTaskListId;
|
||||||
var createdTask = await _tasksApi.CreateTask(_testTask);
|
var createdTask = await _paymoTasksApi.CreateTask(_testPaymoTask);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await _tasksApi.DeleteTask(createdTask.Id);
|
await _paymoTasksApi.DeleteTask(createdTask.Id);
|
||||||
var tasks = (await _tasksApi.GetTasks()).ToList();
|
var tasks = (await _paymoTasksApi.GetTasks()).ToList();
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
@@ -93,16 +93,16 @@ namespace Novaloop.PaymoApi.Tests
|
|||||||
public async void UpdateTask()
|
public async void UpdateTask()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var existingTaskListId = (await _tasksApi.GetTasks()).First().TasklistId;
|
var existingTaskListId = (await _paymoTasksApi.GetTasks()).First().TasklistId;
|
||||||
_testTask.TasklistId = existingTaskListId;
|
_testPaymoTask.TasklistId = existingTaskListId;
|
||||||
var createdTask = await _tasksApi.CreateTask(_testTask);
|
var createdTask = await _paymoTasksApi.CreateTask(_testPaymoTask);
|
||||||
dynamic taskUpdateInfo = new ExpandoObject();
|
dynamic taskUpdateInfo = new ExpandoObject();
|
||||||
taskUpdateInfo.Name = "Updated";
|
taskUpdateInfo.Name = "Updated";
|
||||||
taskUpdateInfo.TaskListId = _testTask.TasklistId;
|
taskUpdateInfo.TaskListId = _testPaymoTask.TasklistId;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await _tasksApi.UpdateTask(taskUpdateInfo, createdTask.Id);
|
await _paymoTasksApi.UpdateTask(taskUpdateInfo, createdTask.Id);
|
||||||
var updatedTask = await _tasksApi.GetTask(createdTask.Id);
|
var updatedTask = await _paymoTasksApi.GetTask(createdTask.Id);
|
||||||
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|||||||
Reference in New Issue
Block a user