Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/BoldSign.Examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
109 changes: 103 additions & 6 deletions examples/DocumentExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ public TeamDocumentRecords ListTeamDocuments()
return documents;
}

/// <summary>
/// Lists the behalf documents.
/// </summary>
public BehalfDocumentRecords ListBehalfDocuments()
{
var tags = new List<string> { "tag" };
var recipients = new List<string> { "recipient1@email.com", "recipient2@email.com" };
var documents = this.DocumentClient.ListBehalfDocuments(
page: 1,
pageSize: 20,
labels: tags,
signers: recipients);

return documents;
}

/// <summary>
/// Lists the document by senders.
/// </summary>
Expand Down Expand Up @@ -87,6 +103,51 @@ public DocumentRecords ListDocumentsWithDateRage()
return documents;
}

/// <summary>
/// Add emailOTP authentication.
/// </summary>
public void AddAuthenticationEmailOTP()
{
// This is an example document id, add your own document id upon usage.
var documentId = "949ebf20-45a8-4a3e-91a9-68e9540e0020";

this.DocumentClient.AddAuthentication(documentId, "signer1@email.com", AuthenticationType.EmailOTP);
}

/// <summary>
/// Add AccessCode authentication.
/// </summary>
public void AddAuthenticationAccessCode()
{
// This is an example document id, add your own document id upon usage.
var documentId = "949ebf20-45a8-4a3e-91a9-68e9540e0020";

this.DocumentClient.AddAuthentication(documentId, "signer1@email.com", AuthenticationType.AccessCode, 1, "123456");
}

/// <summary>
/// Add emailOTP authentication(When Document signing order enabled).
/// </summary>
public void AddAuthenticationEmailOTPWithOrder()
{
// This is an example document id, add your own document id upon usage.
var documentId = "949ebf20-45a8-4a3e-91a9-68e9540e0020";

this.DocumentClient.AddAuthentication(documentId, "signer1@email.com", AuthenticationType.EmailOTP, 2);
}

/// <summary>
/// Add AccessCode authentication(When Document signing order enabled).
/// </summary>
public void AddAuthenticationAccessCodeWithOrder()
{
// This is an example document id, add your own document id upon usage.
var documentId = "949ebf20-45a8-4a3e-91a9-68e9540e0020";

// targeting 2nd order signer of the document
this.DocumentClient.AddAuthentication(documentId, "signer1@email.com", AuthenticationType.AccessCode, 2, "123456");
}

/// <summary>
/// Gets the document properties.
/// </summary>
Expand Down Expand Up @@ -115,6 +176,20 @@ public Stream DownloadDocument()
return documentStream;
}

/// <summary>
/// Downloads the Attachment.
/// </summary>
/// <returns>A Stream.</returns>
public Stream DownloadAttachment()
{
// This is an example document id, add your own document id upon usage.
var documentId = "87e96d94-2a50-4a6b-aff1-449283d395d3";
var attachmentId = "attachment_6rn98";
var documentStream = this.DocumentClient.DownloadAttachment(documentId, attachmentId);

return documentStream;
}

/// <summary>
/// Downloads the document.
/// </summary>
Expand Down Expand Up @@ -213,6 +288,17 @@ public void ChangeAccessCode()
this.DocumentClient.ChangeAccessCode(documentId, "signer1@email.com", "newAccessCodeHere");
}

/// <summary>
/// Extends the expiration date of the document.
/// </summary>
public void ExtendExpiry()
{
// This is an example document id, add your own document id upon usage.
var documentId = "052181ef-0817-41f6-9e75-6310b796d7fd";
var newExpiryValue = "2022-10-15";
this.DocumentClient.ExtendExpiry(documentId, newExpiryValue);
}

/// <summary>
/// chnages the recipient details.
/// </summary>
Expand All @@ -221,7 +307,7 @@ public void ChangeRecipient()
// This is an example document id, add your own document id upon usage.
var documentId = "1ace7c82-6770-4d03-b514-b593e20c4550";

this.DocumentClient.ChangeRecipient(documentId, "signer1@gmail.com", "wrong email", "signer2", "signer2@email.com");
this.DocumentClient.ChangeRecipient(documentId, "signer1@email.com", "wrong email", "signer2", "signer2@email.com");
}

