Esempio n. 1
0
        public async Task <string> ConnectToApiAsync(string fApiKey, string fApiUrl)
        {
            mAsyncCLient = Blue10.CreateAsyncClient(fApiKey, fApiUrl);
            var fMe = await mAsyncCLient.GetMeAsync();

            return(fMe.EnvironmentName);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var builder       = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            var configuration = builder.Build();
            var apiKey        = configuration["ApiKey"];

            if (apiKey == "API-KEY")
            {
                Console.WriteLine("Please enter a valid ApiKey value in the appsettings.json file.");
                Console.ReadKey();
                return;
            }
            var apiUrl = configuration["ApiUrl"];

            if (string.IsNullOrEmpty(apiUrl))
            {
                apiUrl = "https://api.blue10.com/v2/";
            }
            if (!apiUrl.EndsWith('/'))
            {
                apiUrl += "/";
            }

            var client     = Blue10.CreateClient(apiKey, apiUrl);
            var loginCheck = new LoginCheck(client);

            if (!loginCheck.GetCheckLogin())
            {
                Console.WriteLine($"Couldn't login with given ApiKey / ApiUrl. Please enter a valid ApiKey/ApiUrl value in the appsettings.json file.");
                Console.ReadKey();
                return;
            }


            Console.WriteLine("Starting application");

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                switch (o.Action)
                {
                case "SyncVendors":
                    var fSyncVendors = new SynchVendors(client, o.FileName);
                    fSyncVendors.Synch(o.Company);
                    break;

                case "SyncGLAccounts":
                    var fSyncGLAccounts = new SynchGLAccounts(client, o.FileName);
                    fSyncGLAccounts.Synch(o.Company);
                    break;

                case "SyncCostCenters":
                    var fSynchCostCenters = new SynchCostCenters(client, o.FileName);
                    fSynchCostCenters.Synch(o.Company);
                    break;

                case "SyncVatCodes":
                    var fSynchVATCodes = new SynchVATCodes(client, o.FileName);
                    fSynchVATCodes.Synch(o.Company);
                    break;

                case "GetCompanies":
                    var fGetCompanies = new GetCompanies(client);
                    Console.WriteLine(JsonSerializer.Serialize(fGetCompanies.GetAll()));
                    break;

                case "ProcessDocumentActions":
                    var fProcessDocumentActions = new ProcessDocumentActions(client, o.FileName);
                    fProcessDocumentActions.Process();
                    break;

                case "ProcessAdministrationActions":
                    var fProcessAdministrationActions = new ProcessAdministrationActions(client);
                    fProcessAdministrationActions.Process("C:\\FileToVendors.csv");
                    break;
                }
            });
            Console.WriteLine("Ended successfully");
        }