Skip to content

Commit 9c05932

Browse files
author
Sébastien Duverne
committed
Added Install and Quick Start examples
1 parent 2b3eebe commit 9c05932

File tree

1 file changed

+130
-43
lines changed

1 file changed

+130
-43
lines changed

README.md

Lines changed: 130 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ With this library, you will be able to:
3838

3939
## Install Package
4040

41-
```csharp
42-
TBD
43-
```
41+
To use sendsecure-csharp in your C# project, clone or download the SendSecure C# .NET libraries directly from our GitHub repository.
4442

4543
<a name="quickstart"></a>
4644
# Quick Start
@@ -51,26 +49,104 @@ Authentication is done using an API Token, which must be first obtained based on
5149
Here is the minimum code to get such a user-based API Token.
5250

5351
```csharp
54-
TBD
52+
using System;
53+
using System.Collections.Generic;
54+
using System.IO;
55+
using System.Linq;
56+
using System.Text;
57+
using System.Threading.Tasks;
58+
using XMedius.SendSecure;
59+
60+
namespace SendSecureClient
61+
{
62+
class Program
63+
{
64+
static void Main(string[] args)
65+
{
66+
try
67+
{
68+
string token = GetUserToken().Result;
69+
}
70+
catch (XMedius.SendSecure.Exceptions.SendSecureException e)
71+
{
72+
Console.WriteLine(e.Message);
73+
if(!String.IsNullOrEmpty(e.Response))
74+
{
75+
Console.WriteLine("Server response: " + e.Response);
76+
}
77+
}
78+
}
79+
80+
public static async Task<string> GetUserToken()
81+
{
82+
string token = await XMedius.SendSecure.Client.GetUserToken("deathstar", "darthvader", "d@Rk$1De", "DV-TIE/x1", "TIE Advanced x1", "The Force App", new Uri("https://portal.xmedius.com"));
83+
84+
Console.WriteLine(token);
85+
return token;
86+
}
87+
}
88+
}
5589
```
5690

57-
## SafeBox Creation
91+
## SafeBox Creation (Using SafeBox Helper Class)
5892

5993
Here is the minimum required code to create a SafeBox – with 1 recipient, a subject, a message and 1 attachment.
6094
This example uses the user's *default* security profile (which requires to be set in the account).
6195

62-
### With SafeBox Helper Class
63-
6496
```csharp
65-
TBD
97+
using System;
98+
using System.Collections.Generic;
99+
using System.IO;
100+
using System.Linq;
101+
using System.Text;
102+
using System.Threading.Tasks;
103+
using XMedius.SendSecure;
104+
105+
namespace SendSecureClient
106+
{
107+
class Program
108+
{
109+
static void Main(string[] args)
110+
{
111+
try
112+
{
113+
string token = "USER|1d495165-4953-4457-8b5b-4fcf801e621a";
114+
115+
string previewUrl = SubmitSafebox(token).GetAwaiter().GetResult();
116+
}
117+
catch (XMedius.SendSecure.Exceptions.SendSecureException e)
118+
{
119+
Console.WriteLine(e.Message);
120+
if(!String.IsNullOrEmpty(e.Response))
121+
{
122+
Console.WriteLine("Server response: " + e.Response);
123+
}
124+
}
125+
}
126+
127+
public static async Task<string> SubmitSafebox(string token)
128+
{
129+
var safebox2 = new XMedius.SendSecure.Helpers.Safebox("[email protected]");
130+
safebox2.Subject = "Family matters";
131+
safebox2.Message = "Son, you will find attached the evidence.";
132+
133+
safebox2.Attachments.Add(new XMedius.SendSecure.Helpers.Attachment("d:\\Birth_Certificate.pdf"));
134+
135+
var recipient = new XMedius.SendSecure.Helpers.Recipient("[email protected]");
136+
var contactMethod = new XMedius.SendSecure.Helpers.ContactMethod { Destination = "555-232-5334", DestinationType = XMedius.SendSecure.Helpers.ContactMethod.DestinationTypeT.CellPhone };
137+
recipient.ContactMethods.Add(contactMethod);
138+
safebox2.Recipients.Add(recipient);
139+
140+
XMedius.SendSecure.Client client = new Client(token, "deathstar", new Uri("https://portal.xmedius.com"));
141+
XMedius.SendSecure.Helpers.SafeboxResponse safeboxResponse = await client.SubmitSafebox(safebox2);
142+
143+
Console.WriteLine(safeboxResponse.PreviewUrl);
144+
return safeboxResponse.PreviewUrl;
145+
}
146+
}
147+
}
66148
```
67149

68-
<!-- ### Without SafeBox Helper Class
69-
70-
```csharp
71-
TBD
72-
```
73-
-->
74150
<a name="usage"></a>
75151
# Usage
76152

