Skip to content

Commit 9875aa4

Browse files
Automatically update Dotnet SDK
1 parent 8889feb commit 9875aa4

68 files changed

Lines changed: 3603 additions & 85 deletions

File tree

Some content is hidden

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

src/TrophyApi.sln

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrophyApi", "TrophyApi\TrophyApi.csproj", "{27F613F3-7312-4146-8524-871520F2F04A}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrophyApi", "TrophyApi\TrophyApi.csproj", "{95AAA0F9-72C4-4166-83A9-72FB823EA049}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrophyApi.Test", "TrophyApi.Test\TrophyApi.Test.csproj", "{E4E371AE-9A69-4408-93DE-706DD2FAA0C3}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrophyApi.Test", "TrophyApi.Test\TrophyApi.Test.csproj", "{A14AC93F-8AAF-4F17-AAB3-16E56FD1588A}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,13 +16,13 @@ Global
1616
HideSolutionNode = FALSE
1717
EndGlobalSection
1818
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19-
{27F613F3-7312-4146-8524-871520F2F04A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20-
{27F613F3-7312-4146-8524-871520F2F04A}.Debug|Any CPU.Build.0 = Debug|Any CPU
21-
{27F613F3-7312-4146-8524-871520F2F04A}.Release|Any CPU.ActiveCfg = Release|Any CPU
22-
{27F613F3-7312-4146-8524-871520F2F04A}.Release|Any CPU.Build.0 = Release|Any CPU
23-
{E4E371AE-9A69-4408-93DE-706DD2FAA0C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24-
{E4E371AE-9A69-4408-93DE-706DD2FAA0C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
25-
{E4E371AE-9A69-4408-93DE-706DD2FAA0C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
26-
{E4E371AE-9A69-4408-93DE-706DD2FAA0C3}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{95AAA0F9-72C4-4166-83A9-72FB823EA049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{95AAA0F9-72C4-4166-83A9-72FB823EA049}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{95AAA0F9-72C4-4166-83A9-72FB823EA049}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{95AAA0F9-72C4-4166-83A9-72FB823EA049}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{A14AC93F-8AAF-4F17-AAB3-16E56FD1588A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{A14AC93F-8AAF-4F17-AAB3-16E56FD1588A}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{A14AC93F-8AAF-4F17-AAB3-16E56FD1588A}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{A14AC93F-8AAF-4F17-AAB3-16E56FD1588A}.Release|Any CPU.Build.0 = Release|Any CPU
2727
EndGlobalSection
2828
EndGlobal

src/TrophyApi/Admin/Points/Boosts/BoostsClient.cs

Lines changed: 263 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,109 @@ internal BoostsClient(RawClient client)
1616
}
1717

1818
/// <summary>
19-
/// Create points boosts for multiple users.
19+
/// List points boosts for a system.
20+
/// </summary>
21+
/// <example><code>
22+
/// await client.Admin.Points.Boosts.ListAsync(
23+
/// "550e8400-e29b-41d4-a716-446655440000",
24+
/// new BoostsListRequest { Limit = 1, Skip = 1 }
25+
/// );
26+
/// </code></example>
27+
public async Task<IEnumerable<AdminPointsBoost>> ListAsync(
28+
string systemId,
29+
BoostsListRequest request,
30+
RequestOptions? options = null,
31+
CancellationToken cancellationToken = default
32+
)
33+
{
34+
var _query = new Dictionary<string, object>();
35+
if (request.Limit != null)
36+
{
37+
_query["limit"] = request.Limit.Value.ToString();
38+
}
39+
if (request.Skip != null)
40+
{
41+
_query["skip"] = request.Skip.Value.ToString();
42+
}
43+
var response = await _client
44+
.SendRequestAsync(
45+
new JsonRequest
46+
{
47+
BaseUrl = _client.Options.Environment.Admin,
48+
Method = HttpMethod.Get,
49+
Path = string.Format(
50+
"points/{0}/boosts",
51+
ValueConvert.ToPathParameterString(systemId)
52+
),
53+
Query = _query,
54+
Options = options,
55+
},
56+
cancellationToken
57+
)
58+
.ConfigureAwait(false);
59+
if (response.StatusCode is >= 200 and < 400)
60+
{
61+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
62+
try
63+
{
64+
return JsonUtils.Deserialize<IEnumerable<AdminPointsBoost>>(responseBody)!;
65+
}
66+
catch (JsonException e)
67+
{
68+
throw new TrophyApiException("Failed to deserialize response", e);
69+
}
70+
}
71+
72+
{
73+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
74+
try
75+
{
76+
switch (response.StatusCode)
77+
{
78+
case 401:
79+
throw new UnauthorizedError(JsonUtils.Deserialize<ErrorBody>(responseBody));
80+
case 404:
81+
throw new NotFoundError(JsonUtils.Deserialize<ErrorBody>(responseBody));
82+
case 422:
83+
throw new UnprocessableEntityError(
84+
JsonUtils.Deserialize<ErrorBody>(responseBody)
85+
);
86+
}
87+
}
88+
catch (JsonException)
89+
{
90+
// unable to map error response, throwing generic error
91+
}
92+
throw new TrophyApiApiException(
93+
$"Error with status code {response.StatusCode}",
94+
response.StatusCode,
95+
responseBody
96+
);
97+
}
98+
}
99+
100+
/// <summary>
101+
/// Create points boosts.
20102
/// </summary>
21103
/// <example><code>
22104
/// await client.Admin.Points.Boosts.CreateAsync(
23-
/// new CreatePointsBoostsRequest
105+
/// "550e8400-e29b-41d4-a716-446655440000",
106+
/// new List&lt;CreatePointsBoostRequestItem&gt;()
24107
/// {
25-
/// SystemKey = "xp",
26-
/// Boosts = new List&lt;CreatePointsBoostsRequestBoostsItem&gt;()
108+
/// new CreatePointsBoostRequestItem
27109
/// {
28-
/// new CreatePointsBoostsRequestBoostsItem
29-
/// {
30-
/// UserId = "user-123",
31-
/// Name = "Double XP Weekend",
32-
/// Start = "2024-01-01",
33-
/// End = "2024-01-03",
34-
/// Multiplier = 2,
35-
/// },
36-
/// new CreatePointsBoostsRequestBoostsItem
37-
/// {
38-
/// UserId = "user-456",
39-
/// Name = "Holiday Bonus",
40-
/// Start = "2024-12-25",
41-
/// Multiplier = 1.5,
42-
/// Rounding = CreatePointsBoostsRequestBoostsItemRounding.Up,
43-
/// },
110+
/// UserId = "user-123",
111+
/// Name = "Double XP Weekend",
112+
/// Start = "2024-01-01",
113+
/// End = "2024-01-03",
114+
/// Multiplier = 2,
44115
/// },
45116
/// }
46117
/// );
47118
/// </code></example>
48119
public async Task<CreatePointsBoostsResponse> CreateAsync(
49-
CreatePointsBoostsRequest request,
120+
string systemId,
121+
IEnumerable<CreatePointsBoostRequestItem> request,
50122
RequestOptions? options = null,
51123
CancellationToken cancellationToken = default
52124
)
@@ -57,7 +129,10 @@ public async Task<CreatePointsBoostsResponse> CreateAsync(
57129
{
58130
BaseUrl = _client.Options.Environment.Admin,
59131
Method = HttpMethod.Post,
60-
Path = "points/boosts",
132+
Path = string.Format(
133+
"points/{0}/boosts",
134+
ValueConvert.ToPathParameterString(systemId)
135+
),
61136
Body = request,
62137
ContentType = "application/json",
63138
Options = options,
@@ -84,8 +159,6 @@ public async Task<CreatePointsBoostsResponse> CreateAsync(
84159
{
85160
switch (response.StatusCode)
86161
{
87-
case 400:
88-
throw new BadRequestError(JsonUtils.Deserialize<ErrorBody>(responseBody));
89162
case 401:
90163
throw new UnauthorizedError(JsonUtils.Deserialize<ErrorBody>(responseBody));
91164
case 404:
@@ -115,6 +188,7 @@ public async Task<CreatePointsBoostsResponse> CreateAsync(
115188
/// await client.Admin.Points.Boosts.DeleteAsync(new BoostsDeleteRequest());
116189
/// </code></example>
117190
public async Task<DeletePointsBoostsResponse> DeleteAsync(
191+
string systemId,
118192
BoostsDeleteRequest request,
119193
RequestOptions? options = null,
120194
CancellationToken cancellationToken = default
@@ -128,7 +202,10 @@ public async Task<DeletePointsBoostsResponse> DeleteAsync(
128202
{
129203
BaseUrl = _client.Options.Environment.Admin,
130204
Method = HttpMethod.Delete,
131-
Path = "points/boosts",
205+
Path = string.Format(
206+
"points/{0}/boosts",
207+
ValueConvert.ToPathParameterString(systemId)
208+
),
132209
Query = _query,
133210
Options = options,
134211
},
@@ -154,10 +231,169 @@ public async Task<DeletePointsBoostsResponse> DeleteAsync(
154231
{
155232
switch (response.StatusCode)
156233
{
157-
case 400:
158-
throw new BadRequestError(JsonUtils.Deserialize<ErrorBody>(responseBody));
159234
case 401:
160235
throw new UnauthorizedError(JsonUtils.Deserialize<ErrorBody>(responseBody));
236+
case 404:
237+
throw new NotFoundError(JsonUtils.Deserialize<ErrorBody>(responseBody));
238+
case 422:
239+
throw new UnprocessableEntityError(
240+
JsonUtils.Deserialize<ErrorBody>(responseBody)
241+
);
242+
}
243+
}
244+
catch (JsonException)
245+
{
246+
// unable to map error response, throwing generic error
247+
}
248+
throw new TrophyApiApiException(
249+
$"Error with status code {response.StatusCode}",
250+
response.StatusCode,
251+
responseBody
252+
);
253+
}
254+
}
255+
256+
/// <summary>
257+
/// Update multiple points boosts.
258+
/// </summary>
259+
/// <example><code>
260+
/// await client.Admin.Points.Boosts.UpdateAsync(
261+
/// "550e8400-e29b-41d4-a716-446655440000",
262+
/// new List&lt;PatchPointsBoostsRequestItem&gt;()
263+
/// {
264+
/// new PatchPointsBoostsRequestItem
265+
/// {
266+
/// Id = "550e8400-e29b-41d4-a716-446655440000",
267+
/// Name = "Updated Boost Name",
268+
/// Multiplier = 3,
269+
/// },
270+
/// }
271+
/// );
272+
/// </code></example>
273+
public async Task<PatchPointsBoostsResponse> UpdateAsync(
274+
string systemId,
275+
IEnumerable<PatchPointsBoostsRequestItem> request,
276+
RequestOptions? options = null,
277+
CancellationToken cancellationToken = default
278+
)
279+
{
280+
var response = await _client
281+
.SendRequestAsync(
282+
new JsonRequest
283+
{
284+
BaseUrl = _client.Options.Environment.Admin,
285+
Method = HttpMethodExtensions.Patch,
286+
Path = string.Format(
287+
"points/{0}/boosts",
288+
ValueConvert.ToPathParameterString(systemId)
289+
),
290+
Body = request,
291+
ContentType = "application/json",
292+
Options = options,
293+
},
294+
cancellationToken
295+
)
296+
.ConfigureAwait(false);
297+
if (response.StatusCode is >= 200 and < 400)
298+
{
299+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
300+
try
301+
{
302+
return JsonUtils.Deserialize<PatchPointsBoostsResponse>(responseBody)!;
303+
}
304+
catch (JsonException e)
305+
{
306+
throw new TrophyApiException("Failed to deserialize response", e);
307+
}
308+
}
309+
310+
{
311+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
312+
try
313+
{
314+
switch (response.StatusCode)
315+
{
316+
case 401:
317+
throw new UnauthorizedError(JsonUtils.Deserialize<ErrorBody>(responseBody));
318+
case 404:
319+
throw new NotFoundError(JsonUtils.Deserialize<ErrorBody>(responseBody));
320+
case 422:
321+
throw new UnprocessableEntityError(
322+
JsonUtils.Deserialize<ErrorBody>(responseBody)
323+
);
324+
}
325+
}
326+
catch (JsonException)
327+
{
328+
// unable to map error response, throwing generic error
329+
}
330+
throw new TrophyApiApiException(
331+
$"Error with status code {response.StatusCode}",
332+
response.StatusCode,
333+
responseBody
334+
);
335+
}
336+
}
337+
338+
/// <summary>
339+
/// Get a single points boost by ID.
340+
/// </summary>
341+
/// <example><code>
342+
/// await client.Admin.Points.Boosts.GetAsync(
343+
/// "550e8400-e29b-41d4-a716-446655440000",
344+
/// "660f9500-f30c-42e5-b827-557766550001"
345+
/// );
346+
/// </code></example>
347+
public async Task<AdminPointsBoost> GetAsync(
348+
string systemId,
349+
string id,
350+
RequestOptions? options = null,
351+
CancellationToken cancellationToken = default
352+
)
353+
{
354+
var response = await _client
355+
.SendRequestAsync(
356+
new JsonRequest
357+
{
358+
BaseUrl = _client.Options.Environment.Admin,
359+
Method = HttpMethod.Get,
360+
Path = string.Format(
361+
"points/{0}/boosts/{1}",
362+
ValueConvert.ToPathParameterString(systemId),
363+
ValueConvert.ToPathParameterString(id)
364+
),
365+
Options = options,
366+
},
367+
cancellationToken
368+
)
369+
.ConfigureAwait(false);
370+
if (response.StatusCode is >= 200 and < 400)
371+
{
372+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
373+
try
374+
{
375+
return JsonUtils.Deserialize<AdminPointsBoost>(responseBody)!;
376+
}
377+
catch (JsonException e)
378+
{
379+
throw new TrophyApiException("Failed to deserialize response", e);
380+
}
381+
}
382+
383+
{
384+
var responseBody = await response.Raw.Content.ReadAsStringAsync();
385+
try
386+
{
387+
switch (response.StatusCode)
388+
{
389+
case 401:
390+
throw new UnauthorizedError(JsonUtils.Deserialize<ErrorBody>(responseBody));
391+
case 404:
392+
throw new NotFoundError(JsonUtils.Deserialize<ErrorBody>(responseBody));
393+
case 422:
394+
throw new UnprocessableEntityError(
395+
JsonUtils.Deserialize<ErrorBody>(responseBody)
396+
);
161397
}
162398
}
163399
catch (JsonException)

0 commit comments

Comments
 (0)