Class ModuleSpaceMemberships


  • public class ModuleSpaceMemberships
    extends java.lang.Object
    This module contains all the space membership options available to this SDK.
    • Constructor Detail

      • ModuleSpaceMemberships

        public ModuleSpaceMemberships​(retrofit2.Retrofit retrofit,
                                      java.util.concurrent.Executor callbackExecutor,
                                      java.lang.String spaceId,
                                      java.lang.String environmentId,
                                      boolean environmentIdConfigured)
        Create a new membership module.
        Parameters:
        retrofit - the retrofit instance to be used to create the service.
        callbackExecutor - to tell on which thread it should run.
        spaceId - the id of the space to be used if not specified in the module call.
        environmentId - the id of the environment used, if not specified before.
        environmentIdConfigured - internal helper to see if environment was set.
    • Method Detail

      • createService

        protected ServiceSpaceMemberships createService​(retrofit2.Retrofit retrofit)
        Initialize retrofit with the current service.
        Parameters:
        retrofit - the instance to use the service with.
        Returns:
        a populated instance of the service to be used.
      • async

        public ModuleSpaceMemberships.Async async()
        Use all functionalities of this module asynchronously.
        Returns:
        an asynchronous handling instance.
      • fetchAll

        public CMAArray<CMASpaceMembership> fetchAll​(java.lang.String spaceId,
                                                     java.util.Map<java.lang.String,​java.lang.String> query)
        Fetch all memberships of this space.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - the space identifier identifying the space.
        query - define which space memberships to return.
        Returns:
        the array of memberships.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
      • fetchOne

        public CMASpaceMembership fetchOne​(java.lang.String spaceId,
                                           java.lang.String membershipId)
        Fetches one space membership by its id from Contentful.
        Parameters:
        spaceId - the space this membership is hosted by.
        membershipId - the id of the membership to be found.
        Returns:
        null if no membership was found, otherwise the found membership.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if membership id is null.
      • update

        public CMASpaceMembership update​(CMASpaceMembership membership)
        Update the given membership instance on Contentful.

        Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.

        Parameters:
        membership - the membership fetched from Contentful, updated by caller, to be updated.
        Returns:
        the updated membership.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if membership is null.
        java.lang.IllegalArgumentException - if membership id is null.
        java.lang.IllegalArgumentException - if membership does not have a version attached.
      • delete

        public int delete​(CMASpaceMembership membership)
        Delete the given membership instance.

        Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.

        Parameters:
        membership - the membership fetched from Contentful, updated by caller, to be deleted.
        Returns:
        the code of the response (204 means success).
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if membership id is null.