public async Task <HSBuyer> CreateBuyerAndRelatedFunctionalResources(HSBuyer buyer, string accessToken, IOrderCloudClient oc) { // if we're seeding then use the passed in oc client // to support multiple environments and ease of setup for new orgs // else used the configured client var token = oc == null ? null : accessToken; var ocClient = oc ?? _oc; buyer.ID = buyer.ID ?? "{buyerIncrementor}"; var ocBuyer = await ocClient.Buyers.CreateAsync(buyer, accessToken); var ocBuyerID = ocBuyer.ID; buyer.ID = ocBuyerID; // create base security profile assignment await ocClient.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment { BuyerID = ocBuyerID, SecurityProfileID = CustomRole.HSBaseBuyer.ToString() }, token); // assign message sender await ocClient.MessageSenders.SaveAssignmentAsync(new MessageSenderAssignment { MessageSenderID = "BuyerEmails", BuyerID = ocBuyerID }, token); await ocClient.Incrementors.SaveAsync($"{ocBuyerID}-UserIncrementor", new Incrementor { ID = $"{ocBuyerID}-UserIncrementor", LastNumber = 0, LeftPaddingCount = 5, Name = "User Incrementor" }, token); await ocClient.Incrementors.SaveAsync($"{ocBuyerID}-LocationIncrementor", new Incrementor { ID = $"{ocBuyerID}-LocationIncrementor", LastNumber = 0, LeftPaddingCount = 4, Name = "Location Incrementor" }, token); await ocClient.Catalogs.SaveAssignmentAsync(new CatalogAssignment() { BuyerID = ocBuyerID, CatalogID = ocBuyerID, ViewAllCategories = true, ViewAllProducts = false }, token); return(buyer); }
public async Task <EnvironmentSeedResponse> Seed(EnvironmentSeed seed) { OcEnv requestedEnv = validateEnvironment(seed.OrderCloudSettings.Environment); if (requestedEnv.environmentName == OrderCloudEnvironments.Production.environmentName && seed.SellerOrgID == null) { throw new Exception("Cannot create a production environment via the environment seed endpoint. Please contact an OrderCloud Developer to create a production org."); } // lets us handle requests to multiple api environments _oc = new OrderCloudClient(new OrderCloudClientConfig { ApiUrl = requestedEnv.apiUrl, AuthUrl = requestedEnv.apiUrl }); var portalUserToken = await _portal.Login(seed.PortalUsername, seed.PortalPassword); var sellerOrg = await GetOrCreateOrg(portalUserToken, requestedEnv.environmentName, seed.SellerOrgName, seed.SellerOrgID); var orgToken = await _portal.GetOrgToken(sellerOrg.Id, 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, seed); await CreateSuppliers(seed, orgToken); // 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 englishTranslationsPath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "Assets", "english-translations.json")); if (seed?.BlobSettings?.ConnectionString != null && seed?.BlobSettings?.ContainerNameTranslations != null) { var translationsConfig = new BlobServiceConfig() { ConnectionString = seed.BlobSettings.ConnectionString, Container = seed.BlobSettings.ContainerNameTranslations, AccessType = BlobContainerPublicAccessType.Container }; var translationsBlob = new OrderCloudIntegrationsBlobService(translationsConfig); 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", OrganizationName = sellerOrg.Name, OrganizationID = sellerOrg.Id, OrderCloudEnvironment = requestedEnv.environmentName, 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 } } }); }
public AvalaraController(AppSettings settings, IAvalaraCommand avalara, IResaleCertCommand resaleCertCommand, IOrderCloudClient oc) { _avalara = avalara; _resaleCertCommand = resaleCertCommand; }
public HSCatalogCommand(AppSettings settings, IOrderCloudClient oc) { _oc = oc; }
public UserGroupAssignmentSyncCommand(AppSettings settings, LogQuery log, IOrderCloudClient oc) : base(settings, oc, log) { _oc = oc; }
public ShipmentCommand(AppSettings settings, IOrderCloudClient oc, ILineItemCommand lineItemCommand) { _oc = oc; _lineItemCommand = lineItemCommand; }
public ProductFacetSyncCommand(AppSettings settings, LogQuery log, IOrderCloudClient oc) : base(settings, oc, log) { _oc = oc; }
public Functions(IOrderCloudClient oc) { _oc = oc; }
public ReportTemplateQuery(ICosmosStore <ReportTemplate> store, IOrderCloudClient oc) { _store = store; _oc = oc; }
public SupportController(ICheckoutIntegrationCommand checkoutIntegrationCommand, IPostSubmitCommand postSubmitCommand, IZohoCommand zoho, IOrderCloudClient oc, ISupportAlertService supportAlertService, ISendgridService sendgrid) { _checkoutIntegrationCommand = checkoutIntegrationCommand; _postSubmitCommand = postSubmitCommand; _oc = oc; _sendgrid = sendgrid; }
public SmartyStreetsCommand(IOrderCloudClient oc, ISmartyStreetsService service) { _service = service; _oc = oc; }
public async Task <SuperHSBuyer> Create(SuperHSBuyer superBuyer, string accessToken, IOrderCloudClient oc) { var createdImpersonationConfig = new ImpersonationConfig(); var createdBuyer = await CreateBuyerAndRelatedFunctionalResources(superBuyer.Buyer, accessToken, oc); var createdMarkup = await CreateMarkup(superBuyer.Markup, createdBuyer.ID, accessToken, oc); if (superBuyer?.ImpersonationConfig != null) { createdImpersonationConfig = await SaveImpersonationConfig(superBuyer.ImpersonationConfig, createdBuyer.ID, accessToken, oc); } return(new SuperHSBuyer() { Buyer = createdBuyer, Markup = createdMarkup, ImpersonationConfig = createdImpersonationConfig }); }
private async Task <ImpersonationConfig> SaveImpersonationConfig(ImpersonationConfig impersonation, string buyerID, string accessToken, IOrderCloudClient oc = null) { // if we're seeding then use the passed in oc client // to support multiple environments and ease of setup for new orgs // else used the configured client var token = oc == null ? null : accessToken; var ocClient = oc ?? _oc; var currentConfig = await GetImpersonationByBuyerID(buyerID); if (currentConfig != null && impersonation == null) { await ocClient.ImpersonationConfigs.DeleteAsync(currentConfig.ID); return(null); } else if (currentConfig != null) { return(await ocClient.ImpersonationConfigs.SaveAsync(currentConfig.ID, impersonation, token)); } else { impersonation.BuyerID = buyerID; impersonation.SecurityProfileID = Enum.GetName(typeof(CustomRole), CustomRole.HSBaseBuyer); impersonation.ID = $"hs_admin_{buyerID}"; return(await ocClient.ImpersonationConfigs.CreateAsync(impersonation)); } }
private async Task <BuyerMarkup> CreateMarkup(BuyerMarkup markup, string buyerID, string accessToken, IOrderCloudClient oc) { // if we're seeding then use the passed in oc client // to support multiple environments and ease of setup for new orgs // else used the configured client var token = oc == null ? null : accessToken; var ocClient = oc ?? _oc; // to move from xp to contentdocs, that logic will go here instead of a patch var updatedBuyer = await ocClient.Buyers.PatchAsync(buyerID, new PartialBuyer() { xp = new { MarkupPercent = markup.Percent } }, token); return(new BuyerMarkup() { Percent = (int)updatedBuyer.xp.MarkupPercent }); }
public OrderCloudUserAuthHandler(IOptionsMonitor <OrderCloudUserAuthOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IOrderCloudClient ocClient) : base(options, logger, encoder, clock) { _ocClient = ocClient; }
public WebhookController(IOrderCloudClient oc) { _oc = oc; }
public HSReportCommand(IOrderCloudClient oc, ReportTemplateQuery template) { _oc = oc; _template = template; }
public ReceiveRecentPurchaseOrdersJob(IOrderCloudClient oc, IPurchaseOrderDetailDataRepo purchaseOrderDetailDataRepo) { _oc = oc; _purchaseOrderDetailDataRepo = purchaseOrderDetailDataRepo; }
public HSBuyerCommand(AppSettings settings, IOrderCloudClient oc) { _settings = settings; _oc = oc; }
public BuyerController(IHSBuyerCommand command, IOrderCloudClient oc) { _command = command; _oc = oc; }
public BuyerLocationController(ILocationPermissionCommand locationPermissionCommand, IHSBuyerLocationCommand buyerLocationCommand, IOrderCloudClient oc) { _buyerLocationCommand = buyerLocationCommand; _locationPermissionCommand = locationPermissionCommand; _oc = oc; }
public SupplierApiClientHelper(AppSettings settings, IOrderCloudClient oc) { _settings = settings; _oc = oc; }
public HSExchangeRatesService(IOrderCloudClient oc, IExchangeRatesCommand exchangeRatesCommand) { _oc = oc; _exchangeRatesCommand = exchangeRatesCommand; }
public SendgridService(AppSettings settings, IOrderCloudClient ocClient, ISendGridClient client) { _oc = ocClient; _client = client; _settings = settings; }
public LocationPermissionCommand(IOrderCloudClient oc) { _oc = oc; }
public SupplierController(IHeadstartSupplierCommand command, IOrderCloudClient oc, AppSettings settings) : base(settings) { _command = command; _oc = oc; }
public ReceiveRecentLineItemsJob(IOrderCloudClient oc, ILineItemDetailDataRepo lineItemDetailDataRepo) { _oc = oc; _lineItemDetailDataRepo = lineItemDetailDataRepo; }
public CheckoutIntegrationCommand(IAvalaraCommand avalara, IExchangeRatesCommand exchangeRates, IOrderCloudClient orderCloud, IEasyPostShippingService shippingService, AppSettings settings) { _avalara = avalara; _exchangeRates = exchangeRates; _oc = orderCloud; _shippingService = shippingService; _settings = settings; _profiles = new HSShippingProfiles(_settings); }
public OrderSubmitCommand(IOrderCloudClient oc, AppSettings settings, ICreditCardCommand card) { _oc = oc; _settings = settings; _card = card; }
public ReceiveRecentSalesOrdersJob(IOrderCloudClient oc, ISalesOrderDetailDataRepo salesOrderDetailDataRepo) { _oc = oc; _salesOrderDetailDataRepo = salesOrderDetailDataRepo; }