/// <summary> /// Creates an client tag. /// </summary> /// <param name="value">The client tag to create.</param> /// <param name="token">The cancellation token.</param> /// <returns> /// A task that represents the asynchronous operation. /// The task result contains the new client tag. /// </returns> /// <exception cref="ArgumentException">Thrown when the parameter check fails.</exception> /// <exception cref="NotAuthorizedException">Thrown when not authorized to access this resource.</exception> /// <exception cref="NotFoundException">Thrown when the resource url could not be found.</exception> public async Task <ClientTag> CreateAsync(ClientTag value, CancellationToken token = default) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (value.ClientId == 0 || string.IsNullOrEmpty(value.Name)) { throw new ArgumentException("client tag or a value of the client tag is null", nameof(value)); } if (value.Id != 0) { throw new ArgumentException("invalid model id", nameof(value)); } var wrappedModel = new ClientTagWrapper { ClientTag = value.ToApi() }; var jsonModel = await PostAsync("/api/client-tags", wrappedModel, token); return(jsonModel.ToDomain()); }
internal static ClientTag ToDomain(this ClientTagWrapper value) { return(s_clientTagMapper.ApiToDomain(value)); }
public ClientTag ApiToDomain(ClientTagWrapper value) { return(ApiToDomain(value?.ClientTag)); }