public static bool IsValid(this Attribute attribute) { return(attribute != null && !string.IsNullOrEmpty(attribute.Title) && !string.IsNullOrEmpty(attribute.Description) && EnumExtension.GetEnumValues <Intention>().Contains(attribute.Intention)); }
public void UpsertStandardAttributeByTitle_IfContextUnauthorized_Exception401() { var sourceAttribute = new Attribute { Title = "test" }; service = new VenueServiceApi(context); var exception = Assert.Catch <ApiException>(() => { var updatedAttribute = service.UpsertStandardAttributeByTitle(sourceAttribute); }); AssertApiException(exception, HttpStatusCode.Unauthorized); }
public void UpsertStandardAttributeByTitle_IfDescriptionIsNotSet_Exception400() { var sourceAttribute = new Attribute { Title = "test", Intention = Intention.Negative, }; var exception = Assert.Catch <ApiException>(() => { var updatedAttribute = service.UpsertStandardAttributeByTitle(sourceAttribute); }); AssertApiException(exception, HttpStatusCode.BadRequest); }
public void UpsertStandardAttributeByTitle_IfTokenInvalid_Exception403() { var sourceAttribute = new Attribute { Title = "test" }; context.AccessToken = "invalid_token"; service = new VenueServiceApi(context); var exception = Assert.Catch <ApiException>(() => { var updatedAttribute = service.UpsertStandardAttributeByTitle(sourceAttribute); }); AssertApiException(exception, HttpStatusCode.Forbidden); }
public void UpsertStandardAttributeByTitle_IfIntentionIsInvalid_Exception400() { var sourceAttribute = new Attribute { Title = "test", Description = "test description", Intention = (Intention)100, }; var exception = Assert.Catch <ApiException>(() => { var updatedAttribute = service.UpsertStandardAttributeByTitle(sourceAttribute); }); AssertApiException(exception, HttpStatusCode.BadRequest); }
/// <inheritdoc/> public Attribute UpsertStandardAttributeByTitle(Attribute attribute) { if (string.IsNullOrEmpty(attribute?.Title)) { throw new ArgumentException("attribute title must be set"); } TriggerAutomaticAuthentication(); var parameters = new ExecuteApiRequestParameters { Endpoint = $"v{ApiVersion}/admin/attributes", Method = RequestMethod.Patch, Body = attribute, }; var result = Executor.ExecuteApiWithWrappedResponse <Attribute>(parameters); return(result.DataOrException); }