Skip to content

Commit

Permalink
Merge pull request #3 from aloatias/development
Browse files Browse the repository at this point in the history
Release v1.0.0.0
  • Loading branch information
aloatias authored May 31, 2020
2 parents ff59463 + 9d54f16 commit 6b22300
Show file tree
Hide file tree
Showing 75 changed files with 1,735 additions and 268 deletions.
433 changes: 433 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

Binary file removed .vs/GoogleBooks.Api/v16/.suo
Binary file not shown.
20 changes: 20 additions & 0 deletions GoogleBooks.Api.Integration.Tests/GetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Xunit;

namespace GoogleBooks.Api.Integration.Tests
{
public class GetTests : TestFactory
{


public GetTests()
{

}

[Fact(DisplayName ="Get all books")]
public void Test1()
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions GoogleBooks.Api.Integration.Tests/TestFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace GoogleBooks.Api.Integration.Tests
{
public class TestFactory
{
}
}
26 changes: 25 additions & 1 deletion GoogleBooks.Api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleBooks.Api", "GoogleBooks.Api\GoogleBooks.Api.csproj", "{EEC42CB2-DAB7-4B7C-86D1-1594EA366AF8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleBooks.Api", "GoogleBooks.Api\GoogleBooks.Api.csproj", "{EEC42CB2-DAB7-4B7C-86D1-1594EA366AF8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{771FFFBA-4837-4EC4-B503-223F6E42E993}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleBooks.Client", "GoogleBooks.Client\GoogleBooks.Client.csproj", "{2E7B8EFC-B3D3-4CB0-B8DF-CB18E0B74180}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleBooks.Api.Integration.Tests", "GoogleBooks.Api.Integration.Tests\GoogleBooks.Api.Integration.Tests.csproj", "{F181021F-3B7B-48E2-87E8-AF711F2C4EAF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleBooks.Client.Integration.Tests", "GoogleBooks.Client.Integration.Tests\GoogleBooks.Client.Integration.Tests.csproj", "{F9E7806E-168F-4406-8C4F-F9F317E2B83A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,10 +23,26 @@ Global
{EEC42CB2-DAB7-4B7C-86D1-1594EA366AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEC42CB2-DAB7-4B7C-86D1-1594EA366AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEC42CB2-DAB7-4B7C-86D1-1594EA366AF8}.Release|Any CPU.Build.0 = Release|Any CPU
{2E7B8EFC-B3D3-4CB0-B8DF-CB18E0B74180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E7B8EFC-B3D3-4CB0-B8DF-CB18E0B74180}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E7B8EFC-B3D3-4CB0-B8DF-CB18E0B74180}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E7B8EFC-B3D3-4CB0-B8DF-CB18E0B74180}.Release|Any CPU.Build.0 = Release|Any CPU
{F181021F-3B7B-48E2-87E8-AF711F2C4EAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F181021F-3B7B-48E2-87E8-AF711F2C4EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F181021F-3B7B-48E2-87E8-AF711F2C4EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F181021F-3B7B-48E2-87E8-AF711F2C4EAF}.Release|Any CPU.Build.0 = Release|Any CPU
{F9E7806E-168F-4406-8C4F-F9F317E2B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9E7806E-168F-4406-8C4F-F9F317E2B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9E7806E-168F-4406-8C4F-F9F317E2B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9E7806E-168F-4406-8C4F-F9F317E2B83A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F181021F-3B7B-48E2-87E8-AF711F2C4EAF} = {771FFFBA-4837-4EC4-B503-223F6E42E993}
{F9E7806E-168F-4406-8C4F-F9F317E2B83A} = {771FFFBA-4837-4EC4-B503-223F6E42E993}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49DD649C-E0CE-4CF4-AF3C-784667714715}
EndGlobalSection
Expand Down
24 changes: 24 additions & 0 deletions GoogleBooks.Api/Configuration/ServicesConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using GoogleBooks.Api.Interfaces;
using GoogleBooks.Api.Services;
using GoogleBooks.Client.Configuration;
using GoogleBooks.Client.Configuration.ConfigurationOptions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace GoogleBooks.Api.Configuration
{
public static class ServicesConfiguration
{
private const string _urlsSection = "Urls";

public static void ConfigureApiServices(this IServiceCollection services, IConfiguration configuration)
{
// Api configuration
services.AddScoped<IBooksService, BooksService>();
services.Configure<GoogleBooksUrlOptions>(configuration.GetSection(_urlsSection));

// Google Books Client configuration
services.ConfigureGoogleBooksClientServices(configuration);
}
}
}
95 changes: 95 additions & 0 deletions GoogleBooks.Api/Controllers/BooksController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using GoogleBooks.Api.Dtos;
using GoogleBooks.Api.Dtos.Output;
using GoogleBooks.Api.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace GoogleBooks.Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class BooksController : Controller
{
private readonly IBooksService _booksService;
private readonly ILogger<BooksController> _logger;

public BooksController(IBooksService booksService, ILogger<BooksController> logger)
{
_booksService = booksService;
_logger = logger;
}

[HttpGet]
[Route("GetBookDetailsById")]
public async Task<IActionResult> GetBookDetailsAsync(string bookId)
{
try
{
var getBookDetailsResult = await _booksService.GetBookDetailsAsync(bookId);

switch (getBookDetailsResult.Status)
{
case StatusEnum.Ok:
return Ok(getBookDetailsResult.IndividualBookDetails);
case StatusEnum.NotFound:
return StatusCode(204, getBookDetailsResult.Error.ErrorMessage);
default:
return StatusCode(500);
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message, ex.InnerException, $"Class={ nameof(BooksController) }", $"Method={ nameof(GetBookDetailsAsync) }");
throw;
}
}

[HttpGet]
[Route("GetBooksCatalogOnApiLaunch")]
public async Task<IActionResult> GetBooksCatalogOnApiLaunchAsync(string keywords, int pageNumber, int pageSize)
{
try
{
var getBooksCatalogResult = await _booksService.GetBooksCatalogAsync(new BooksCatalogSearch(keywords, pageNumber, pageSize));

switch (getBooksCatalogResult.Status)
{
case StatusEnum.Ok:
return Ok(getBooksCatalogResult);
default:
return StatusCode(500);
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message, ex.InnerException, $"Class={ nameof(BooksController) }", $"Method={ nameof(GetBooksCatalogOnApiLaunchAsync) }");
throw;
}
}

[HttpPost]
[Route("GetBooksCatalog")]
public async Task<IActionResult> GetBooksCatalogAsync([FromBody]BooksCatalogSearch catalogBooksSearch)
{
try
{
var getBooksCatalogResult = await _booksService.GetBooksCatalogAsync(catalogBooksSearch);

switch (getBooksCatalogResult.Status)
{
case StatusEnum.Ok:
return Ok(getBooksCatalogResult.BooksCatalog);
default:
return StatusCode(500);
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message, ex.InnerException, $"Class={ nameof(BooksController) }", $"Method={ nameof(GetBooksCatalogAsync) }");
throw;
}
}
}
}
39 changes: 0 additions & 39 deletions GoogleBooks.Api/Controllers/WeatherForecastController.cs

This file was deleted.

9 changes: 9 additions & 0 deletions GoogleBooks.Api/Dtos/Input/BooksCatalogSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace GoogleBooks.Api.Dtos
{
public class BooksCatalogSearch : PagingInfoBase
{
public BooksCatalogSearch(string keywords, int pageNumber, int pageSize) : base(keywords, pageNumber, pageSize)
{
}
}
}
73 changes: 73 additions & 0 deletions GoogleBooks.Api/Dtos/Output/BookDetailsForCatalog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
namespace GoogleBooks.Api.Dtos.Output
{
public class BookDetailsForCatalog
{
public string Id { get; set; }

public string Kind { get; set; }

public string Etag { get; set; }

public string SelfLink { get; set; }

public string Title { get; set; }

public string[] Authors { get; set; }

public string Publisher { get; set; }

public string PublishedDate { get; set; }

public string Description { get; set; }

public string TextReadingMode { get; set; }

public bool? ImageReadingMode { get; set; }

public int? PageCount { get; set; }

public int? PrintedPageCount { get; set; }

public string PrintType { get; set; }

public string MaturityRating { get; set; }

public bool? AllowAnonLogging { get; set; }

public string ContentVersion { get; set; }

public string Language { get; set; }

public string PreviewLink { get; set; }

public string InfoLink { get; set; }

public string CanonicalVolumeLink { get; set; }

public string SmallThumbNail { get; set; }

public string Thumbnail { get; set; }

public string Country { get; set; }

public string Saleability { get; set; }

public bool? IsEbook { get; set; }

public bool? Embeddable { get; set; }

public bool? PublicDomain { get; set; }

public string TextToSpeechPermission { get; set; }

public bool? IsPdfAvailable { get; set; }

public string PdfActsTokenLink { get; set; }

public string WebReaderLink { get; set; }

public string AccessViewStatus { get; set; }

public string QuoteSharingAllowed { get; set; }
}
}
17 changes: 17 additions & 0 deletions GoogleBooks.Api/Dtos/Output/BooksCatalog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace GoogleBooks.Api.Dtos.Output
{
public class BooksCatalog
{
public string Kind { get; private set; }

public List<BookDetailsForCatalog> BookDetails { get; private set; }

public BooksCatalog(string kind, List<BookDetailsForCatalog> bookDetails)
{
Kind = kind;
BookDetails = bookDetails;
}
}
}
21 changes: 21 additions & 0 deletions GoogleBooks.Api/Dtos/Output/BooksCatalogResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using GoogleBooks.Api.Dtos.Output.Exceptions;

namespace GoogleBooks.Api.Dtos.Output
{
public class BooksCatalogResult : ResultBase
{
public PagingInfoResult PagingInfo { get; private set; }

public BooksCatalog BooksCatalog { get; private set; }

public BooksCatalogResult(BooksCatalogSearchResult booksCatalogSearchResult, StatusEnum status) : base(status)
{
BooksCatalog = booksCatalogSearchResult.BooksCatalog;
PagingInfo = booksCatalogSearchResult.PagingInfoResult;
}

public BooksCatalogResult(ErrorBase error, StatusEnum status) : base(error, status)
{
}
}
}
17 changes: 17 additions & 0 deletions GoogleBooks.Api/Dtos/Output/BooksCatalogSearchResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using GoogleBooks.Api.Dtos.Output;

namespace GoogleBooks.Api.Dtos
{
public class BooksCatalogSearchResult
{
public PagingInfoResult PagingInfoResult { get; private set; }

public BooksCatalog BooksCatalog { get; private set; }

public BooksCatalogSearchResult(PagingInfoResult pagingInfoResult, BooksCatalog booksCatalog)
{
PagingInfoResult = pagingInfoResult;
BooksCatalog = booksCatalog;
}
}
}
Loading

0 comments on commit 6b22300

Please sign in to comment.