Skip to content

Commit c7309f3

Browse files
authored
Merge pull request #11 from SendSafely/v3.0.8
v3.0.8
2 parents a1ab3fc + 4ade922 commit c7309f3

11 files changed

Lines changed: 298 additions & 215 deletions

SendsafelyAPI/ClientAPI.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ namespace SendSafely
1515
public class ClientAPI
1616
{
1717
private Connection connection = null;
18+
private String locale = "en-US";
19+
20+
public ClientAPI() { }
21+
22+
public ClientAPI(string locale)
23+
{
24+
if (!String.IsNullOrEmpty(locale)) {
25+
this.locale = locale;
26+
}
27+
}
1828

1929
/// <summary>
2030
/// Initializes the API. This function must be called before the API can be used.
@@ -40,6 +50,7 @@ public void InitialSetup(string host, string apiKey, string apiSecret, WebProxy
4050
{
4151
StartupUtility su = new StartupUtility(host, apiSecret, apiKey, proxy);
4252
this.connection = su.GetConnectionObject();
53+
this.connection.setLocale(this.locale);
4354
}
4455

4556
/// <summary>
@@ -51,6 +62,7 @@ public void InitialSetup(string host, string apiKey, string apiSecret, WebProxy
5162
public void InitialSetup(string host, WebProxy proxy)
5263
{
5364
this.connection = new Connection(host, proxy);
65+
this.connection.setLocale(this.locale);
5466
}
5567

5668
/// <summary>
@@ -332,14 +344,15 @@ public void DeletePackage(String packageId)
332344
}
333345

334346
/// <summary>
335-
/// Deletes a temporary package, which is a package that has not yet been finalized.
347+
/// (Deprecated) Deletes a temporary package, which is a package that has not yet been finalized.
336348
/// </summary>
337349
/// <param name="packageId"> The unique package id of the package to be deleted.</param>
338350
/// <exception cref="APINotInitializedException">Thrown when the API has not been initialized.</exception>
339351
/// <exception cref="InvalidCredentialsException">Thrown when the API credentials are incorrect.</exception>
340352
/// <exception cref="ServerUnavailableException">Thrown when the API failed to connect to the server.</exception>
341353
/// <exception cref="InvalidPackageException">Thrown when a non-existent or invalid package ID is used.</exception>
342354
/// <exception cref="ActionFailedException">Will be thrown if the server returns an error message</exception>
355+
[Obsolete("This version of DeleteTempPackage is deprecated. Instead please use DeletePackage.")]
343356
public void DeleteTempPackage(String packageId)
344357
{
345358
EnforceInitialized();
@@ -713,7 +726,6 @@ public String FinalizePackage(String packageId, String keycode)
713726
/// <returns>
714727
/// A link to access the package. This link can be sent to the recipients.
715728
/// </returns>
716-
[Obsolete("This version of FinalizePackage is deprecated. Instead please use FinalizePackage which supports both allowReplyAll and notifyRecipients features.")]
717729
public String FinalizePackage(String packageId, String keycode, bool allowReplyAll)
718730
{
719731
EnforceInitialized();
@@ -1598,6 +1610,15 @@ public void SetOutlookVersion(String version)
15981610
{
15991611
this.connection.OutlookVersion = version;
16001612
}
1613+
1614+
/// <summary>
1615+
/// This method is intended for use by the SendSafely Outlook Plugin. Sets the name of the client application that is making the API request.
1616+
/// </summary>
1617+
/// <param name="requestAPI">Name of client application making the API request.</param>
1618+
public void setRequestAPI(String requestAPI)
1619+
{
1620+
this.connection.RequestAPI = requestAPI;
1621+
}
16011622

16021623
/// <summary>
16031624
/// This method is intended for use by the SendSafely Outlook Plugin. Starts the registration process. If a valid email is provided, a validation code will be sent to the SendSafely servers.

SendsafelyAPI/EnterpriseInformation.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class EnterpriseInformation
1212
private bool allowUndisclosedRecipients;
1313
private bool outlookBeta;
1414
private bool messageEncryption;
15+
private bool allowI18nAll;
1516

1617
public String Host
1718
{
@@ -43,5 +44,11 @@ public bool MessageEncryption
4344
set { messageEncryption = value; }
4445
}
4546

47+
public bool AllowI18nAll
48+
{
49+
get { return allowI18nAll; }
50+
set { allowI18nAll = value; }
51+
}
52+
4653
}
4754
}
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace SendSafely.Exceptions
6-
{
7-
/// <summary>
8-
/// Thrown when two factor authentication is required. The exception contains a ValidationToken parameter that must be used when validating the 2FA Code.
9-
/// </summary>
10-
[Serializable]
11-
public class TwoFactorAuthException : BaseException
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace SendSafely.Exceptions
6+
{
7+
/// <summary>
8+
/// Thrown when two factor authentication is required. The exception contains a ValidationToken parameter that must be used when validating the 2FA Code.
9+
/// </summary>
10+
[Serializable]
11+
public class TwoFactorAuthException : BaseException
1212
{
1313

1414
private String _validationToken;
15+
private String _twoFaType;
1516

16-
public TwoFactorAuthException(String validationToken)
17+
public TwoFactorAuthException(String validationToken, String twoFaType)
1718
{
18-
this._validationToken = validationToken;
19+
this._validationToken = validationToken;
20+
this._twoFaType = twoFaType;
1921
}
2022

2123
public String ValidationToken
2224
{
2325
get { return _validationToken; }
2426
set { _validationToken = value; }
25-
}
26-
}
27-
}
27+
}
28+
29+
public String TwoFaType
30+
{
31+
get { return _twoFaType; }
32+
set { _twoFaType = value; }
33+
}
34+
}
35+
}

