예제 #1
0
        public async Task <IActionResult> UpdateCurrencyHttp(
            [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "currency")] HttpRequest req, ILogger log)
        {
            log.LogInformation("HTTP Currency Updated Trigger");
            await _command.Update();

            return(new OkObjectResult("OK"));
        }
        public async Task <EnvironmentSeedResponse> Seed(EnvironmentSeed seed)
        {
            if (string.IsNullOrEmpty(_settings.OrderCloudSettings.ApiUrl))
            {
                throw new Exception("Missing required app setting OrderCloudSettings:ApiUrl");
            }
            if (string.IsNullOrEmpty(_settings.OrderCloudSettings.WebhookHashKey))
            {
                throw new Exception("Missing required app setting OrderCloudSettings:WebhookHashKey");
            }
            if (string.IsNullOrEmpty(_settings.EnvironmentSettings.MiddlewareBaseUrl))
            {
                throw new Exception("Missing required app setting EnvironmentSettings:MiddlewareBaseUrl");
            }

            var portalUserToken = await _portal.Login(seed.PortalUsername, seed.PortalPassword);

            await VerifyOrgExists(seed.SellerOrgID, portalUserToken);

            var orgToken = await _portal.GetOrgToken(seed.SellerOrgID, portalUserToken);

            await CreateDefaultSellerUsers(seed, orgToken);

            await CreateIncrementors(orgToken);         // must be before CreateBuyers
            await CreateMessageSenders(seed, orgToken); // must be before CreateBuyers and CreateSuppliers

            await CreateSecurityProfiles(orgToken);
            await CreateBuyers(seed, orgToken);
            await CreateConfigureAnonBuyer(seed, orgToken);

            await CreateApiClients(orgToken);
            await AssignSecurityProfiles(seed, orgToken);

            var apiClients = await GetApiClients(orgToken);

            await CreateXPIndices(orgToken);
            await CreateAndAssignIntegrationEvents(new string[] { apiClients.BuyerUiApiClient.ID }, apiClients.BuyerLocalUiApiClient.ID, orgToken);
            await CreateSuppliers(seed, orgToken);

            // populates exchange rates into blob container name: settings.BlobSettings.ContainerNameExchangeRates or "currency" if setting is not defined
            await _exhangeRates.Update();

            // populate default english translations into blob container name: settings.BlobSettings.ContainerNameTranslations or "ngx-translate" if setting is not defined
            // provide other language files to support multiple languages
            var currentDirectory        = Directory.GetCurrentDirectory();
            var englishTranslationsPath = Path.GetFullPath(Path.Combine(currentDirectory, @"..\Headstart.Common\Assets\english-translations.json"));
            await _translationsBlob.Save("i18n/en.json", File.ReadAllText(englishTranslationsPath));

            return(new EnvironmentSeedResponse
            {
                Comments = "Success! Your environment is now seeded. The following clientIDs & secrets should be used to finalize the configuration of your application. The initial admin username and password can be used to sign into your admin application",
                ApiClients = new Dictionary <string, dynamic>
                {
                    ["Middleware"] = new
                    {
                        ClientID = apiClients.MiddlewareApiClient.ID,
                        ClientSecret = apiClients.MiddlewareApiClient.ClientSecret
                    },
                    ["Seller"] = new
                    {
                        ClientID = apiClients.AdminUiApiClient.ID
                    },
                    ["Buyer"] = new
                    {
                        ClientID = apiClients.BuyerUiApiClient.ID
                    }
                }
            });
        }