-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.mustache
More file actions
98 lines (83 loc) · 2.68 KB
/
Configuration.mustache
File metadata and controls
98 lines (83 loc) · 2.68 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Aspose.BarCode.Cloud.Sdk.Api
{
/// <summary>
/// Represents a set of configuration settings
/// </summary>
public class Configuration
{
/// <summary>
/// Default constructor
/// </summary>
public Configuration()
{
ApiBaseUrl = "https://{{host}}";
DebugMode = false;
ApiVersion = "{{appVersion}}";
AuthType = AuthType.JWT;
TokenUrl = {{#authMethods}}{{#-first}}"{{tokenUrl}}"{{/-first}}{{/authMethods}};
DefaultHeaders = new Dictionary<string, string>();
}
/// <summary>
/// Aspose Cloud API base URL.
/// </summary>
public string ApiBaseUrl { get; set; }
/// <summary>
/// Aspose Cloud API auth URL.
/// </summary>
public string TokenUrl { get; set; }
/// <summary>
/// Gets or sets the Client Secret.
/// </summary>
public string ClientSecret { get; set; }
/// <summary>
/// Gets or sets the Client Id.
/// </summary>
public string ClientId { get; set; }
/// <summary>
/// Gets or sets the Jwt token.
/// If set the library would handle auth internally
/// </summary>
public string JwtToken
{
get => _jwtToken;
set
{
if (string.IsNullOrEmpty(value))
{
return;
}
AuthType = AuthType.ExternalAuth;
_jwtToken = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether debug mode.
/// </summary>
public bool DebugMode { get; set; }
/// <summary>
/// Authentication type.
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public AuthType AuthType { get; private set; }
/// <summary>
/// Get or sets Cloud API Version.
/// </summary>
public string ApiVersion { get; }
/// <summary>
/// Gets or sets HTTP headers
/// </summary>
public Dictionary<string, string> DefaultHeaders { get; set; }
/// <summary>
/// Get API root url
/// </summary>
public string GetApiRootUrl()
{
string result = ApiBaseUrl + "/v" + ApiVersion;
return result.EndsWith("/", StringComparison.InvariantCulture) ? result.Substring(0, result.Length - 1) : result;
}
private string _jwtToken;
}
}