Skip to content

Commit 571236a

Browse files
committed
Apply ReSharper code formatting profile
1 parent 7a6985e commit 571236a

File tree

5 files changed

+87
-60
lines changed

5 files changed

+87
-60
lines changed

src/Draftable.CompareAPI.Client/Export.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.Serialization;
2+
23
using JetBrains.Annotations;
34

45

@@ -7,7 +8,8 @@ namespace Draftable.CompareAPI.Client
78
/// <summary>
89
/// Represents an export created via the Draftable API.
910
/// </summary>
10-
[PublicAPI, DataContract(Name = "export")]
11+
[PublicAPI]
12+
[DataContract(Name = "export")]
1113
public class Export
1214
{
1315
/// <summary>
@@ -65,9 +67,10 @@ public class Export
6567
public bool? Failed { get; private set; }
6668

6769
/// <summary>
68-
/// Error message for failed exports. This is set to null for successful exports.
70+
/// Error message for failed exports. This is set to null for successful exports.
6971
/// </summary>
70-
[DataMember(Name = "error_message"), CanBeNull]
72+
[DataMember(Name = "error_message")]
73+
[CanBeNull]
7174
public string ErrorMessage { get; private set; }
7275
}
7376
}
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,63 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Net.Http;
4+
45
using Draftable.CompareAPI.Client.Internal;
6+
57
using JetBrains.Annotations;
8+
69
using Newtonsoft.Json;
710

11+
812
namespace Draftable.CompareAPI.Client
913
{
1014
public class Exports : IDisposable
1115
{
1216
private readonly RestApiClient _client;
1317
private readonly URLs _urls;
1418

15-
public Exports(
16-
[NotNull] string authToken,
17-
[NotNull] string baseUrl,
18-
[CanBeNull, InstantHandle] Action<HttpClientHandler> httpClientHandlerConfigurator)
19+
public Exports([NotNull] string authToken,
20+
[NotNull] string baseUrl,
21+
[CanBeNull] [InstantHandle] Action<HttpClientHandler> httpClientHandlerConfigurator)
1922
{
2023
_urls = new URLs(baseUrl);
2124
_client = new RestApiClient(authToken, httpClientHandlerConfigurator);
2225
}
2326

24-
[PublicAPI, Pure, NotNull]
27+
[PublicAPI]
28+
[Pure]
29+
[NotNull]
2530
public Export Create(string comparisonId, string mode, bool icludeCoverPage = true)
2631
{
2732
try
2833
{
29-
var response = _client.Post(
30-
_urls.Exports,
31-
data: new Dictionary<string, string>
32-
{
33-
{"comparison", comparisonId},
34-
{"kind", mode},
35-
{"include_cover_page", icludeCoverPage.ToString()}
36-
});
34+
var response = _client.Post(_urls.Exports,
35+
data: new Dictionary<string, string>
36+
{
37+
{"comparison", comparisonId},
38+
{"kind", mode},
39+
{"include_cover_page", icludeCoverPage.ToString()}
40+
});
3741
return DeserializeExport(response);
3842
}
3943
catch (RestApiClient.UnexpectedResponseException ex)
4044
{
41-
throw Comparisons.BadRequestException.For(ex) ?? Comparisons.InvalidCredentialsException.For(ex) ?? new UnknownResponseException(ex);
45+
throw Comparisons.BadRequestException.For(ex) ?? Comparisons.InvalidCredentialsException.For(ex) ??
46+
new UnknownResponseException(ex);
4247
}
4348
}
4449

45-
46-
[PublicAPI, Pure, NotNull]
50+
[PublicAPI]
51+
[Pure]
52+
[NotNull]
4753
public Export Get(string exportId)
4854
{
49-
var resp =_client.Get(_urls.Export(exportId));
55+
var resp = _client.Get(_urls.Export(exportId));
5056
return DeserializeExport(resp);
5157
}
5258

53-
[Pure, NotNull]
59+
[Pure]
60+
[NotNull]
5461
private static Export DeserializeExport([NotNull] string jsonExport)
5562
{
5663
try
@@ -67,9 +74,6 @@ private static Export DeserializeExport([NotNull] string jsonExport)
6774
}
6875
}
6976

70-
public void Dispose()
71-
{
72-
_client.Dispose();
73-
}
77+
public void Dispose() { _client.Dispose(); }
7478
}
7579
}
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
using JetBrains.Annotations;
22

