Skip to content

Commit 32cf23f

Browse files
committed
Added support for upcoming DRES API change for submissions
1 parent 582cb6e commit 32cf23f

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed
0 Bytes
Binary file not shown.

Runtime/Libs/Dev.Dres.ClientApi.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Libs/Dev.Dres.ClientApi.xml.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Libs/JsonSubTypes.Dres.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Libs/Newtonsoft.Json.Dres.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Libs/RestSharp.Dres.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Dres/UnityClient/DresClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Threading.Tasks;
33
using Dev.Dres.ClientApi.Model;
4+
using UnityEditor;
45

56
namespace Dres.Unityclient
67
{
@@ -26,6 +27,7 @@ public async Task Login()
2627
UserDetails = await DresWrapper.Login(config.user, config.password);
2728
}
2829

30+
2931
/// <summary>
3032
/// Submits the given item (and optionally frame informaiton) to the DRES instance as current user.
3133
/// </summary>
@@ -38,6 +40,16 @@ public async Task<SuccessfulSubmissionsStatus> SubmitResult(string item, int? fr
3840
return await DresWrapper.Submit(item, UserDetails.SessionId, frame);
3941
}
4042

43+
/// <summary>
44+
/// Submits the given text to the DRES instance as current user
45+
/// </summary>
46+
/// <param name="text">The text to submit (this can be anything).</param>
47+
/// <returns>The success / failure state of the operation</returns>
48+
public async Task<SuccessfulSubmissionsStatus> SubmitTextualResult(string text)
49+
{
50+
return await DresWrapper.SubmitText(text, UserDetails.SessionId);
51+
}
52+
4153
/// <summary>
4254
/// Sends the given results as result log to the DRES instance as current user.
4355
/// For further information on the logging format, please consider visiting the

Runtime/Scripts/Dres/UnityClient/DresWrapper.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ namespace Dres.Unityclient
1212
/// <br />
1313
/// This class is held deliberately stateless (no session ID etc.) to allow multi-user scenarios in the future.
1414
/// </summary>
15-
public static class DresWrapper
15+
internal static class DresWrapper
1616
{
1717

1818
/// <summary>
1919
/// The deliberately single Logging Api instance of DRES. Used to send logs to DRES
2020
/// </summary>
21-
public static readonly LogApi LogApi = new LogApi(DresConfigManager.Instance.ApiConfiguration);
21+
internal static readonly LogApi LogApi = new LogApi(DresConfigManager.Instance.ApiConfiguration);
2222
/// <summary>
2323
/// The deliberately single Status Api instance of DRES. Used to get the status of DRES
2424
/// </summary>
25-
public static readonly StatusApi StatusApi = new StatusApi(DresConfigManager.Instance.ApiConfiguration);
25+
internal static readonly StatusApi StatusApi = new StatusApi(DresConfigManager.Instance.ApiConfiguration);
2626
/// <summary>
2727
/// The deliberately single Submission Api instance of DRES. Used to submit media items during competitions to DRES:
2828
/// </summary>
29-
public static readonly SubmissionApi SubmissionApi = new SubmissionApi(DresConfigManager.Instance.ApiConfiguration);
29+
internal static readonly SubmissionApi SubmissionApi = new SubmissionApi(DresConfigManager.Instance.ApiConfiguration);
3030
/// <summary>
3131
/// The deliberately single User Api instance of DRES. Used to log into DRES and retrieve the session id of the user.
3232
/// </summary>
33-
public static readonly UserApi UserApi = new UserApi(DresConfigManager.Instance.ApiConfiguration);
33+
internal static readonly UserApi UserApi = new UserApi(DresConfigManager.Instance.ApiConfiguration);
3434

3535
/// <summary>
3636
/// Login to DRES with given username and password.
@@ -41,7 +41,7 @@ public static class DresWrapper
4141
/// <param name="password">The DRES password</param>
4242
/// <returns>The login state on success.</returns>
4343
/// <exception cref="ApiException">If the config has no credentials set and no credentials file exists</exception>
44-
public static async Task<UserDetails> Login(string user, string password)
44+
internal static async Task<UserDetails> Login(string user, string password)
4545
{
4646
var loginRequest = new LoginRequest(user, password);
4747
return await UserApi.PostApiV1LoginAsync(loginRequest);
@@ -57,10 +57,24 @@ public static async Task<UserDetails> Login(string user, string password)
5757
/// If no notion of frames exist for the item, this can likely be omitted.</param>
5858
/// <returns>The submission state on success / failure.</returns>
5959
/// <exception cref="ApiException">A 404 if there is no ongoing competition for this session, a 403 if there is no such user</exception>
60-
public static async Task<SuccessfulSubmissionsStatus> Submit(string item, string session, int? frame = null)
60+
internal static async Task<SuccessfulSubmissionsStatus> Submit(string item, string session, int? frame = null)
6161
{
6262
return await SubmissionApi.GetApiV1SubmitAsync(item: item, frame: frame, session: session);
6363
}
64+
65+
/// <summary>
66+
/// Submits given TEXT to the DRES endpoint.
67+
/// Submissions are only allowed during active competitions (inferred from the given sesssion id)
68+
/// </summary>
69+
/// <param name="text">The submission in textual form (might also be a number) submit</param>
70+
/// <param name="session">The session id to which this submission belongs</param>
71+
/// <returns>The submission state on success / failure.</returns>
72+
/// <exception cref="ApiException">A 404 if there is no ongoing competition for this session, a 403 if there is no such user</exception>
73+
internal static async Task<SuccessfulSubmissionsStatus> SubmitText(string text, string session)
74+
{
75+
return await SubmissionApi.GetApiV1SubmitAsync(text= text, session=session);
76+
}
77+
6478

6579
/// <summary>
6680
/// Send result logs to the DRES endpoint.
@@ -75,7 +89,7 @@ public static async Task<SuccessfulSubmissionsStatus> Submit(string item, string
7589
/// <param name="session">The session id to which this log belongs</param>
7690
/// <returns>The state of success / failure of the log sending.</returns>
7791
/// <exception cref="ApiException">A 404 if there is no ongoing competition for this session, a 403 if there is no such user</exception>
78-
public static async Task<SuccessStatus> LogResults(long timestamp, string sortType, string resultSetAvailability,
92+
internal static async Task<SuccessStatus> LogResults(long timestamp, string sortType, string resultSetAvailability,
7993
List<QueryResult> results, List<QueryEvent> events, string session)
8094
{
8195
var resultLog = new QueryResultLog(timestamp, sortType, resultSetAvailability, results, events);
@@ -92,7 +106,7 @@ public static async Task<SuccessStatus> LogResults(long timestamp, string sortTy
92106
/// <param name="session">The session id to which this log belongs</param>
93107
/// <returns>The state of success / failure of the log sending.</returns>
94108
/// <exception cref="ApiException">A 404 if there is no ongoing competition for this session, a 403 if there is no such user</exception>
95-
public static async Task<SuccessStatus> LogQueryEvents(long timestamp, List<QueryEvent> events, string session)
109+
internal static async Task<SuccessStatus> LogQueryEvents(long timestamp, List<QueryEvent> events, string session)
96110
{
97111
var queryEventLog = new QueryEventLog(timestamp, events);
98112
return await LogApi.PostApiV1LogQueryAsync(session, queryEventLog);

0 commit comments

Comments
 (0)