/// <summary>
        /// Map presubscription object
        /// </summary>
        /// <param name="subscriptionData">Subscription data</param>
        /// <returns>Presubscription</returns>
        public static Presubscription Map(mds.Model.Presubscription subscriptionData)
        {
            var substriction = new Presubscription
            {
                DeviceId      = subscriptionData?.EndpointName,
                DeviceType    = subscriptionData?.EndpointType,
                ResourcePaths = subscriptionData?.ResourcePath?.ToList() ?? new List <string>()
            };

            return(substriction);
        }
        /// <summary>
        /// Update pre-subscription data. Pre-subscription data will be removed for empty list.
        /// </summary>
        /// <param name="presubscriptions">Array of <see cref="Presubscription"/></param>
        /// <example>
        /// <code>
        /// try
        /// {
        ///     var presubscription = new Presubscription
        ///     {
        ///         DeviceId = "015bb66a92a30000000000010010006d",
        ///         ResourcePaths = new List { "/5001/0/1" },
        ///     };
        ///     connectApi.UpdatePresubscriptions(new Presubscription[] { presubscription });
        ///
        ///     foreach (var item in api.ListPresubscriptions())
        ///     {
        ///         Console.WriteLine(item);
        ///     }
        /// }
        /// catch (MbedCloudApiException)
        /// {
        ///     throw;
        /// }
        /// </code>
        /// </example>
        /// <exception cref="CloudApiException">CloudApiException</exception>
        public void UpdatePresubscriptions(Presubscription[] presubscriptions)
        {
            var presubscriptionArray = new mds.Model.PresubscriptionArray();

            foreach (var presubscription in presubscriptions)
            {
                var updatedPresubscription = new mds.Model.Presubscription(presubscription.DeviceId, presubscription.DeviceType, presubscription.ResourcePaths.ToList());
                presubscriptionArray.Add(updatedPresubscription);
            }

            try
            {
                SubscriptionsApi.UpdatePreSubscriptions(presubscriptionArray);
            }
            catch (mds.Client.ApiException ex)
            {
                throw new mds.Client.ApiException(ex.ErrorCode, ex.Message, ex.ErrorContent);
            }
        }