@@ -83,16 +159,17 @@ GetUserToken(enterpriseAccount, username, password, deviceId, deviceName, applic
83159
Creates and returns an API Token for a specific user within a SendSecure enterprise account.
84160
Calling this method again with the exact same params will always return the same Token.
85161

86-
Param | Type | Definition
87-
------------------|--------|-----------
88-
enterpriseAccount | String | The SendSecure enterprise account
89-
username | String | The username of a SendSecure user of the current enterprise account
90-
password | String | The password of this user
91-
deviceId | String | The unique ID of the device used to get the Token
92-
deviceName | String | The name of the device used to get the Token
93-
applicationType | String | The type/name of the application used to get the Token ("SendSecure C#" will be used by default if empty)
94-
endpoint | Uri | The URL to the SendSecure service ("https://portal.xmedius.com" will be used by default if empty)
95-
oneTimePassword | String | The one-time password of this user (if any)
162+
Param | Type | Definition
163+
------------------|-------------------|-----------
164+
enterpriseAccount | String | The SendSecure enterprise account
165+
username | String | The username of a SendSecure user of the current enterprise account
166+
password | String | The password of this user
167+
deviceId | String | The unique ID of the device used to get the Token
168+
deviceName | String | The name of the device used to get the Token
169+
applicationType | String | The type/name of the application used to get the Token ("SendSecure C#" will be used by default if empty)
170+
endpoint | Uri | The URL to the SendSecure service ("https://portal.xmedius.com" will be used by default if empty)
171+
oneTimePassword | String | The one-time password of this user (if any)
172+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
96173

97174
### Client Object Constructor
98175
```
@@ -112,46 +189,54 @@ EnterpriseSettings(cancellationToken)
112189
```
113190
Returns all values/properties of the enterprise account's settings specific to SendSecure.
114191

192+
Param | Type | Definition
193+
------------------|-------------------|-----------
194+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
195+
115196
### Get Default Security Profile
116197
```
117198
DefaultSecurityProfile(userEmail, cancellationToken)
118199
```
119200
Returns the default security profile (if it has been set) for a specific user, with all its setting values/properties.
120201

121-
Param | Type | Definition
122-
-----------|--------|-----------
123-
userEmail | String | The email address of a SendSecure user of the current enterprise account
202+
Param | Type | Definition
203+
------------------|-------------------|-----------
204+
userEmail | String | The email address of a SendSecure user of the current enterprise account
205+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
124206

125207
### Get Security Profiles
126208
```
127209
SecurityProfiles(userEmail, cancellationToken)
128210
```
129211
Returns the list of all security profiles available to a specific user, with all their setting values/properties.
130212

131-
Param | Type | Definition
132-
-----------|--------|-----------
133-
userEmail | String | The email address of a SendSecure user of the current enterprise account
213+
Param | Type | Definition
214+
------------------|-------------------|-----------
215+
userEmail | String | The email address of a SendSecure user of the current enterprise account
216+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
134217

135218
### Initialize SafeBox
136219
```
137220
InitializeSafebox(safebox, cancellationToken)
138221
```
139222
Pre-creates a SafeBox on the SendSecure system and returns the updated Safebox object with the necessary system parameters filled out (GUID, public encryption key, upload URL).
140223

141-
Param | Type | Definition
142-
-----------|---------|-----------
143-
safebox | Safebox | A Safebox object to be initialized by the SendSecure system
224+
Param | Type | Definition
225+
------------------|-------------------|-----------
226+
safebox | String | A Safebox object to be initialized by the SendSecure system
227+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
144228

145229
### Upload Attachment
146230
```
147231
UploadAttachment(safebox, attachment, cancellationToken)
148232
```
149233
Uploads the specified file as an Attachment of the specified SafeBox and returns the updated Attachment object with the GUID parameter filled out.
150234

151-
Param | Type | Definition
152-
-----------|------------|-----------
153-
safebox | Safebox | An initialized Safebox object
154-
attachment | Attachment | An Attachment object - the file to upload to the SendSecure system
235+
Param | Type | Definition
236+
------------------|-------------------|-----------
237+
safebox | Safebox | An initialized Safebox object
238+
attachment | Attachment | An Attachment object - the file to upload to the SendSecure system
239+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
155240

156241
### Commit SafeBox
157242
```
@@ -160,19 +245,21 @@ CommitSafebox(safebox, cancellationToken)
160245
Finalizes the creation (commit) of the SafeBox on the SendSecure system.
161246
This actually "Sends" the SafeBox with all content and contact info previously specified.
162247

163-
Param | Type | Definition
164-
-----------|---------|-----------
165-
safebox | Safebox | A Safebox object already initialized, with security profile, recipient(s), subject and message already defined, and attachments already uploaded.
248+
Param | Type | Definition
249+
------------------|-------------------|-----------
250+
safebox | Safebox | A Safebox object already initialized, with security profile, recipient(s), subject and message already defined, and attachments already uploaded.
251+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
166252

167253
### Submit SafeBox
168254
```
169255
SubmitSafebox(safebox, cancellationToken)
170256
```
171257
This method is a high-level combo that initializes the SafeBox, uploads all attachments and commits the SafeBox.
172258

173-
Param | Type | Definition
174-
-----------|---------|-----------
175-
safebox | Safebox | A non-initialized Safebox object with security profile, recipient(s), subject, message and attachments (not yet uploaded) already defined.
259+
Param | Type | Definition
260+
------------------|-------------------|-----------
261+
safebox | Safebox | A non-initialized Safebox object with security profile, recipient(s), subject, message and attachments (not yet uploaded) already defined.
262+
cancellationToken | CancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation
176263

177264

178265
## Helper Modules

0 commit comments

Comments
 (0)