Code Monkey home page Code Monkey logo

Comments (9)

philippeVerney avatar philippeVerney commented on June 12, 2024 1

Actually, I made the PR.

from csharp-ovh.

LukeMarlin avatar LukeMarlin commented on June 12, 2024

Thank you for bringing that to my attention.
I'll be looking into this as soon as possible! (most probably tomorrow maximum)

from csharp-ovh.

LukeMarlin avatar LukeMarlin commented on June 12, 2024

Fixed with #20 and #21 for now.
When I'm done with #13 I'll update the nuget package and do a full check of documentation.

In the meantime I'll leave this issue opened as there might well be more obsolete stuff :)

from csharp-ovh.

philippeVerney avatar philippeVerney commented on June 12, 2024

This same code snippet also misses "using Ovh.Api.Models;"
By doing a copy paste of the code snippet, the compiler could not find "CredentialRequest" class without this "using".

from csharp-ovh.

LukeMarlin avatar LukeMarlin commented on June 12, 2024

I'll check this before the week end, thanks for the report

from csharp-ovh.

philippeVerney avatar philippeVerney commented on June 12, 2024

I think you also miss a code line to make the same code snippet working : "client.ConsumerKey = credentialRequestResult.ConsumerKey;"
Here is a proposed change. Sorry, I am too lazy to make a fork and a PR.

.. code:: csharp

using Ovh.Api;
using Ovh.Api.Models; // TO BE ADDED!!!!!!
using System;
using System.Collections.Generic;

namespace api_tester
{
    class Program
    {
        static void Main(string[] args)
        {
            Client client = new Client();
            CredentialRequest requestPayload = new CredentialRequest(
                new List<AccessRight>(){
                    new AccessRight("GET", "/me")
                },
                "https://redirect.url" // CHANGE THIS URL IF YOU DON'T WANT TO SEE AN UNREACHING WEBPAGE AFTER YOU LOGGED IN
            );

            CredentialRequestResult credentialRequestResult =
                client.RequestConsumerKey(requestPayload);
            Console.Write(
                String.Format("Please visit {0} to authenticate ",
                    credentialRequestResult.ValidationUrl));
            Console.WriteLine("and press enter to continue");
            Console.ReadLine();

            client.ConsumerKey = credentialRequestResult.ConsumerKey; // TO BE ADDED!!!!!!
            PartialMe me = client.Get<PartialMe>("/me");

            Console.WriteLine(
                String.Format("Welcome, {0}", me.firstname));
            Console.WriteLine(
                String.Format("Btw, your 'consumerKey' is {0}",
                    credentialRequestResult.ConsumerKey));
            Console.ReadLine();
        }
    }

    class PartialMe
    {
        public string firstname { get; set; }
        public string name { get; set; }
    }
}

from csharp-ovh.

LukeMarlin avatar LukeMarlin commented on June 12, 2024

Thank you very much!
I guess that I skipped that missing line because I had a key registered in my env, so it worked for me anyway :)

I'll check and merge is as soon as possible!

from csharp-ovh.

philippeVerney avatar philippeVerney commented on June 12, 2024

Hi Luke,

In documentation paragraph "Install a new mail redirection", this code line does not compile : client.Post(String.Format("/email/domain/{0}/redirection", domain), payload);

Indeed, payload is a dictionary but the post method requires a simple string as a second parameter, not a dictionary.
Could you correct this please?

from csharp-ovh.

LukeMarlin avatar LukeMarlin commented on June 12, 2024

@philippeVerney Fixed with #27.

Made me wonder why I dropped the simple API of Call<T>([...], object data) and forced users to specify a Y for the input data type. The only thing that is done is serialization by Json.Net.

If we still had the old way, that example would still be working. I might remove these <T,Y> versions and use object instead of Y soon as I see no benefits to using them.

If you can confirm it's alright, I'll merge the PR and close that issue.

from csharp-ovh.

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.