Ejemplo n.º 1
0
 public static bool IsValid(this Attribute attribute)
 {
     return(attribute != null &&
            !string.IsNullOrEmpty(attribute.Title) &&
            !string.IsNullOrEmpty(attribute.Description) &&
            EnumExtension.GetEnumValues <Intention>().Contains(attribute.Intention));
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        /// <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);
        }