Skip to content

Commit

Permalink
#255 Add missing argument null checks to space client
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamZ-Kontent committed Jan 18, 2024
1 parent 1afb8a7 commit eec8790
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Kontent.Ai.Management/ManagementClient.Space.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Kontent.Ai.Management.Models.Spaces.Patch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

Expand All @@ -17,17 +18,16 @@ public partial class ManagementClient
/// <inheritdoc />
public async Task<SpaceModel> CreateSpaceAsync(SpaceCreateModel space)
{
ArgumentNullException.ThrowIfNull(space);

var endpointUrl = _urlBuilder.BuildSpacesUrl();
return await _actionInvoker.InvokeMethodAsync<SpaceCreateModel, SpaceModel>(endpointUrl, HttpMethod.Post, space);
}

/// <inheritdoc />
public async Task<SpaceModel> GetSpaceAsync(Reference identifier)
{
if (identifier == null)
{
throw new ArgumentNullException(nameof(identifier));
}
ArgumentNullException.ThrowIfNull(identifier);

var endpointUrl = _urlBuilder.BuildSpacesUrl(identifier);
return await _actionInvoker.InvokeReadOnlyMethodAsync<SpaceModel>(endpointUrl, HttpMethod.Get);
Expand All @@ -43,10 +43,8 @@ public async Task<IEnumerable<SpaceModel>> ListSpacesAsync()
/// <inheritdoc />
public async Task<SpaceModel> ModifySpaceAsync(Reference identifier, IEnumerable<SpaceOperationReplaceModel> changes)
{
if (identifier == null)
{
throw new ArgumentNullException(nameof(identifier));
}
ArgumentNullException.ThrowIfNull(identifier);
ArgumentNullException.ThrowIfNull(changes);

var endpointUrl = _urlBuilder.BuildSpacesUrl(identifier);
return await _actionInvoker.InvokeMethodAsync<IEnumerable<SpaceOperationReplaceModel>, SpaceModel>(endpointUrl, HttpMethod.Patch, changes);
Expand All @@ -55,10 +53,7 @@ public async Task<SpaceModel> ModifySpaceAsync(Reference identifier, IEnumerable
/// <inheritdoc />
public async Task DeleteSpaceAsync(Reference identifier)
{
if (identifier == null)
{
throw new ArgumentNullException(nameof(identifier));
}
ArgumentNullException.ThrowIfNull(identifier);

var endpointUrl = _urlBuilder.BuildSpacesUrl(identifier);
await _actionInvoker.InvokeMethodAsync(endpointUrl, HttpMethod.Delete);
Expand Down

0 comments on commit eec8790

Please sign in to comment.