Skip to content

Commit

Permalink
OF-293 Implement player delete method
Browse files Browse the repository at this point in the history
  • Loading branch information
tsviatkov committed Oct 30, 2023
1 parent 79231e2 commit 0e5e8a7
Show file tree
Hide file tree
Showing 2 changed files with 356 additions and 0 deletions.
188 changes: 188 additions & 0 deletions Openfort.SDK/Generated/Api/PlayersApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ public interface IPlayersApiSync : IApiAccessor
/// <returns>ApiResponse of SessionResponse</returns>
ApiResponse<SessionResponse> CreatePlayerSessionWithHttpInfo(string id, CreatePlayerSessionRequest createPlayerSessionRequest);
/// <summary>
/// Deletes a player object.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <returns>PlayerDeleteResponse</returns>
PlayerDeleteResponse DeletePlayer(string id, PlayerRequest playerRequest);

/// <summary>
/// Deletes a player object.
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <returns>ApiResponse of PlayerDeleteResponse</returns>
ApiResponse<PlayerDeleteResponse> DeletePlayerWithHttpInfo(string id, PlayerRequest playerRequest);
/// <summary>
/// Retrieves the details of an existing player.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
Expand Down Expand Up @@ -402,6 +422,31 @@ public interface IPlayersApiAsync : IApiAccessor
/// <returns>Task of ApiResponse (SessionResponse)</returns>
System.Threading.Tasks.Task<ApiResponse<SessionResponse>> CreatePlayerSessionWithHttpInfoAsync(string id, CreatePlayerSessionRequest createPlayerSessionRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// Deletes a player object.
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of PlayerDeleteResponse</returns>
System.Threading.Tasks.Task<PlayerDeleteResponse> DeletePlayerAsync(string id, PlayerRequest playerRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));

/// <summary>
/// Deletes a player object.
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse (PlayerDeleteResponse)</returns>
System.Threading.Tasks.Task<ApiResponse<PlayerDeleteResponse>> DeletePlayerWithHttpInfoAsync(string id, PlayerRequest playerRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// Retrieves the details of an existing player.
/// </summary>
/// <remarks>
Expand Down Expand Up @@ -1382,6 +1427,149 @@ public Openfort.SDK.Client.ApiResponse<SessionResponse> CreatePlayerSessionWithH
return localVarResponse;
}

/// <summary>
/// Deletes a player object.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <returns>PlayerDeleteResponse</returns>
public PlayerDeleteResponse DeletePlayer(string id, PlayerRequest playerRequest)
{
Openfort.SDK.Client.ApiResponse<PlayerDeleteResponse> localVarResponse = DeletePlayerWithHttpInfo(id, playerRequest);
return localVarResponse.Data;
}

/// <summary>
/// Deletes a player object.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <returns>ApiResponse of PlayerDeleteResponse</returns>
public Openfort.SDK.Client.ApiResponse<PlayerDeleteResponse> DeletePlayerWithHttpInfo(string id, PlayerRequest playerRequest)
{
// verify the required parameter 'id' is set
if (id == null)
throw new Openfort.SDK.Client.ApiException(400, "Missing required parameter 'id' when calling PlayersApi->DeletePlayer");

// verify the required parameter 'playerRequest' is set
if (playerRequest == null)
throw new Openfort.SDK.Client.ApiException(400, "Missing required parameter 'playerRequest' when calling PlayersApi->DeletePlayer");

Openfort.SDK.Client.RequestOptions localVarRequestOptions = new Openfort.SDK.Client.RequestOptions();

string[] _contentTypes = new string[] {
"application/json"
};

// to determine the Accept header
string[] _accepts = new string[] {
"application/json"
};

var localVarContentType = Openfort.SDK.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);

var localVarAccept = Openfort.SDK.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);

localVarRequestOptions.PathParameters.Add("id", Openfort.SDK.Client.ClientUtils.ParameterToString(id)); // path parameter
localVarRequestOptions.Data = playerRequest;

// authentication (sk) required
// bearer authentication required
if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}

// make the HTTP request
var localVarResponse = this.Client.Delete<PlayerDeleteResponse>("/v1/players/{id}", localVarRequestOptions, this.Configuration);

if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("DeletePlayer", localVarResponse);
if (_exception != null) throw _exception;
}

return localVarResponse;
}

/// <summary>
/// Deletes a player object.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of PlayerDeleteResponse</returns>
public async System.Threading.Tasks.Task<PlayerDeleteResponse> DeletePlayerAsync(string id, PlayerRequest playerRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
Openfort.SDK.Client.ApiResponse<PlayerDeleteResponse> localVarResponse = await DeletePlayerWithHttpInfoAsync(id, playerRequest, cancellationToken).ConfigureAwait(false);
return localVarResponse.Data;
}

