forked from alpacahq/alpaca-trade-api-csharp
/
SecretKey.cs
48 lines (43 loc) · 1.44 KB
/
SecretKey.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
namespace Alpaca.Markets;
/// <summary>
/// Secret API key for Alpaca API authentication.
/// </summary>
public sealed class SecretKey : SecurityKey
{
/// <summary>
/// Creates a new instance of <see cref="SecretKey"/> object.
/// </summary>
/// <param name="keyId">Secret API key identifier.</param>
/// <param name="value">Secret API key value.</param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="keyId"/> or <paramref name="value"/> argument is <c>null</c>.
/// </exception>
public SecretKey(
String keyId,
String value)
: base(value) =>
KeyId = keyId.EnsureNotNull();
private String KeyId { get; }
internal override IEnumerable<KeyValuePair<String, String>> GetAuthenticationHeaders()
{
// ReSharper disable StringLiteralTypo
yield return new KeyValuePair<String, String>(
"APCA-API-KEY-ID", KeyId);
yield return new KeyValuePair<String, String>(
"APCA-API-SECRET-KEY", Value);
// ReSharper restore StringLiteralTypo
}
internal override JsonAuthRequest.JsonData GetAuthenticationData() =>
new()
{
KeyId = KeyId,
SecretKey = Value
};
internal override JsonAuthentication GetAuthentication() =>
new()
{
Action = JsonAction.StreamingAuthenticate,
SecretKey = Value,
KeyId = KeyId
};
}