Skip to content

Commit 3270be9

Browse files
committed
Updated sources
1 parent 336040f commit 3270be9

5 files changed

Lines changed: 217 additions & 4 deletions

File tree

src/GroupDocs.Conversion.Cloud.Sdk.Test/GroupDocs.Conversion.Cloud.Sdk.Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
12-
<PackageReference Include="NUnit" Version="3.9.0" />
12+
<PackageReference Include="NUnit" Version="3.13.2" />
13+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
1314
</ItemGroup>
1415
<ItemGroup>
1516
<ProjectReference Include="..\GroupDocs.Conversion.Cloud.Sdk\GroupDocs.Conversion.Cloud.Sdk.csproj" />
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd" file="LicenseApi.cs">
3+
// Copyright (c) 2003-2021 Aspose Pty Ltd
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace GroupDocs.Conversion.Cloud.Sdk.Api
27+
{
28+
using System.IO;
29+
using System.Collections.Generic;
30+
using System.Text.RegularExpressions;
31+
using GroupDocs.Conversion.Cloud.Sdk.Client;
32+
using GroupDocs.Conversion.Cloud.Sdk.Client.RequestHandlers;
33+
using GroupDocs.Conversion.Cloud.Sdk.Model;
34+
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
35+
36+
/// <summary>
37+
/// GroupDocs.Conversion Cloud API.
38+
/// </summary>
39+
public class LicenseApi
40+
{
41+
private readonly ApiInvoker apiInvoker;
42+
private readonly Configuration configuration;
43+
44+
/// <summary>
45+
/// Initializes a new instance of the <see cref="LicenseApi"/> class.
46+
/// </summary>
47+
/// <param name="appSid">Application identifier (App SID)</param>
48+
/// <param name="appKey">Application private key (App Key)</param>
49+
public LicenseApi(string appSid, string appKey)
50+
: this(new Configuration(appSid, appKey))
51+
{
52+
}
53+
54+
/// <summary>
55+
/// Initializes a new instance of the <see cref="LicenseApi"/> class.
56+
/// </summary>
57+
/// <param name="configuration">Configuration settings</param>
58+
public LicenseApi(Configuration configuration)
59+
{
60+
this.configuration = configuration;
61+
62+
var requestHandlers = new List<IRequestHandler>();
63+
requestHandlers.Add(new AuthRequestHandler(this.configuration));
64+
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
65+
requestHandlers.Add(new ApiExceptionRequestHandler());
66+
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
67+
}
68+
69+
/// <summary>
70+
/// Get license consumption
71+
/// </summary>
72+
/// <returns><see cref="ConsumptionResult"/></returns>
73+
public ConsumptionResult GetConsumptionCredit()
74+
{
75+
// create path and map variables
76+
var resourcePath = this.configuration.GetServerUrl() + "/conversion/consumption";
77+
resourcePath = Regex
78+
.Replace(resourcePath, "\\*", string.Empty)
79+
.Replace("&amp;", "&")
80+
.Replace("/?", "?");
81+
82+
var response = this.apiInvoker.InvokeApi(
83+
resourcePath,
84+
"GET",
85+
null,
86+
null,
87+
null);
88+
89+
if (response != null)
90+
{
91+
return (ConsumptionResult)SerializationHelper.Deserialize(response, typeof(ConsumptionResult));
92+
}
93+
94+
return null;
95+
}
96+
}
97+
}

src/GroupDocs.Conversion.Cloud.Sdk/GroupDocs.Conversion.Cloud.Sdk.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;net20</TargetFrameworks>
5-
<AssemblyVersion>21.10.0.0</AssemblyVersion>
6-
<FileVersion>21.10.0.0</FileVersion>
7-
<Version>21.10.0</Version>
5+
<AssemblyVersion>21.12.0.0</AssemblyVersion>
6+
<FileVersion>21.12.0.0</FileVersion>
7+
<Version>21.12.0</Version>
88
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
99
<Company>GroupDocs</Company>
1010
<Authors>GroupDocs Product Team</Authors>

src/GroupDocs.Conversion.Cloud.Sdk/GroupDocs.Conversion.Cloud.Sdk.xml

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd" file="ConsumptionResult.cs">
3+
// Copyright (c) 2003-2021 Aspose Pty Ltd
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace GroupDocs.Conversion.Cloud.Sdk.Model
27+
{
28+
using System;
29+
using System.Collections;
30+
using System.Collections.Generic;
31+
using System.Runtime.Serialization;
32+
using System.Text;
33+
using Newtonsoft.Json;
34+
using Newtonsoft.Json.Converters;
35+
36+
/// <summary>
37+
/// Metered license consumption information
38+
/// </summary>
39+
public class ConsumptionResult
40+
{
41+
/// <summary>
42+
/// Amount of used credits
43+
/// </summary>
44+
public decimal? Credit { get; set; }
45+
46+
/// <summary>
47+
/// Amount of MBs processed
48+
/// </summary>
49+
public decimal? Quantity { get; set; }
50+
51+
/// <summary>
52+
/// Get the string presentation of the object
53+
/// </summary>
54+
/// <returns>String presentation of the object</returns>
55+
public override string ToString()
56+
{
57+
var sb = new StringBuilder();
58+
sb.Append("class ConsumptionResult {\n");
59+
sb.Append(" Credit: ").Append(this.Credit).Append("\n");
60+
sb.Append(" Quantity: ").Append(this.Quantity).Append("\n");
61+
sb.Append("}\n");
62+
return sb.ToString();
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)