Skip to content

Commit

Permalink
Added remaining endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed May 13, 2020
1 parent 5eadccf commit 268130f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
5 changes: 3 additions & 2 deletions DVSA.MOT.SDK/Interfaces/IAllVehiclesService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Threading.Tasks;
using DVSA.MOT.SDK.Models;

namespace DVSA.MOT.SDK.Interfaces
{
public interface IAllVehiclesService
{
MotTestResponses GetAllMotTests(int page);
MotTestResponses GetAllMotTestsByDate(DateTime date, int page);
Task<ApiResponse> GetAllMotTests(int page);
Task<ApiResponse> GetAllMotTestsByDate(DateTime date, int page);
}
}
45 changes: 41 additions & 4 deletions DVSA.MOT.SDK/Services/AllVehiclesService.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DVSA.MOT.SDK.Interfaces;
using DVSA.MOT.SDK.Models;
using Microsoft.Extensions.Logging;

namespace DVSA.MOT.SDK.Services
{
public class AllVehiclesService : IAllVehiclesService
{
public MotTestResponses GetAllMotTests(int page)
private readonly ILogger<SingleVehicleService> _logger;
private readonly IProcessApiResponse _processApiResponse;

public AllVehiclesService(ILogger<SingleVehicleService> logger, IProcessApiResponse processApiResponse)
{
_logger = logger;
_processApiResponse = processApiResponse;
}

public async Task<ApiResponse> GetAllMotTests(int page)
{
throw new NotImplementedException();
try
{
var parameters = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(Constants.Parameters.Page, page.ToString())
};
return await _processApiResponse.GetData(parameters);
}
catch (Exception ex)
{
_logger.Log(LogLevel.Error, ex, ex.Message);
return null;
}
}

public MotTestResponses GetAllMotTestsByDate(DateTime date, int page)
public async Task<ApiResponse> GetAllMotTestsByDate(DateTime date, int page)
{
throw new NotImplementedException();
try
{
var parameters = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(Constants.Parameters.Date, date.ToString("yyyyMMdd")),
new KeyValuePair<string, string>(Constants.Parameters.Page, page.ToString())
};
return await _processApiResponse.GetData(parameters);
}
catch (Exception ex)
{
_logger.Log(LogLevel.Error, ex, ex.Message);
return null;
}
}
}
}

0 comments on commit 268130f

Please sign in to comment.