Skip to content

Commit

Permalink
v3.0.7
Browse files Browse the repository at this point in the history
- Pagining enhancements to multiple methods
- Add recipient notification to FinalizePackage
- Addresses #7
  • Loading branch information
SendSafely-GitHub committed Nov 12, 2020
1 parent 417c55b commit 00fefdb
Show file tree
Hide file tree
Showing 16 changed files with 624 additions and 234 deletions.
166 changes: 158 additions & 8 deletions SendsafelyAPI/ClientAPI.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SendsafelyAPI/Objects/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private String generateUserAgent()

private String CreateSignature(String privateKey, String apiKey, String uri, String dateStr, String requestData)
{
String content = apiKey + uri + dateStr + requestData;
String content = apiKey + uri.Split('?')[0] + dateStr + requestData;
Logger.Log("-" + content + "-");
CryptUtility cu = new CryptUtility();
return cu.createSignature(privateKey, content);
Expand Down
2 changes: 2 additions & 0 deletions SendsafelyAPI/Objects/ConnectionStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class ConnectionStrings
{"receivedPackages", new Endpoint("/api/v2.0/package/received/", HTTPMethod.GET, "application/json")},
{"archivedPackages", new Endpoint("/api/v2.0/package/archived/", HTTPMethod.GET, "application/json")},
{"organizationPackages", new Endpoint("/api/v2.0/package/organization/", HTTPMethod.POST, "application/json")},
{"organizationPackagesSearch", new Endpoint("/api/v2.0/package/organization/search", HTTPMethod.POST, "application/json") },
{"addRecipient", new Endpoint("/api/v2.0/package/{packageId}/recipient/", HTTPMethod.PUT, "application/json")},
{"addRecipientPhonenumber", new Endpoint("/api/v2.0/package/{packageId}/recipient/{recipientId}/", HTTPMethod.POST, "application/json")},
{"createFileId", new Endpoint("/api/v2.0/package/{packageId}/file/", HTTPMethod.PUT, "application/json")},
Expand Down Expand Up @@ -73,6 +74,7 @@ internal class ConnectionStrings
{"addContactGroupsToPackage", new Endpoint("/api/v2.0/package/{packageId}/group/{groupId}/", HTTPMethod.PUT, "application/json")},
{"removeContactGroupsToPackage", new Endpoint("/api/v2.0/package/{packageId}/group/{groupId}/", HTTPMethod.DELETE, "application/json")},
{"removeRecipient", new Endpoint("/api/v2.0/package/{packageId}/recipient/{recipientId}/", HTTPMethod.DELETE, "application/json")},
{"notifyRecipients", new Endpoint("/api/v2.0/package/{packageId}/notify", HTTPMethod.POST, "application/json") },
};
}
}
8 changes: 4 additions & 4 deletions SendsafelyAPI/Objects/DirectoryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ public class DirectoryResponse
private ICollection<DirectoryResponse> subDirectories = new Collection<DirectoryResponse>();

[JsonProperty(PropertyName = "directoryId")]
internal String DirectoryId
public String DirectoryId
{
get { return directoryId; }
set { directoryId = value; }
}
[JsonProperty(PropertyName = "name")]
internal String Name
public String Name
{
get { return name; }
set { name = value; }
}
[JsonProperty(PropertyName = "created")]
internal DateTime Created
public DateTime Created
{
get { return created; }
set { created = value; }
}
[JsonProperty(PropertyName = "subDirectories")]
internal ICollection<DirectoryResponse> SubDirectories
public ICollection<DirectoryResponse> SubDirectories
{
get { return subDirectories; }
set { subDirectories = value; }
Expand Down
5 changes: 2 additions & 3 deletions SendsafelyAPI/Objects/GetOrganizationPakagesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SendSafely.Objects
{
class GetOrganizationPakagesResponse : StandardResponse
class GetOrganizationPakagesResponse : PaginationResponse
{

List<PackageDTO> packages;
Expand All @@ -18,13 +18,12 @@ public List<PackageDTO> Packages
set { packages = value; }
}

[Obsolete("capped is deprecated, please use Pagination property instead)",false)]
[JsonProperty(PropertyName = "capped")]
public bool Capped
{
get { return capped; }
set { capped = value; }
}


}
}
11 changes: 2 additions & 9 deletions SendsafelyAPI/Objects/GetPackagesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@
namespace SendSafely.Objects
{
[JsonObject(MemberSerialization.OptIn)]
class GetPackagesResponse
class GetPackagesResponse : PaginationResponse
{
private APIResponse _response;

private List<PackageDTO> _packages;

[JsonProperty(PropertyName = "response")]
internal APIResponse Response
{
get { return _response; }
set { _response = value; }
}

[JsonProperty(PropertyName = "packages")]
public List<PackageDTO> Packages
{
Expand Down
2 changes: 1 addition & 1 deletion SendsafelyAPI/Objects/Keypair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SendSafely.Objects
{
class Keypair
public class Keypair
{
public String PrivateKey { get; set; }
public String PublicKey { get; set; }
Expand Down
16 changes: 16 additions & 0 deletions SendsafelyAPI/Objects/NotifyPackageRecipientsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace SendSafely.Objects
{
[JsonObject(MemberSerialization.OptIn)]
class NotifyPackageRecipientsRequest
{
private String _keycode;

[JsonProperty(PropertyName = "keycode")]
public String Keycode { get; set; }
}
}
20 changes: 20 additions & 0 deletions SendsafelyAPI/Objects/PaginationResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace SendSafely.Objects
{
class PaginationResponse : StandardResponse
{

private Dictionary<String, String> _pagination;

[JsonProperty(PropertyName = "pagination")]
internal Dictionary<String, String> Pagination
{
get { return _pagination; }
set { _pagination = value; }
}
}
}
2 changes: 1 addition & 1 deletion SendsafelyAPI/Objects/ProgressStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ProgressStream(Stream inner, ISendSafelyProgress progress, String prefix,
this._inner = inner;
this._progress = progress;
this._prefix = prefix;
this._fileSize = size;
this._fileSize = size < 1024 ? size * 1024 : size; // multiple file size by 1024 if fileSize is less than 1024 bytes.
this._readSoFar = 0;
this._offset = offset;
_lastProgressCallback = DateTime.Now.Ticks - UPDATE_FREQUENCY; // Make sure we trigger it the first time.
Expand Down
46 changes: 46 additions & 0 deletions SendsafelyAPI/PaginatedList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace SendSafely
{
[JsonObject(MemberSerialization.OptIn)]
public class PaginatedList<T> : List<T>
{
private int _rowIndex = 0;
private int _rowsReturned;
private int _nextRowIndex;
private bool _rowsCapped;

[JsonProperty(PropertyName = "rowIndex")]
public int RowIndex
{
get { return _rowIndex; }
set { _rowIndex = value; }
}

[JsonProperty(PropertyName = "rowsReturned")]
public int RowsReturned
{
get { return _rowsReturned; }
set { _rowsReturned = value; }
}

[JsonProperty(PropertyName = "nextRowIndex")]
public int NextRowIndex
{
get { return _nextRowIndex; }
set { _nextRowIndex = value; }
}

[JsonProperty(PropertyName = "rowsCapped")]
public bool RowsCapped
{
get { return _rowsCapped; }
set { _rowsCapped = value; }
}
}


}
4 changes: 2 additions & 2 deletions SendsafelyAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.6")]
[assembly: AssemblyFileVersion("3.0.6")]
[assembly: AssemblyVersion("3.0.7")]
[assembly: AssemblyFileVersion("3.0.7")]

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

0 comments on commit 00fefdb

Please sign in to comment.