Ejemplo n.º 1
0
        /// <summary>
        /// Create a new section within a ticket field.
        ///
        /// c.f. https://developers.freshdesk.com/api/#create_section
        /// </summary>
        ///
        /// <param name="ticketFieldId">
        /// The unique identifier for the ticket field
        /// </param>
        ///
        /// <param name="request">
        /// The request encapsulating the properties to set on the new section.
        /// </param>
        ///
        /// <param name="cancellationToken"></param>
        ///
        /// <returns>The newly created section</returns>
        public async Task <Section> CreateSectionAsync(
            long ticketFieldId,
            CreateSectionRequest request,
            CancellationToken cancellationToken = default)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request), "Request must not be null");
            }

            return(await _freshdeskClient
                   .ApiOperationAsync <Section, CreateSectionRequest>(HttpMethod.Post, $"/api/v2/admin/ticket_fields/{ticketFieldId}/sections", request, cancellationToken)
                   .ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public SectionInfo CreateSection(
            string name, string code, RichTextInfo description, Identifier courseOfferingId)
        {
            CreateSectionRequest request = new CreateSectionRequest()
            {
                Name             = name,
                Code             = code,
                Description      = description,
                CourseOfferingId = courseOfferingId
            };
            CreateSectionResponse response = CallWebService <
                IOrgUnitManagementServicev1_0, CreateSectionRequest, CreateSectionResponse>(
                m_service1_0, request, (s, q) => s.CreateSection(q));

            return(response.Section);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sections / Create Section
        /// </summary>
        public async Task <CreateSectionResponse> CreateSectionAsync(CreateSectionRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("Value cannot be null.", nameof(request));
            }
            if (string.IsNullOrEmpty(request.Name))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(request.Name));
            }
            if (request.Status == null)
            {
                throw new ArgumentNullException("Value cannot be null.", nameof(request.Status));
            }
            if (request.Position <= 0)
            {
                throw new ArgumentOutOfRangeException("Value must be positive and non zero.", nameof(request.Position));
            }

            return(await ExecuteAsync <CreateSectionResponse>(CreateRequest <CreateSectionRequest>(PROJECTS_PATH, request.ProjectId, SECTIONS_PATH, request)).ConfigureAwait(false));
        }
