Skip to content

Commit 30e93e3

Browse files
authored
Merge pull request #143 from docusign/feature/add-stylecheck-to-CI-CD
Refactoring the code examples after adding linter to CI/CD
2 parents 6db66ed + 18986d0 commit 30e93e3

File tree

170 files changed

+1721
-1114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+1721
-1114
lines changed

.editorconfig

Lines changed: 495 additions & 0 deletions
Large diffs are not rendered by default.

DSHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ namespace DocuSign.CodeExamples.Common
77
using System.IO;
88
using System.Runtime.InteropServices;
99

10-
internal class DSHelper
10+
internal class DsHelper
1111
{
1212
internal static string PrepareFullPrivateKeyFilePath(string fileName)
1313
{
14-
const string DefaultRSAPrivateKeyFileName = "private.key";
14+
const string defaultRsaPrivateKeyFileName = "private.key";
1515

1616
var fileNameOnly = Path.GetFileName(fileName);
1717
if (string.IsNullOrEmpty(fileNameOnly))
1818
{
19-
fileNameOnly = DefaultRSAPrivateKeyFileName;
19+
fileNameOnly = defaultRsaPrivateKeyFileName;
2020
}
2121

2222
var filePath = Path.GetDirectoryName(fileName);
@@ -27,7 +27,7 @@ internal static string PrepareFullPrivateKeyFilePath(string fileName)
2727

2828
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && Directory.GetCurrentDirectory().Contains("bin"))
2929
{
30-
fileNameOnly = DefaultRSAPrivateKeyFileName;
30+
fileNameOnly = defaultRsaPrivateKeyFileName;
3131
filePath = Path.GetFullPath(filePath);
3232
}
3333

ExamplesAPIType.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,46 @@
22
// Copyright (c) DocuSign. All rights reserved.
33
// </copyright>
44

5-
using System.ComponentModel;
6-
75
namespace DocuSign.CodeExamples.Common
86
{
9-
public enum ExamplesAPIType
7+
using System.ComponentModel;
8+
9+
public enum ExamplesApiType
1010
{
11+
/// <summary>
12+
/// Rooms API
13+
/// </summary>
1114
[Description("reg")]
1215
Rooms = 0,
1316

17+
/// <summary>
18+
/// ESignature API
19+
/// </summary>
1420
[Description("eg")]
1521
ESignature = 1,
1622

23+
/// <summary>
24+
/// Click API
25+
/// </summary>
1726
[Description("ceg")]
1827
Click = 2,
1928

29+
/// <summary>
30+
/// Monitor API
31+
/// </summary>
2032
[Description("meg")]
2133
Monitor = 3,
2234

35+
/// <summary>
36+
/// Admin API
37+
/// </summary>
2338
[Description("aeg")]
2439
Admin = 4,
2540
}
2641

27-
public static class ExamplesAPITypeExtensions
42+
public static class ExamplesApiTypeExtensions
2843
{
29-
public static string ToKeywordString(this ExamplesAPIType val)
44+
public static string ToKeywordString(this ExamplesApiType val)
3045
{
3146
DescriptionAttribute[] attributes = (DescriptionAttribute[])val
3247
.GetType()

ExamplesApiTypeExtensions.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// <copyright file="ExamplesApiTypeExtensions.cs" company="DocuSign">
2+
// Copyright (c) DocuSign. All rights reserved.
3+
// </copyright>
4+
5+
namespace DocuSign.CodeExamples.Common
6+
{
7+
using System.ComponentModel;
8+
9+
public enum ExamplesApiType
10+
{
11+
/// <summary>
12+
/// Rooms API
13+
/// </summary>
14+
[Description("reg")]
15+
Rooms = 0,
16+
17+
/// <summary>
18+
/// ESignature API
19+
/// </summary>
20+
[Description("eg")]
21+
ESignature = 1,
22+
23+
/// <summary>
24+
/// Click API
25+
/// </summary>
26+
[Description("ceg")]
27+
Click = 2,
28+
29+
/// <summary>
30+
/// Monitor API
31+
/// </summary>
32+
[Description("meg")]
33+
Monitor = 3,
34+
35+
/// <summary>
36+
/// Admin API
37+
/// </summary>
38+
[Description("aeg")]
39+
Admin = 4,
40+
}
41+
42+
public static class ExamplesApiTypeExtensions
43+
{
44+
public static string ToKeywordString(this ExamplesApiType val)
45+
{
46+
DescriptionAttribute[] attributes = (DescriptionAttribute[])val
47+
.GetType()
48+
.GetField(val.ToString())
49+
.GetCustomAttributes(typeof(DescriptionAttribute), false);
50+
return attributes.Length > 0 ? attributes[0].Description : string.Empty;
51+
}
52+
}
53+
}

JWT-Console/JWT-Console.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21+
<Compile Include="..\ExamplesApiTypeExtensions.cs" Link="ExamplesApiTypeExtensions.cs" />
2122
<Compile Include="..\DSHelper.cs" Link="DSHelper.cs" />
22-
<Compile Include="..\ExamplesAPIType.cs" Link="ExamplesAPIType.cs" />
2323
<Compile Include="..\JWTAuth.cs" Link="JWTAuth.cs" />
2424
<Compile Include="..\launcher-csharp\eSignature\Examples\SigningViaEmail.cs" Link="SigningViaEmail.cs" />
2525
</ItemGroup>

JWT-Console/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ static void Main(string[] args)
2424
OAuthToken accessToken = null;
2525
try
2626
{
27-
accessToken = JWTAuth.AuthenticateWithJWT("ESignature", ConfigurationManager.AppSettings["ClientId"], ConfigurationManager.AppSettings["ImpersonatedUserId"],
28-
ConfigurationManager.AppSettings["AuthServer"], DSHelper.ReadFileContent(ConfigurationManager.AppSettings["PrivateKeyFile"]));
27+
accessToken = JwtAuth.AuthenticateWithJwt("ESignature", ConfigurationManager.AppSettings["ClientId"], ConfigurationManager.AppSettings["ImpersonatedUserId"],
28+
ConfigurationManager.AppSettings["AuthServer"], DsHelper.ReadFileContent(ConfigurationManager.AppSettings["PrivateKeyFile"]));
2929
}
3030
catch (ApiException apiExp)
3131
{

JWTAuth.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ namespace DocuSign.CodeExamples.Authentication
1010
using DocuSign.eSign.Client;
1111
using static DocuSign.eSign.Client.Auth.OAuth;
1212

13-
public static class JWTAuth
13+
public static class JwtAuth
1414
{
1515
/// <summary>
1616
/// Uses Json Web Token (JWT) Authentication Method to obtain the necessary information needed to make API calls.
1717
/// </summary>
1818
/// <returns>Auth token needed for API calls</returns>
19-
public static OAuthToken AuthenticateWithJWT(string api, string clientId, string impersonatedUserId, string authServer, byte[] privateKeyBytes)
19+
public static OAuthToken AuthenticateWithJwt(string api, string clientId, string impersonatedUserId, string authServer, byte[] privateKeyBytes)
2020
{
2121
var docuSignClient = new DocuSignClient();
22-
var apiType = Enum.Parse<ExamplesAPIType>(api);
22+
var apiType = Enum.Parse<ExamplesApiType>(api);
2323
var scopes = new List<string>
2424
{
2525
"signature",
2626
"impersonation",
2727
};
28-
if (apiType == ExamplesAPIType.Rooms)
28+
if (apiType == ExamplesApiType.Rooms)
2929
{
3030
scopes.AddRange(new List<string>
3131
{
@@ -41,7 +41,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
4141
});
4242
}
4343

44-
if (apiType == ExamplesAPIType.Click)
44+
if (apiType == ExamplesApiType.Click)
4545
{
4646
scopes.AddRange(new List<string>
4747
{
@@ -50,7 +50,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
5050
});
5151
}
5252

53-
if (apiType == ExamplesAPIType.Monitor)
53+
if (apiType == ExamplesApiType.Monitor)
5454
{
5555
scopes.AddRange(new List<string>
5656
{
@@ -59,7 +59,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
5959
});
6060
}
6161

62-
if (apiType == ExamplesAPIType.Admin)
62+
if (apiType == ExamplesApiType.Admin)
6363
{
6464
scopes.AddRange(new List<string>
6565
{
@@ -75,7 +75,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
7575
"asset_group_account_read",
7676
"asset_group_account_clone_write",
7777
"asset_group_account_clone_read",
78-
});
78+
});
7979
}
8080

8181
return docuSignClient.RequestJWTUserToken(

Quick_ACG/Common/RequestItemService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public class RequestItemsService : IRequestItemsService
1313
private readonly IHttpContextAccessor _httpContextAccessor;
1414
private readonly IMemoryCache _cache;
1515
private readonly string _id;
16-
public DocuSignClient _docuSignClient { get; private set; }
16+
public DocuSignClient DocuSignClient { get; private set; }
1717

1818
public RequestItemsService(IHttpContextAccessor httpContextAccessor, IMemoryCache cache, IConfiguration configuration)
1919
{
2020
_httpContextAccessor = httpContextAccessor;
2121
_cache = cache;
2222
Status = "sent";
23-
_docuSignClient ??= new DocuSignClient();
23+
DocuSignClient ??= new DocuSignClient();
2424
var identity = httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity;
2525

2626
if (identity != null && identity.IsAuthenticated)

Quick_ACG/Quick_ACG.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<Compile Include="..\ExamplesAPIType.cs" Link="ExamplesAPIType.cs" />
20+
<Compile Include="..\ExamplesApiTypeExtensions.cs" Link="ExamplesApiTypeExtensions.cs" />
2121
<Compile Include="..\launcher-csharp\Common\SetViewBagAttribute.cs" Link="Common\SetViewBagAttribute.cs" />
2222
<Compile Include="..\launcher-csharp\EmbeddedSigningCeremony.cs" Link="EmbeddedSigningCeremony.cs" />
2323
<Compile Include="..\launcher-csharp\eSignature\Controllers\EmbeddedSigningCeremony.cs" Link="eSignature\Controllers\EmbeddedSigningCeremony.cs" />

Quick_ACG/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public void ConfigureServices(IServiceCollection services)
4747
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
4848
options.CheckConsentNeeded = context => true;
4949
});
50-
DSConfiguration config = new DSConfiguration();
50+
DsConfiguration config = new DsConfiguration();
5151

5252
Configuration.Bind("DocuSign", config);
53-
config.QuickACG = "true";
53+
config.QuickAcg = "true";
5454

5555
services.AddSingleton(config);
5656
services.AddSingleton(new LauncherTexts(config, Configuration));

0 commit comments

Comments
 (0)