Coder Social home page Coder Social logo

codewrinkles.hibpclient's Introduction

Codewrinkles.HIBPDotNetCore.Client

.NET consumer for the HaveIBeenPawned API

codewrinkles.hibpclient's People

Contributors

danpdc avatar zvaklinov avatar

Stargazers

Eser SAHIN avatar

Watchers

Eser SAHIN avatar

Forkers

esersahin

codewrinkles.hibpclient's Issues

Add sample applications

In order to be able to manually test the functionality and compatibility with different .NET versions we need to create some sample apps. For now I think we to take into consideration two scenarios:

  1. DI-capable apps
  2. DI-non capable apps

Therefore, as part of this story:

  • Create a console .NET 7 console application targeting .NET Framework
  • Create a .NET 7 minimal API
  • Each of the apps should be placed in dedicated solutions in the "samples" folder in the root of the repository
  • For now, all the sample apps should have a project reference to Condewrinkles.HIBP.Client project (we'll replace this dependency with NuGet package once we publish the first one)
  • WPF application targeting .NET Framework
  • WPF application targeting .NET Core

Right now we don't need any functionality in the apps. We just need to have them set up.

Implement exception classes

The HIBP API returns some error responses in certain scenarios. We need to have appropriate exceptions for each of the possible error response. The possible error response codes are documented here: https://haveibeenpwned.com/API/v3#ResponseCodes

  • Implement an exception for each error response
  • follow the custom exception best practices
  • add custom exception properties if there is some data in the error response that we want to capture
  • Override the ToString method so that we can return a meaningful exception string
  • Feel free to design the exceptions the way you see fit.
    Silviu

Implement an initial version of the HibpClient class

The HibpClient class will be the most important class in this project. It will grow presumably as we add support for each Hibp endpoint. But for now we need a basic skeleton for the class. There are several things you should keep in mind at this stage:

  • We need to be flexible and offer the possibility that our class gets an HttpClient via .NET Core dependency injection, but also the possibility to create the HttpClient by ourselves (if our library is used in a non DI .NET app). This means you should probably play around with constructors
  • If we create the HttpClient by ourselves, me need to make sure we dispose it when the HibpClient is disposed.
  • the HibpClient class should also support ILogger. Also keep in mind that we'll either get the ILogger via DI (like the HttpClient) or we might need to create it ourselves. The Logger shouldn't be implemented as part of the story. Just make sure that HibpClient has a field for it

Create custom ILogger

For cases when consumers will use our app in a .NET application that doesn't support dependency injection, we need to be able to create ILogger instances by ourselves.

As part of this story you need to implement a mechanism that can generate named ILoggers. Feel free to investigate and propose an approach that you find suitable.

Implement the HibpOptions class

In the project there is already an empty HibpOptions class.
The HIBP has some API level options that it specifies: for instance how to add the API key, custom headers and so on. The HIBP documentation is here: https://haveibeenpwned.com/API/v3

We will need this class to configure our HibpClient later.

  • Implement properties on the HibpOptions class to capture the necessary options
  • In case if hard coded strings are needed, add them in the Constants class. We don't want to have strings scattered throughout the code base. All string constants need to be in one place

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.