public string RequestSenderToken(
     string ReturnURL)
 {
     Debug.Assert(String.IsNullOrEmpty(_envelopeId) == false);
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(_accountCredentials);
     return(apiService.RequestSenderToken(_envelopeId, _accountCredentials.AccountId, ReturnURL));
 }
 /// <summary>
 /// This method will get you the PDF bytes
 /// that can be written out to a PDF file.
 /// </summary>
 /// <returns></returns>
 public byte[] RetrievePdfBytes()
 {
     Debug.Assert(String.IsNullOrEmpty(_envelopeId) == false);
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(_accountCredentials);
     DocuSignWeb.EnvelopePDF    pdf        = apiService.RequestPDF(_envelopeId);
     return(pdf.PDFBytes);
 }
 /// <summary>
 /// Retrieving status goes out to the server and gets the
 /// latest status of the entire envelope.  You can use this
 /// to figure out if the envelope has been signed or delivered.
 /// </summary>
 /// <returns></returns>
 public DocuSignWeb.EnvelopeStatusCode RetrieveStatus()
 {
     Debug.Assert(String.IsNullOrEmpty(_envelopeId) == false);
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(_accountCredentials);
     DocuSignWeb.EnvelopeStatus status     = apiService.RequestStatus(_envelopeId);
     Debug.Assert(!(status == null));
     return(status.Status);
 }
 public string RequestRecipientToken(
     DocuSignWeb.Recipient recipient,
     DocuSignWeb.RequestRecipientTokenAuthenticationAssertion authenticationAssertion,
     DocuSignWeb.RequestRecipientTokenClientURLs clientURLs)
 {
     Debug.Assert(String.IsNullOrEmpty(_envelopeId) == false);
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(_accountCredentials);
     return(apiService.RequestRecipientToken(_envelopeId, recipient.CaptiveInfo.ClientUserId,
                                             recipient.UserName, recipient.Email, authenticationAssertion, clientURLs));
 }
 public static Envelope CreateEnvelopeFromServerTemplates(
     AccountCredentials accountCredentials,
     TemplateReference[] templateRefs,
     Recipient[] signers,
     EnvelopeInformation envelopeInfo,
     bool ActivateEnvelope)
 {
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(accountCredentials);
     DocuSignWeb.EnvelopeStatus envStatus  = apiService.CreateEnvelopeFromTemplates(
         templateRefs, signers, envelopeInfo, ActivateEnvelope);
     return(new Envelope(envStatus.EnvelopeID, accountCredentials));
 }
        /// <summary>
        /// Initial method / factory instanciation.
        /// In case the call is successfully completed you will get back an
        /// envelope object that can be used to work with this envelope.
        /// In case the envelope is misconstructed an exception will be thrown
        /// The IDs on both the recipients and documents are going to be altered
        /// after the call and the Tabs will be linked to the appropriate document and
        /// recipient ids.
        /// </summary>
        /// <param name="signers">A collection of signer objects that describes who is going to
        /// recieve the documents.  You should have at least one signer.  Every signer
        /// must have at least one signature.</param>
        /// <param name="documents">A set of documents with tabs attached
        /// to them.  There should be at least one document in the envelope and there should be
        /// at least one tab on the envelope.</param>
        /// <param name="subject">Subject of the e-mail that the signers
        /// are going to receive</param>
        /// <param name="emailBlurb">e-mail blurb that will be inserted
        /// into the messages delivered to signers</param>
        /// <returns>An envelope object that can be used to work with this envelope.</returns>
        public static Envelope CreateEnvelopeFromTemplates(AccountCredentials accountCredentials,
                                                           DocuSignWeb.Recipient[] signers,
                                                           LinkedTemplateReferenceRoleAssignment[] roleAssignments,
                                                           string template,
                                                           string subject, string emailBlurb,
                                                           DocuSignWeb.CustomField[] fields)
        {
            //
            // Assign sequential IDs to all the recipients
            //
            int nextRecipientId = 1;

            foreach (DocuSignWeb.Recipient recipient in signers)
            {
                recipient.ID = nextRecipientId.ToString(System.Globalization.CultureInfo.InvariantCulture);
                nextRecipientId++;
            }

            //
            // update the template references
            //
            TemplateReferenceRoleAssignment[] finalRoleAssignments = new TemplateReferenceRoleAssignment[roleAssignments.Length];
            for (int i = 0; i < roleAssignments.Length; ++i)
            {
                roleAssignments[i].referenceRoleAssignment.RecipientID = roleAssignments[i].signer.ID;
                finalRoleAssignments[i] = roleAssignments[i].referenceRoleAssignment;
            }

            //
            // setting up the template
            //
            TemplateReference templateReference = new TemplateReference();

            templateReference.Template         = template;
            templateReference.TemplateLocation = TemplateLocationCode.SOAP;
            templateReference.RoleAssignments  = finalRoleAssignments;

            //
            // Envelope wide information
            //
            DocuSignWeb.EnvelopeInformation envelopeInfo = new EnvelopeInformation();
            envelopeInfo.AccountId    = accountCredentials.AccountId;
            envelopeInfo.CustomFields = fields;
            envelopeInfo.EmailBlurb   = emailBlurb;
            envelopeInfo.Subject      = subject;

            DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(accountCredentials);
            DocuSignWeb.EnvelopeStatus envStatus  = apiService.CreateEnvelopeFromTemplates(
                new TemplateReference[] { templateReference },
                signers, envelopeInfo, true);
            return(new Envelope(envStatus.EnvelopeID, accountCredentials));
        }
 /// <summary>
 /// This method will allow you to void an envelope.  Voiding
 /// does not work if the envelope has not been complete yet.
 /// </summary>
 public void Void(string reason)
 {
     Debug.Assert(String.IsNullOrEmpty(_envelopeId) == false);
     DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(_accountCredentials);
     apiService.VoidEnvelope(_envelopeId, reason);
 }
        /// <summary>
        /// Initial method / factory instanciation.
        /// In case the call is successfully completed you will get back an
        /// envelope object that can be used to work with this envelope.
        /// In case the envelope is misconstructed an exception will be thrown
        /// The IDs on both the recipients and documents are going to be altered
        /// after the call and the Tabs will be linked to the appropriate document and
        /// recipient ids.
        /// </summary>
        /// <param name="signers">A collection of signer objects that describes who is going to
        /// recieve the documents.  You should have at least one signer.  Every signer
        /// must have at least one signature.</param>
        /// <param name="documents">A set of documents with tabs attached
        /// to them.  There should be at least one document in the envelope and there should be
        /// at least one tab on the envelope.</param>
        /// <param name="subject">Subject of the e-mail that the signers
        /// are going to receive</param>
        /// <param name="emailBlurb">e-mail blurb that will be inserted
        /// into the messages delivered to signers</param>
        /// <returns>An envelope object that can be used to work with this envelope.</returns>
        public static Envelope CreateAndSendEnvelope(AccountCredentials accountCredentials, DocuSignWeb.Recipient[] signers, LinkedDocument[] documents, string subject, string emailBlurb, DocuSignWeb.CustomField[] fields, DocuSignWeb.Attachment[] attachments)
        {
            //
            // Assign sequential IDs to all the recipients
            //
            int nextRecipientId = 1;

            foreach (DocuSignWeb.Recipient recipient in signers)
            {
                recipient.ID = nextRecipientId.ToString(System.Globalization.CultureInfo.InvariantCulture);
                nextRecipientId++;
            }

            //
            // go through the documents
            // assign them appropriate IDs
            // and then pull out the tabs and properly assign
            // recipients to for them.
            //
            List <DocuSignWeb.Tab> tabs = new List <DocuSignWeb.Tab>();
            int nextDocId = 1;

            foreach (LinkedDocument linkedDoc in documents)
            {
                linkedDoc.Document.ID = nextDocId.ToString(CultureInfo.InvariantCulture);

                foreach (LinkedTab linkedTab in linkedDoc.Tabs)
                {
                    linkedTab.Tab.DocumentID  = linkedDoc.Document.ID;
                    linkedTab.Tab.RecipientID = linkedTab.Recipient.ID;
                    tabs.Add(linkedTab.Tab);
                }
                nextDocId++;
            }

            //
            // Envelope wide initialization
            //
            DocuSignWeb.Envelope envelope = new DocuSignWeb.Envelope();
            envelope.Subject    = subject;
            envelope.EmailBlurb = emailBlurb;
            envelope.Recipients = signers;
            envelope.AccountId  = accountCredentials.AccountId;

            // assign the document array
            envelope.Documents = new DocuSignWeb.Document[documents.Length];
            for (int i = 0; i < documents.Length; ++i)
            {
                envelope.Documents[i] = documents[i].Document;
            }

            // assign the tabs to the envelope
            envelope.Tabs = tabs.ToArray();

            envelope.CustomFields       = fields;
            envelope.EnvelopeAttachment = attachments;

            DocuSignWeb.APIServiceSoap apiService = CreateApiProxy(accountCredentials);
            DocuSignWeb.EnvelopeStatus envStatus  = apiService.CreateAndSendEnvelope(envelope);
            return(new Envelope(envStatus.EnvelopeID, accountCredentials));
        }