internal static JsonObject Generate(ComponentInputWithProjectKey componentInput)
        {
            if (componentInput == null)
            {
                throw new ArgumentNullException("componentInput");
            }

            var res = new JsonObject();

            if (componentInput.ProjectKey != null)
            {
                res.Add("project", componentInput.ProjectKey);
            }

            if (componentInput.Name != null)
            {
                res.Add("name", componentInput.Name);
            }

            if (componentInput.Description != null)
            {
                res.Add("description", componentInput.Description);
            }

            if (componentInput.LeadUserName != null)
            {
                res.Add("leadUserName", componentInput.LeadUserName);
            }

            switch (componentInput.AssigneeType)
            {
                case AssigneeType.ProjectDefault:
                    res.Add("assigneeType", "PROJECT_DEFAULT");
                    break;

                case AssigneeType.ComponentLead:
                    res.Add("assigneeType", "COMPONENT_LEAD");
                    break;

                case AssigneeType.ProjectLead:
                    res.Add("assigneeType", "PROJECT_LEAD");
                    break;

                case AssigneeType.Unassigned:
                    res.Add("assigneeType", "UNASSIGNED");
                    break;

                default:
                    throw new ArgumentException("Assignee type is invalid", "componentInput");
            }

            return res;
        }
 /// <summary>
 /// Creates a new component in a project.
 /// </summary>
 /// <param name="projectKey">The key for the project in which to create the new component.</param>
 /// <param name="componentInput">A class containing the essential information about the component.</param>
 /// <returns>The newly created component.</returns>
 /// <exception cref="WebServiceException">The caller is not logged in and does not have permission to create components in the project.</exception>
 public Component CreateComponent(string projectKey, ComponentInput componentInput)
 {
     var helper = new ComponentInputWithProjectKey(projectKey, componentInput);
     var json = ComponentInputWithProjectKeyJsonGenerator.Generate(helper);
     return client.Post<Component>(baseComponentUri.ToString(), json);
 }
 /// <summary>
 /// Creates a new component in a project.
 /// </summary>
 /// <param name="componentUri">The URI for the selected component.</param>
 /// <param name="componentInput">A class containing the essential information about the component.</param>
 /// <returns>The updated component.</returns>
 /// <exception cref="WebServiceException">The caller is not logged in and does not have permission to edit components.</exception>
 public Component UpdateComponent(Uri componentUri, ComponentInput componentInput)
 {
     var helper = new ComponentInputWithProjectKey(null, componentInput);
     var json = ComponentInputWithProjectKeyJsonGenerator.Generate(helper);
     return client.Put<Component>(componentUri.ToString(), json);
 }