public async Task <T> GetKontentItem <T>(GetKontentParameters getKontentItemParameters) where T : notnull { return(await GetDeliveryClient() .GetItemAsync <T>( getKontentItemParameters.Codename, new LanguageParameter(coreContext.Localization) )); }
public async Task <TransferItem> CreateTransferItem(CreateTransferItemParameters createTransferItemParameters) { var contentItemResponse = await AddContentItem(createTransferItemParameters); var variant = GetNewTransferLanguageVariant(createTransferItemParameters); await UpsertLanguageVariant(new UpsertLanguageVariantParameters { Codename = contentItemResponse.Codename, Variant = variant, }); var getKontentItemParameters = new GetKontentParameters { Codename = contentItemResponse.Codename }; await PublishLanguageVariant(getKontentItemParameters); TransferItem?transferItem = default; var retryAttempts = settings.KenticoKontent.PublishLanguageVariantRetry; while (retryAttempts > 0) { try { transferItem = await GetKontentItem <TransferItem>(getKontentItemParameters); } catch { } if (transferItem != default) { return(transferItem); } await Task.Delay(1000); retryAttempts--; } throw new Exception($"Published language variant {contentItemResponse.Codename} but could not get it from Delivery."); }
public async Task UnpublishLanguageVariant(GetKontentParameters getKontentItemParameters) { var requestUri = ConfigureClient($"/codename/{getKontentItemParameters.Codename}/variants/codename/{coreContext.Localization}/unpublish"); await PutAsJsonAsync(requestUri); }