Giter VIP home page Giter VIP logo

Comments (4)

Viincenttt avatar Viincenttt commented on June 6, 2024

Hi gerbendv,

Perhaps we could add an constructor override to the API clients so you can inject your own HttpClient. Then you could use your dependency injection framework to pass a singleton instance of HttpClient.

Right now some of the API's have different authentication headers. The Mollie Connect API passes a clientid/clientsecret on every request, while most of the other API's pass the API key. If you'd pass in a singleton HttpClient I will need to make sure the correct information is passed in the Bearer token. This isn't very difficult, but I'll have to do some more testing before I implement this.

I'll also think about your suggestion to use a static HttpClient instead.

Kind regards,
Vincent

from mollieapi.

gerbendv avatar gerbendv commented on June 6, 2024

Hi Vincenttt,

I see the problem with the headers that would or would not be present on the HttpClient. A constructor override might be a good solution. I noticed that HttpClient has a overload of SendAsync in which an instance of HttpRequestMessage can be passed. That would enable you to add the right headers to the HttpRequestMessage.Headers collection.

Best regards,

Gerben

from mollieapi.

Viincenttt avatar Viincenttt commented on June 6, 2024

Hi gerbendv,

I just released a new version of the Mollie API (2.0.1.0) that allows you to pass your own HttpClient instance in the constructor of all the Mollie Client classes.

For example:

HttpClient myHttpClientInstance = new HttpClient();
PaymentClient paymentClient = new PaymentClient(this.ApiTestKey, myHttpClientInstance);
PaymentRequest paymentRequest = new PaymentRequest() {
    Amount = new Amount(Currency.EUR, "100.00"),
    Description = "Description",
    RedirectUrl = this.DefaultRedirectUrl
};
PaymentResponse result = await paymentClient.CreatePaymentAsync(paymentRequest);

Please let me know if you have any other suggestions/ideas.

Kind regards,
Vincent

from mollieapi.

gerbendv avatar gerbendv commented on June 6, 2024

Great, thanks!

from mollieapi.

Related Issues (20)

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.