3+
34
namespace Draftable.CompareAPI.Client
45
{
56
public class URLs
67
{
78
[NotNull] private readonly string _baseUrl;
89

9-
public URLs([NotNull] string baseURL)
10-
{
11-
_baseUrl = baseURL.EndsWith(@"/") ? baseURL.TrimEnd('/') : baseURL;
12-
}
10+
public URLs([NotNull] string baseURL) { _baseUrl = baseURL.EndsWith(@"/") ? baseURL.TrimEnd('/') : baseURL; }
1311

1412
[NotNull] public string Comparisons => _baseUrl + "/comparisons";
1513
[NotNull] public string Exports => _baseUrl + "/exports";
1614

17-
[NotNull] public string Comparison([NotNull] string identifier) => $"{Comparisons}/{identifier}";
18-
[NotNull] public string Export([NotNull] string identifier) => $"{Exports}/{identifier}";
15+
[NotNull]
16+
public string Comparison([NotNull] string identifier) { return $"{Comparisons}/{identifier}"; }
1917

20-
[NotNull] public string ComparisonViewer([NotNull] string accountId, [NotNull] string identifier)
21-
=> $"{Comparisons}/viewer/{accountId}/{identifier}";
18+
[NotNull]
19+
public string Export([NotNull] string identifier) { return $"{Exports}/{identifier}"; }
20+
21+
[NotNull]
22+
public string ComparisonViewer([NotNull] string accountId, [NotNull] string identifier)
23+
{
24+
return $"{Comparisons}/viewer/{accountId}/{identifier}";
25+
}
2226
}
2327
}

src/Draftable.CompareAPI.Client/UnknownResponseException.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,56 @@
11
using System;
2+
23
using Draftable.CompareAPI.Client.Internal;
4+
35
using JetBrains.Annotations;
6+
47
using Newtonsoft.Json;
58

9+
610
namespace Draftable.CompareAPI.Client
711
{
812
/// <summary>
9-
/// Thrown when the response received from the server is unrecognized. This should not occur in regular use of the API, but is possible if for example you have a misconfigured proxy server.
13+
/// Thrown when the response received from the server is unrecognized. This should not occur in regular use of the API,
14+
/// but is possible if for example you have a misconfigured proxy server.
1015
/// </summary>
1116
/// <remarks>
12-
/// If requests made to the API are not being intercepted, an <see cref="UnknownResponseException"/> indicates an error in this client library. Please contact support@draftable.com if this is the case.
17+
/// If requests made to the API are not being intercepted, an <see cref="UnknownResponseException" /> indicates an
18+
/// error in this client library. Please contact support@draftable.com if this is the case.
1319
/// </remarks>
1420
[PublicAPI]
1521
public class UnknownResponseException : Comparisons.RequestExceptionBase
1622
{
1723
/// <summary>
18-
/// The content of the response.
24+
/// The content of the response.
1925
/// </summary>
20-
[PublicAPI, NotNull] public string ResponseContent { get; }
26+
[PublicAPI]
27+
[NotNull]
28+
public string ResponseContent { get; }
2129

2230
internal UnknownResponseException([NotNull] RestApiClient.UnexpectedResponseException ex)
23-
: base("An unknown response was received. Contact support@draftable.com for assistance, or open an issue on GitHub.", ex)
31+
: base(
32+
"An unknown response was received. Contact support@draftable.com for assistance, or open an issue on GitHub.",
33+
ex)
2434
{
2535
ResponseContent = ex.ResponseContent;
2636
}
2737

28-
internal UnknownResponseException([NotNull] string responseContent, [NotNull] string message, [NotNull] JsonException ex)
29-
: base($"{message}\nA deserialization error indicates an issue in this client library, or the comparison API. Contact support@draftable.com for assistance, or open an issue on GitHub.", ex)
38+
internal UnknownResponseException([NotNull] string responseContent,
39+
[NotNull] string message,
40+
[NotNull] JsonException ex)
41+
: base(
42+
$"{message}\nA deserialization error indicates an issue in this client library, or the comparison API. Contact support@draftable.com for assistance, or open an issue on GitHub.",
43+
ex)
3044
{
3145
ResponseContent = responseContent;
3246
}
3347

34-
internal UnknownResponseException([NotNull] string responseContent, [NotNull] string message, [NotNull] NullReferenceException ex)
35-
: base($"{message}\nA deserialization error indicates an issue in this client library, or the comparison API. Contact support@draftable.com for assistance, or open an issue on GitHub.", ex)
48+
internal UnknownResponseException([NotNull] string responseContent,
49+
[NotNull] string message,
50+
[NotNull] NullReferenceException ex)
51+
: base(
52+
$"{message}\nA deserialization error indicates an issue in this client library, or the comparison API. Contact support@draftable.com for assistance, or open an issue on GitHub.",
53+
ex)
3654
{
3755
ResponseContent = responseContent;
3856
}

src/Sample.Core/ExportsSample.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
using System.IO;
44
using System.Linq;
55
using System.Net;
6+
67
using Draftable.CompareAPI.Client;
8+
79
using Newtonsoft.Json;
810

11+
912
namespace Sample.Core
1013
{
1114
public class ExportsSample
@@ -30,10 +33,11 @@ public void Run()
3033
using (var exportClient = new Exports(Token, KnownURLs.CloudBaseURL, null))
3134
{
3235
// tuple here is: comparisonId,mode,exportId
33-
var exportInfos = StartExportsAndBuildInfosList(comparisonsCreated.Select(c => c.Identifier), exportClient);
36+
var exportInfos =
37+
StartExportsAndBuildInfosList(comparisonsCreated.Select(c => c.Identifier), exportClient);
3438
foreach (var exportInfo in exportInfos)
3539
{
36-
var exportRetrieved =exportClient.Get(exportInfo.Item3);
40+
var exportRetrieved = exportClient.Get(exportInfo.Item3);
3741
var outputPath = Path.Combine(ExportsDir, $"{exportInfo.Item1}_{exportInfo.Item2}.pdf");
3842
if (string.IsNullOrEmpty(exportRetrieved.Url))
3943
{
@@ -47,6 +51,7 @@ public void Run()
4751
}
4852
}
4953
}
54+
5055
return;
5156
}
5257
catch (Exception e)
@@ -56,15 +61,10 @@ public void Run()
5661
}
5762
}
5863