Ejemplo n.º 4
0
        public PrivateApiResponse <Dictionary <string, Guid> > CreateSection(TestCoreFramework.Enums.ResourceType resource, string name = "TestSection", int columnsCount = 1, int rowsCount = 0)
        {
            var request = new CreateSectionRequest
            {
                TargetResourceId   = (int)resource,
                SectionDescription = new CreateSectionRequest.SectionItem
                {
                    ColumnsCount = columnsCount,
                    RowsCount    = rowsCount,
                    Title        = new Dictionary <string, string>
                    {
                        ["ja"] = name
                    }
                }
            };
            var requestContent = ConvertToJsonString(request);

            using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Creating a new section \"{name}\" in resource {resource}"))
            {
                return(ProcessResponseWithContent <Dictionary <string, Guid> >(Connection.SendAsync(FieldLayoutApiRelativeUrl, requestContent, HttpMethod.Post).Result));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the section for the given template into the given campaign.
        /// </summary>
        /// <param name="templateId">The template Id.</param>
        /// <param name="campaignId">The campaign Id.</param>
        /// <exception cref="System.ArgumentException">
        /// templateId;templateId must not be an empty guid!
        /// or
        /// campaignId;campaignId must not be an empty guid!
        /// </exception>
        public bool GenerateSection(Guid templateId, Guid campaignId)
        {
            if (templateId == Guid.Empty)
            {
                throw new ArgumentException("templateId", "templateId must not be an empty guid!");
            }
            if (campaignId == Guid.Empty)
            {
                throw new ArgumentException("campaignId", "campaignId must not be an empty guid!");
            }

            // Load all available section definitions for the given template
            SectionDefinition[] sectionDefinitions = this.LoadSectionDefinitions(templateId);
            bool sectionsCreated = sectionDefinitions != null && sectionDefinitions.Length > 0;

            // If there are no section definitions we can't setup the campaign.
            if (sectionDefinitions != null && sectionDefinitions.Length > 0)
            {
                // Right here we create three different sample sections for our sample campaign.

                #region SectionArticle
                // Load the section definition that defines an article.
                SectionDefinition definitionArticle = sectionDefinitions.FirstOrDefault(s => s.Name == "article");

                if (definitionArticle != null)
                {
                    CreateSectionRequest createSectionRequest = new CreateSectionRequest()
                    {
                        Campaign = new Campaign {
                            Guid = campaignId
                        },
                        SecurityContext = this.securityContext,
                        Language        = "EN",
                    };



                    // ### BUILD UP THE SECTION ###

                    Section sectionArticle = new Section()
                    {
                        Created = DateTime.Now,
                        SectionDefinitionName = definitionArticle.Name,
                        StatisticName         = "my first article"
                    };

                    /*
                     * Beware when setting field values: Please send new field-objects and ansure that the InternalName of the field contains the same value than the original field...
                     * The different field types use OO paradigms and define the kind of value in the field. Multi-Text-Line, Single-Text-Line, True/False settings etc. They are like datatypes in programming languages.
                     * The InternalName and the fieldtype has to match and they define at which field in the section the value will be entered.
                     * The fields are defined by the mailworx Template (=Layout of the email) and the defined fields there.
                     */
                    List <Field> fieldsToAdd = new List <Field>();
                    foreach (Field currentField in definitionArticle.Fields)
                    {
                        if (currentField.InternalName == "a_show")
                        {
                            fieldsToAdd.Add(new BooleanField()
                            {
                                InternalName = currentField.InternalName, UntypedValue = Boolean.TrueString
                            });
                        }
                        else if (currentField.InternalName == "description")
                        {
                            fieldsToAdd.Add(new TextField()
                            {
                                InternalName = currentField.InternalName,
                                // Beware single quotes do not work for attributes in HTML tags.
                                // If you want to use double quotes for your text, you must use them HTML-encoded.
                                // A text can only be linked with <a> tags and a href attributes. E.g.: <a href=""www.mailworx.info"">go to mailworx website</a>
                                UntypedValue = @"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy &quot;eirmod tempor&quot; invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
												At vero eos et accusam et <a href=""www.mailworx.info"">justo</a> duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
												Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
												At vero eos et accusam et justo duo dolores et ea rebum.  <a href=""http://sys.mailworx.info/sys/Form.aspx?frm=4bf54eb6-97a6-4f95-a803-5013f0c62b35"">Stet</a> clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
                            });
                        }
                        else if (currentField.InternalName == "productimage")
                        {
                            // Upload the file from the given path to the mailworx media data base.
                            Guid fileId = this.UploadFile(@"E:\mailworx\image_2016061694924427.png", "criteria.png");

                            if (fileId != Guid.Empty)
                            {
                                fieldsToAdd.Add(new MdbField()
                                {
                                    InternalName = currentField.InternalName, UntypedValue = fileId.ToString()
                                });
                            }
                        }
                        else if (currentField.InternalName == "name")
                        {
                            fieldsToAdd.Add(new TextField()
                            {
                                InternalName = currentField.InternalName, UntypedValue = "[%mwr:briefanrede%]"
                            });
                        }
                    }

                    sectionArticle.Fields = fieldsToAdd.ToArray();

                    // ### BUILD UP THE SECTION ###



                    createSectionRequest.Section = sectionArticle;


                    // ### CREATE THE SECTION ###

                    CreateSectionResponse response = this.serviceAgent.CreateSection(createSectionRequest);

                    // ### CREATE THE SECTION ###



                    sectionsCreated = sectionsCreated && response != null && response.Guid != Guid.Empty;
                }
                #endregion

                #region SectionBanner
                SectionDefinition definitionBanner = sectionDefinitions.FirstOrDefault(s => s.Name.Equals("banner"));
                if (definitionBanner != null)
                {
                    CreateSectionRequest createBanner = new CreateSectionRequest()
                    {
                        Campaign = new Campaign {
                            Guid = campaignId
                        },
                        SecurityContext = this.securityContext,
                        Language        = "EN"
                    };

                    Section banner = new Section()
                    {
                        Created = DateTime.Now,
                        SectionDefinitionName = definitionBanner.Name,
                        StatisticName         = "banner"
                    };

                    List <Field> fieldsToAdd = new List <Field>();
                    foreach (Field currentField in definitionBanner.Fields)
                    {
                        if (currentField.InternalName == "al_image")
                        {
                            Guid fileId = this.UploadFile(@"E:\mailworx\irated_header_final.jpg", "iratedHeader.jpg");

                            if (fileId != Guid.Empty)
                            {
                                fieldsToAdd.Add(new MdbField()
                                {
                                    InternalName = currentField.InternalName, UntypedValue = fileId.ToString()
                                });
                            }
                        }
                        else if (currentField.InternalName == "al_text")
                        {
                            fieldsToAdd.Add(
                                new TextField()
                            {
                                InternalName = currentField.InternalName,
                                UntypedValue = @"Developed in the <a href=""http://www.mailworx.info/en/"">mailworx</a> laboratory the intelligent and auto-adaptive algorithm <a href=""http://www.mailworx.info/en/irated-technology"">iRated®</a>
													 brings real progress to your email marketing. It is more than a target group oriented approach.
													 iRated® sorts the sections of your emails automatically depending on the current preferences of every single subscriber.
													 This helps you send individual emails even when you don't know much about the person behind the email address."
                            });
                        }
                    }

                    banner.Fields        = fieldsToAdd.ToArray();
                    createBanner.Section = banner;
                    CreateSectionResponse response = this.serviceAgent.CreateSection(createBanner);
                    sectionsCreated = sectionsCreated && response != null && response.Guid != Guid.Empty;
                }

                #endregion

                #region SectionTwoColumns
                SectionDefinition definitionTwoColumn = sectionDefinitions.FirstOrDefault(s => s.Name.Equals("section two columns"));
                if (definitionTwoColumn != null)
                {
                    CreateSectionRequest createTwoColumn = new CreateSectionRequest()
                    {
                        Campaign = new Campaign {
                            Guid = campaignId
                        },
                        SecurityContext = this.securityContext,
                        Language        = "EN"
                    };

                    Section twoColoumn = new Section()
                    {
                        Created = DateTime.Now,
                        SectionDefinitionName = definitionTwoColumn.Name,
                        StatisticName         = "section with two columns"
                    };

                    List <Field> fieldsToAdd = new List <Field>();
                    foreach (Field currentField in definitionTwoColumn.Fields)
                    {
                        if (currentField.InternalName == "atwo_left_image")
                        {
                            Guid fileId = this.UploadFile(@"E:\mailworx\connector.png", "connector.png");

                            if (fileId != Guid.Empty)
                            {
                                fieldsToAdd.Add(new MdbField()
                                {
                                    InternalName = currentField.InternalName, UntypedValue = fileId.ToString()
                                });
                            }
                        }
                        else if (currentField.InternalName == "atwo_left_text")
                        {
                            fieldsToAdd.Add(new TextField()
                            {
                                InternalName = currentField.InternalName, UntypedValue = @"Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 
																														Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim,
																														qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."
                            });
                        }
                        else if (currentField.InternalName == "atwo_right_image")
                        {
                            Guid fileId = this.UploadFile(@"E:\mailworx\event-app-qr-code-ticket.png", "event.png");

                            if (fileId != Guid.Empty)
                            {
                                fieldsToAdd.Add(new MdbField()
                                {
                                    InternalName = currentField.InternalName, UntypedValue = fileId.ToString()
                                });
                            }
                        }
                        else if (currentField.InternalName == "atwo_right_text")
                        {
                            fieldsToAdd.Add(new TextField()
                            {
                                InternalName = "atwo_right_text",
                                UntypedValue = @"Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
											   sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo."
                            });
                        }
                    }

                    twoColoumn.Fields       = fieldsToAdd.ToArray();
                    createTwoColumn.Section = twoColoumn;
                    CreateSectionResponse response = this.serviceAgent.CreateSection(createTwoColumn);
                    sectionsCreated = sectionsCreated && response != null && response.Guid != Guid.Empty;
                }
                #endregion
            }

            return(sectionsCreated);
        }