-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from aloatias/development
Release v1.0.0.0
- Loading branch information
Showing
75 changed files
with
1,735 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
{ | ||
|
||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
GoogleBooks.Api.Integration.Tests/GoogleBooks.Api.Integration.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace GoogleBooks.Api.Integration.Tests | ||
{ | ||
public class TestFactory | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.