59-
private static List<Tuple<string, string, string>> StartExportsAndBuildInfosList(IEnumerable<string> compareIds, Exports exportClient)
64+
private static List<Tuple<string, string, string>> StartExportsAndBuildInfosList(IEnumerable<string> compareIds,
65+
Exports exportClient)
6066
{
61-
var allModes = new[]
62-
{
63-
ExportKinds.Left,
64-
ExportKinds.Right,
65-
ExportKinds.SinglePage,
66-
ExportKinds.Combined,
67-
};
67+
var allModes = new[] {ExportKinds.Left, ExportKinds.Right, ExportKinds.SinglePage, ExportKinds.Combined};
6868
var exportInfos = new List<Tuple<string, string, string>>();
6969
foreach (var cid in compareIds)
7070
{
@@ -88,12 +88,10 @@ private static List<Comparison> CreateComparisons(Tuple<string, string>[] filePa
8888
foreach (var pair in filePairs)
8989
{
9090
var identifier = Comparisons.GenerateIdentifier();
91-
var newComparison = comparisons.Create(
92-
Comparisons.Side.FromFile(pair.Item1),
93-
Comparisons.Side.FromFile(pair.Item2),
94-
identifier: identifier,
95-
expires: TimeSpan.FromMinutes(100)
96-
);
91+
var newComparison = comparisons.Create(Comparisons.Side.FromFile(pair.Item1),
92+
Comparisons.Side.FromFile(pair.Item2),
93+
identifier,
94+
expires: TimeSpan.FromMinutes(100));
9795
comparisonsCreated.Add(newComparison);
9896
}
9997
}
@@ -110,9 +108,9 @@ private static Tuple<string, string>[] BuildInputPairs()
110108
{
111109
new Tuple<string, string>("equations-1.pdf", "equations-2.pdf"),
112110
new Tuple<string, string>("rotated-left.pdf", "rotated-right.pdf"),
113-
new Tuple<string, string>("eq2-left.pdf", "eq2-right.pdf"),
111+
new Tuple<string, string>("eq2-left.pdf", "eq2-right.pdf")
114112
}.Select(t => new Tuple<string, string>(basicPath + t.Item1, basicPath + t.Item2))
115-
.ToArray();
113+
.ToArray();
116114
return filePairs;
117115
}
118116
}

0 commit comments

Comments
 (0)