Beispiel #1
0
        /// <summary>
        /// Pre-creates a SafeBox on the SendSecure system and initializes the Safebox object accordingly.
        /// </summary>
        /// <param name="safebox">A SafeBox object to be finalized by the SendSecure system</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated SafeBox object with the necessary system parameters (GUID, public encryption key, upload URL) filled out</returns>
        public async Task <Helpers.Safebox> InitializeSafeboxAsync(Helpers.Safebox safebox, CancellationToken cancellationToken = default(CancellationToken))
        {
            string jsonResponse = await JsonClient.NewSafeboxAsync(safebox.UserEmail, cancellationToken);

            safebox.Update(jsonResponse);

            return(safebox);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve all download activity info of an existing safebox for the current user account.
        /// </summary>
        /// <param name="safebox">A Safebox object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The Download Activity</returns>
        public async Task <Helpers.DownloadActivity> DownloadActivityAsync(Helpers.Safebox safebox, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (safebox.Guid == null)
            {
                throw new Exceptions.SendSecureException("Safebox Guid cannot be null");
            }

            string jsonResponse = await JsonClient.GetSafeboxDownloadActivityAsync(safebox.Guid, cancellationToken);

            safebox.Update(jsonResponse);

            return(safebox.DownloadActivity);
        }
Beispiel #3
0
        /// <summary>
        /// Retrieve all messages info of an existing safebox for the current user account.
        /// </summary>
        /// <param name="safebox">A Safebox object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The list of messages</returns>
        public async Task <List <Helpers.Message> > MessagesAsync(Helpers.Safebox safebox, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (safebox.Guid == null)
            {
                throw new Exceptions.SendSecureException("Safebox Guid cannot be null");
            }

            string jsonResponse = await JsonClient.GetSafeboxMessagesAsync(safebox.Guid, cancellationToken);

            safebox.Update(jsonResponse);

            return(safebox.Messages);
        }
Beispiel #4
0
        /// <summary>
        /// Retrieve all info of an existing safebox for the current user account.
        /// </summary>
        /// <param name="safebox">A Safebox object</param>
        /// <param name="sections">The list of sections to be retrieved</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated safebox containing all the informations on the specified sections.
        ///          If no sections are specified, it will return all safebox infos.</returns>
        public async Task <Helpers.Safebox> SafeboxInfoAsync(Helpers.Safebox safebox, string[] sections, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (safebox.Guid == null)
            {
                throw new Exceptions.SendSecureException("Safebox Guid cannot be null");
            }

            string parameters = sections != null?String.Join(",", sections) : "";

            string jsonResponse = await JsonClient.GetSafeboxInfoAsync(safebox.Guid, parameters, cancellationToken);

            var response = JObject.Parse(jsonResponse);

            safebox.Update(response["safebox"].ToString());

            return(safebox);
        }
Beispiel #5
0
        /// <summary>
        /// This actually "Sends" the SafeBox with all content and contact info previously specified.
        /// </summary>
        /// <param name="safebox">A Safebox object already finalized, with security profile, recipient(s),
        ///                       subject and message already defined, and attachments already uploaded.</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated safebox</returns>
        public async Task <Helpers.Safebox> CommitSafeboxAsync(Helpers.Safebox safebox, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (safebox.Guid == null)
            {
                throw new Exceptions.SendSecureException("Safebox Guid cannot be null");
            }

            if (safebox.Participants.Count == 0)
            {
                throw new Exceptions.SendSecureException("Participants cannot be empty");
            }

            string jsonResponse = await JsonClient.CommitSafeboxAsync(safebox.ToJson(), cancellationToken);

            safebox.Update(jsonResponse);

            return(safebox);
        }