/// <summary>
Expand Down Expand Up @@ -260,7 +346,7 @@ public async Task<DocumentCreated> CreateDocument()
{
List<FormField> formFeilds = new List<FormField>();
formFeilds.Add(new FormField(
id: "Sign_1",
name: "Sign",
type: FieldType.Signature,
pageNumber: 1,
isRequired: true,
Expand All @@ -274,7 +360,7 @@ public async Task<DocumentCreated> CreateDocument()
{
new DocumentSigner(
name: "Signer Name 1",
emailAddress: "test@boldsign.dev",
emailAddress: "signer1@email.com",
signerOrder: 1,
authenticationCode: "123",
signerType: SignerType.Signer,
Expand Down Expand Up @@ -324,7 +410,7 @@ public async Task<DocumentCreated> CreateDocumentWithFileUrl()
List<FormField> formFields = new List<FormField>
{
new FormField(
id: "Sign_1",
name: "Sign",
type: FieldType.Signature,
pageNumber: 1,
isRequired: true,
Expand Down Expand Up @@ -367,7 +453,7 @@ public async Task EmbeddedSendDocument()
List<FormField> formFields = new List<FormField>
{
new FormField(
id: "Sign_1",
name: "Sign",
type: FieldType.Signature,
pageNumber: 1,
isRequired: true,
Expand Down Expand Up @@ -415,5 +501,16 @@ public async Task EmbeddedSendDocument()
// url to send the document from your web application
var documentSendUrl = documentCreated.SendUrl;
}
/// <summary>
/// Removes the access code.
/// </summary>
public void RemoveAuthentication()
{
// This is an example document id, add your own document id upon usage.
var documentId = "949ebf20-45a8-4a3e-91a9-68e9540e0020";

this.DocumentClient.RemoveAuthentication(documentId, "signer1@email.com", 1);
}

}
}
}
22 changes: 21 additions & 1 deletion examples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace BoldSign.Examples
{
using BoldSign.Api;
using BoldSign.Api;
using System.Threading.Tasks;
using BoldSign.Model.Webhook;

internal class Program
{
Expand All @@ -18,8 +19,27 @@ private static async Task Main(string[] args)
var templateExamples = new TemplateExamples(new TemplateClient(apiClient));
var userExamples = new UserExamples(new UserClient(apiClient));
var brandingExamples = new BrandingExamples(new BrandingClient(apiClient));
var senderIdentityExamples = new SenderIdentityExamples(new SenderIdentityClient(apiClient));
await documentExamples.CreateDocument().ConfigureAwait(false);

// webhook event helpers
var jsonPayload = "{}";
var webhookEvent = WebhookUtility.ParseEvent(jsonPayload);

switch (webhookEvent.Event.EventType)
{
// if its a document event, cast as DocumentEvent
case WebHookEventType.Declined:
var documentEvent = webhookEvent.Data as DocumentEvent;

break;

// if its a sender identity event, cast as SenderIdentityEvent
case WebHookEventType.SenderIdentityUpdated:
var senderIdentityEvent = webhookEvent.Data as SenderIdentityEvent;

break;
}
}
}
}
85 changes: 85 additions & 0 deletions examples/SenderIdentityExamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
namespace BoldSign.Examples
{
using BoldSign.Api;
using BoldSign.Model;

/// <summary>
/// The sender identity examples.
/// </summary>
public class SenderIdentityExamples
{
private readonly SenderIdentityClient senderIdentityClient;

/// <summary>
/// Initializes a new instance of the <see cref="SenderIdentityExamples" /> class.
/// </summary>
/// <param name="SenderIdentityClient">The sender identity api.</param>
public SenderIdentityExamples(SenderIdentityClient senderIdentityClient) => this.senderIdentityClient = senderIdentityClient;

/// <summary>
/// Gets or sets the create sender identity details.
/// Gets or sets the emailId (Required).
/// Gets or sets the name (Required).
/// </summary>
public SenderIdentityCreated CreateSenderIdentity()
{
NotificationSettings notificationSettings = new NotificationSettings();
notificationSettings.AuthenticationFailed = true;
notificationSettings.Completed = true;
notificationSettings.Sent = true;
var request = new SenderIdentityRequest("Sender Identity", "identity@email.com", notificationSettings);
var senderIdentityCreated = this.senderIdentityClient.CreateSenderIdentity(request);
return senderIdentityCreated;
}

/// <summary>
/// Updates sender identity name.
/// This is an example sender identity name, add your own sender identity name upon usage.
/// This is an example sender identity email, add your own identity email upon usage.
/// </summary>
public void UpdateSenderIdentity()
{
NotificationSettings notificationSettings = new NotificationSettings();
notificationSettings.Completed = false;
notificationSettings.Sent = false;
var request = new SenderIdentityRequest("Edit Sender Identity", "identity@email.com", notificationSettings);
this.senderIdentityClient.UpdateSenderIdentity(request);
}

/// <summary>
/// Resend sender identity invite.
/// </summary>
public void ResendSenderIdentityInvitation()
{
var email = "identity@email.com";
this.senderIdentityClient.ResendInvitation(email);
}

/// <summary>
/// Rerequests the sender identity.
/// </summary>
public void RerequestSenderIdentity()
{
var email = "identity@email.com";
this.senderIdentityClient.RerequestSenderIdentity(email);
}

/// <summary>
/// Delete sender identity.
/// </summary>
public void DeleteSenderIdentity()
{
var email = "identity@email.com";
this.senderIdentityClient.DeleteSenderIdentity(email);
}

/// <summary>
/// Lists the sender identities.
/// </summary>
public SenderIdentityList ListSenderIdentity()
{
var senderIdentities = this.senderIdentityClient.ListSenderIdentities(page: 1, pageSize: 20);
return senderIdentities;
}
}
}
Loading