/// <summary>
/// Deletes a player object.
/// </summary>
/// <exception cref="Openfort.SDK.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="id">Specifies the unique player ID (starts with pla_).</param>
/// <param name="playerRequest"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse (PlayerDeleteResponse)</returns>
public async System.Threading.Tasks.Task<Openfort.SDK.Client.ApiResponse<PlayerDeleteResponse>> DeletePlayerWithHttpInfoAsync(string id, PlayerRequest playerRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
// verify the required parameter 'id' is set
if (id == null)
throw new Openfort.SDK.Client.ApiException(400, "Missing required parameter 'id' when calling PlayersApi->DeletePlayer");

// verify the required parameter 'playerRequest' is set
if (playerRequest == null)
throw new Openfort.SDK.Client.ApiException(400, "Missing required parameter 'playerRequest' when calling PlayersApi->DeletePlayer");


Openfort.SDK.Client.RequestOptions localVarRequestOptions = new Openfort.SDK.Client.RequestOptions();

string[] _contentTypes = new string[] {
"application/json"
};

// to determine the Accept header
string[] _accepts = new string[] {
"application/json"
};


var localVarContentType = Openfort.SDK.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);

var localVarAccept = Openfort.SDK.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);

localVarRequestOptions.PathParameters.Add("id", Openfort.SDK.Client.ClientUtils.ParameterToString(id)); // path parameter
localVarRequestOptions.Data = playerRequest;

// authentication (sk) required
// bearer authentication required
if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}

// make the HTTP request

var localVarResponse = await this.AsynchronousClient.DeleteAsync<PlayerDeleteResponse>("/v1/players/{id}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);

if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("DeletePlayer", localVarResponse);
if (_exception != null) throw _exception;
}

return localVarResponse;
}

/// <summary>
/// Retrieves the details of an existing player.
/// </summary>
Expand Down
168 changes: 168 additions & 0 deletions Openfort.SDK/Generated/Model/PlayerDeleteResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
* Openfort API
*
* Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
*
* The version of the OpenAPI document: 1.0.0
* Contact: founders@openfort.xyz
* Generated by: https://github.com/openapitools/openapi-generator.git
*/


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.ComponentModel.DataAnnotations;
using FileParameter = Openfort.SDK.Client.FileParameter;
using OpenAPIDateConverter = Openfort.SDK.Client.OpenAPIDateConverter;

namespace Openfort.SDK.Model
{
/// <summary>
/// PlayerDeleteResponse
/// </summary>
[DataContract(Name = "PlayerDeleteResponse")]
public partial class PlayerDeleteResponse : IEquatable<PlayerDeleteResponse>, IValidatableObject
{

/// <summary>
/// Gets or Sets Object
/// </summary>
[DataMember(Name = "object", IsRequired = true, EmitDefaultValue = true)]
public EntityTypePLAYER Object { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="PlayerDeleteResponse" /> class.
/// </summary>
[JsonConstructorAttribute]
protected PlayerDeleteResponse() { }
/// <summary>
/// Initializes a new instance of the <see cref="PlayerDeleteResponse" /> class.
/// </summary>
/// <param name="id">id (required).</param>
/// <param name="_object">_object (required).</param>
/// <param name="deleted">deleted (required).</param>
public PlayerDeleteResponse(string id = default(string), EntityTypePLAYER _object = default(EntityTypePLAYER), bool deleted = default(bool))
{
// to ensure "id" is required (not null)
if (id == null)
{
throw new ArgumentNullException("id is a required property for PlayerDeleteResponse and cannot be null");
}
this.Id = id;
this.Object = _object;
this.Deleted = deleted;
}

/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name = "id", IsRequired = true, EmitDefaultValue = true)]
public string Id { get; set; }

/// <summary>
/// Gets or Sets Deleted
/// </summary>
[DataMember(Name = "deleted", IsRequired = true, EmitDefaultValue = true)]
public bool Deleted { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class PlayerDeleteResponse {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Object: ").Append(Object).Append("\n");
sb.Append(" Deleted: ").Append(Deleted).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return this.Equals(input as PlayerDeleteResponse);
}

/// <summary>
/// Returns true if PlayerDeleteResponse instances are equal
/// </summary>
/// <param name="input">Instance of PlayerDeleteResponse to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(PlayerDeleteResponse input)
{
if (input == null)
{
return false;
}
return
(
this.Id == input.Id ||
(this.Id != null &&
this.Id.Equals(input.Id))
) &&
(
this.Object == input.Object ||
this.Object.Equals(input.Object)
) &&
(
this.Deleted == input.Deleted ||
this.Deleted.Equals(input.Deleted)
);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.Id != null)
{
hashCode = (hashCode * 59) + this.Id.GetHashCode();
}
hashCode = (hashCode * 59) + this.Object.GetHashCode();
hashCode = (hashCode * 59) + this.Deleted.GetHashCode();
return hashCode;
}
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}

}

0 comments on commit 0e5e8a7

Please sign in to comment.