SendsafelyAPI/Objects/Connection.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ internal class Connection
2424
private String apiKeyHeadervalue = "ss-api-key";
2525
private String apiTimestampHeadervalue = "ss-request-timestamp";
2626
private String apiSignatureHeadervalue = "ss-request-signature";
27+
private String acceptLanguageHeaderValue = "Accept-Language";
28+
private String apiIntegrationTypeHeadervalue = "ss-request-api";
2729
private String outlookVersion = null;
30+
private String requestAPI = null;
31+
private String locale = "en-US";
2832

2933
#region Constructors
3034

@@ -55,6 +59,12 @@ public String OutlookVersion
5559
set { outlookVersion = value; }
5660
}
5761

62+
public String RequestAPI
63+
{
64+
get { return requestAPI; }
65+
set { requestAPI = value; }
66+
}
67+
5868
public String ApiHost
5969
{
6070
get { return url; }
@@ -137,6 +147,7 @@ public HttpWebRequest GetRequestforFileUpload(Endpoint p, String boundary, Strin
137147

138148
wrReq.Headers.Add(apiSignatureHeadervalue, signature);
139149
wrReq.Headers.Add(apiTimestampHeadervalue, dateStr);
150+
wrReq.Headers.Add(acceptLanguageHeaderValue, locale);
140151

141152
wrReq.Method = p.Method.ToString();
142153
wrReq.ContentType = p.ContentType + "; boundary=" + boundary;
@@ -182,6 +193,12 @@ public Stream CallServer(Endpoint p, Object request)
182193
wrReq.Headers.Add(apiSignatureHeadervalue, signature);
183194
}
184195
wrReq.Headers.Add(apiTimestampHeadervalue, dateStr);
196+
wrReq.Headers.Add(acceptLanguageHeaderValue, locale);
197+
198+
if (!String.IsNullOrEmpty(requestAPI))
199+
{
200+
wrReq.Headers.Add(apiIntegrationTypeHeadervalue, requestAPI);
201+
}
185202

186203
if (proxy != null)
187204
{
@@ -199,6 +216,11 @@ public Stream CallServer(Endpoint p, Object request)
199216
return objStream;
200217
}
201218

219+
public void setLocale(String locale)
220+
{
221+
this.locale = locale;
222+
}
223+
202224
#endregion
203225

204226
#region Private Functions

SendsafelyAPI/Objects/EnterpriseInformationResponse.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class EnterpriseInformationResponse
1414
private bool _allowUndisclosedRecipients;
1515
private bool _outlookBeta;
1616
private bool _messageEncryption;
17+
private bool _allowI18nAll;
1718

1819
[JsonProperty(PropertyName = "host")]
1920
public String Host
@@ -49,5 +50,12 @@ public bool MessageEncryption
4950
get { return _messageEncryption; }
5051
set { _messageEncryption = value; }
5152
}
53+
54+
[JsonProperty(PropertyName = "allowI18nAll")]
55+
public bool AllowI18nAll
56+
{
57+
get { return _allowI18nAll; }
58+
set { _allowI18nAll = value; }
59+
}
5260
}
5361
}

SendsafelyAPI/Objects/GenerateAPIKeyResponse.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GenerateAPIKeyResponse
1414
private String _email;
1515
private String _apiKey;
1616
private String _apiSecret;
17+
private String _twoFaType;
1718

1819
[JsonProperty(PropertyName = "response")]
1920
internal APIResponse Response
@@ -49,5 +50,12 @@ public String APISecret
4950
get { return _apiSecret; }
5051
set { _apiSecret = value; }
5152
}
53+
54+
[JsonProperty(PropertyName = "twoFaType")]
55+
public String TwoFaType
56+
{
57+
get { return _twoFaType; }
58+
set { _twoFaType = value; }
59+
}
5260
}
5361
}

SendsafelyAPI/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("SendSafely Windows Client API")]
13-
[assembly: AssemblyCopyright("Copyright © 2020")]
13+
[assembly: AssemblyCopyright("Copyright © 2023")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,7 +32,7 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.7")]
36-
[assembly: AssemblyFileVersion("3.0.7")]
35+
[assembly: AssemblyVersion("3.0.8")]
36+
[assembly: AssemblyFileVersion("3.0.8")]
3737

3838
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("APITests")]

0 commit comments

Comments
 (0)