Class CreateProfileFieldApiRequest

java.lang.Object
com.github.jamesnetherton.zulip.client.api.core.ZulipApiRequest
com.github.jamesnetherton.zulip.client.api.server.request.CreateProfileFieldApiRequest
All Implemented Interfaces:
ExecutableApiRequest<Long>

public class CreateProfileFieldApiRequest extends ZulipApiRequest implements ExecutableApiRequest<Long>

Zulip API request builder for creating a custom profile field.

This endpoint is only available to organization administrators.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • withSimpleFieldType

      public CreateProfileFieldApiRequest withSimpleFieldType(ProfileFieldType type, String name, String hint)
      Creates a simple profile field determined by the provided ProfileFieldType.
      Parameters:
      type - The field type to create
      name - The name of the profile field
      hint - The help text displayed against the custom field in the Zulip UI
      Returns:
      This CreateProfileFieldApiRequest instance
    • withListOfOptionsFieldType

      public CreateProfileFieldApiRequest withListOfOptionsFieldType(String name, String hint, Map<String,Map<String,String>> data)
      Creates a list of options profile field.
      Parameters:
      name - The name of the profile field
      hint - The help text displayed against the custom field in the Zulip UI
      data - The map that determines the available list options and their order
                    Map<String, Map<String, String>> options = new LinkedHashMap<>();
                    Map<String, String> option = new LinkedHashMap<>();
                    option.put("text", "Test Field");
                    option.put("order", "1");
                    options.put("test", option);
                    
      Returns:
      This CreateProfileFieldApiRequest instance
    • withExternalAccountFieldType

      public CreateProfileFieldApiRequest withExternalAccountFieldType(Map<String,String> data)
      Creates a external account filed type. Zulip labels this field structure for this field type as not being stable, so this API is best avoided unless you know what you are doing.
      Parameters:
      data - The mao that determines the external account type configuration
                    Map<String, String> externalData = new LinkedHashMap<>();
                    externalData.put("subtype", "github");
                    
      Returns:
      This CreateProfileFieldApiRequest instance
    • withDisplayInProfileSummary

      public CreateProfileFieldApiRequest withDisplayInProfileSummary(boolean isDisplayInProfileSummary)
      Sets whether clients should display this profile field in a summary section of a users profile.
      Parameters:
      isDisplayInProfileSummary - Whether clients should display this profile field in a summary section of a users profile
      Returns:
      This CreateProfileFieldApiRequest instance
    • withRequired

      public CreateProfileFieldApiRequest withRequired(boolean required)
      Sets whether the profile field is required.
      Parameters:
      required - Whether the profile field is required
      Returns:
      This CreateProfileFieldApiRequest instance
    • withEditableByUser

      public CreateProfileFieldApiRequest withEditableByUser(boolean editableByUser)
      Sets whether regular users can edit the profile field on their own account.
      Parameters:
      editableByUser - Whether regular users can edit the profile field on their own account
      Returns:
      This CreateProfileFieldApiRequest instance
    • execute

      public Long execute() throws ZulipClientException
      Executes the Zulip API request for creating a custom profile field.
      Specified by:
      execute in interface ExecutableApiRequest<Long>
      Returns:
      The id of the created profile field
      Throws:
      ZulipClientException - if the request was not successful