예제 #1
0
        internal static async Task <ContentItemModel> PrepareTestItem(ContentManagementClient client, string typeCodename, string externalId = null)
        {
            var type = ContentTypeIdentifier.ByCodename(typeCodename);

            if (externalId != null)
            {
                // We use upsert for preparing item by external ID in order to be able to recover from situation when previous test run didn't clean up properly
                var item = new ContentItemUpsertModel()
                {
                    Name = "Hooray!",
                    Type = type,
                };

                return(await client.UpsertContentItemByExternalIdAsync(externalId, item));
            }
            else
            {
                var item = new ContentItemCreateModel()
                {
                    Name = "Hooray!",
                    Type = type,
                };

                return(await client.CreateContentItemAsync(item));
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a basic content item with the supplied content name
        /// </summary>
        /// <param name="documentName"></param>
        /// <returns></returns>
        public async Task <string> CreateItemAsync(string documentName)
        {
            var item = new ContentItemCreateModel
            {
                Name = documentName,
                Type = ContentTypeIdentifier.ByCodename("simple_page")
            };

            var itemResult = await _managementClient.CreateContentItemAsync(item);

            return(itemResult.CodeName);
        }
        /// <summary>
        /// Creates content item.
        /// </summary>
        /// <param name="contentItem">Represents content item which will be created.</param>
        /// <returns>The <see cref="ContentItemModel"/> instance that represents created content item.</returns>
        public async Task <ContentItemModel> CreateContentItemAsync(ContentItemCreateModel contentItem)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException(nameof(contentItem));
            }

            var endpointUrl = _urlBuilder.BuildItemsUrl();
            var response    = await _actionInvoker.InvokeMethodAsync <ContentItemCreateModel, ContentItemModel>(endpointUrl, HttpMethod.Post, contentItem);

            return(response);
        }
예제 #4
0
        static ContentItemModel CreateNewContentItem(string codename, string type)
        {
            ContentItemCreateModel newitem = new ContentItemCreateModel()
            {
                Name = codename,
                Type = ContentTypeIdentifier.ByCodename(type)
            };

            Task <ContentItemModel> createtask = clientCM.CreateContentItemAsync(newitem);

            return(createtask.GetAwaiter().GetResult());
        }
예제 #5
0
        private async Task <ContentItemModel> CreateUserItem(string name, string id)
        {
            var item = new ContentItemCreateModel
            {
                Name       = name,
                Type       = ContentTypeIdentifier.ByCodename("user"),
                ExternalId = id
            };

            ContentItemModel responseItem = await managementClient.CreateContentItemAsync(item);

            return(responseItem);
        }
예제 #6
0
    public async void QuickStartCreateContentItem()
    {
        // Remove next line in codesample
        var client = _fileSystemFixture.CreateMockClientWithResponse("ArticleContentItemResponse.json");

        var item = new ContentItemCreateModel
        {
            Codename = "on_roasts",
            Name = "On Roasts",
            Type = Reference.ByCodename("article")
        };

        var responseItem = await client.CreateContentItemAsync(item);
    }
예제 #7
0
        private async Task <ContentItemModel> CreateConversationItem(string conversationId)
        {
            ContentItemModel       responseItem;
            ContentItemCreateModel item = new ContentItemCreateModel
            {
                Name       = conversationId,
                Type       = ContentTypeIdentifier.ByCodename("conversation"),
                ExternalId = conversationId
            };

            responseItem = await managementClient.CreateContentItemAsync(item);

            return(responseItem);
        }