Пример #1
0
        private static HttpContent ConstructApplyValidatorBodyFromObject(object obj, string validatorId)
        {
            var dataType       = CollectionNameDeterminer.GetCollectionName(obj.GetType());
            var submitDataBody = new ApplyValidatorBody(dataType, obj, validatorId);

            return(PostBodyBuilder.ConstructBody(submitDataBody));
        }
Пример #2
0
        private static HttpContent ConstructSubmitBodyFromObject(object obj, bool overwrite, string id)
        {
            var dataType       = CollectionNameDeterminer.GetCollectionName(obj.GetType());
            var submitDataBody = new SubmitDataBody(dataType, obj, overwrite, id);

            return(PostBodyBuilder.ConstructBody(submitDataBody));
        }
Пример #3
0
        public static void Register(ApiConfiguration configuration, HttpClient httpClient, string username, string firstName, string lastName, string password, string email)
        {
            var requestUri = RequestUriBuilder.Build(configuration, "api/account/register");
            var body       = PostBodyBuilder.ConstructBody(new RegistrationInformation(username, firstName, lastName, password, email));
            var response   = httpClient.PostAsync(requestUri, body).Result;

            ErrorReporter.EnsureSuccesStatusCode(response);
        }
Пример #4
0
        public static void ChangePassword(ApiConfiguration configuration, HttpClient httpClient, string username, string password)
        {
            var requestUri = RequestUriBuilder.Build(configuration, "api/account/changepassword");
            var body       = PostBodyBuilder.ConstructBody(new ChangePasswordBody(username, password));
            var response   = httpClient.PostAsync(requestUri, body).Result;

            ErrorReporter.EnsureSuccesStatusCode(response);
        }
Пример #5
0
        private static HttpContent ConstructApplyValidatorBodyFromJson(string dataType, string json, string validatorId)
        {
            var submitDataBody       = new ApplyValidatorBody(dataType, null, validatorId);
            var submitBodyJsonObject = JObject.FromObject(submitDataBody);

            submitBodyJsonObject["Data"] = JObject.Parse(json);
            return(PostBodyBuilder.ConstructBodyFromJObject(submitBodyJsonObject));
        }
Пример #6
0
        private static HttpContent ConstructSubmitBodyFromJson(string dataType, string json, bool overwrite, string id)
        {
            var submitDataBody       = new SubmitDataBody(dataType, null, overwrite, id);
            var submitBodyJsonObject = JObject.FromObject(submitDataBody);

            submitBodyJsonObject["Data"] = JObject.Parse(json);
            return(PostBodyBuilder.ConstructBodyFromJObject(submitBodyJsonObject));
        }
Пример #7
0
        private static HttpContent ConstructSubmitValidatorBody(ValidatorDefinition validatorDefinition, bool suppressAutoApprove)
        {
            var submitValidatorBody = new SubmitValidatorBody(validatorDefinition)
            {
                SuppressAutoApprove = suppressAutoApprove
            };

            return(PostBodyBuilder.ConstructBody(submitValidatorBody));
        }
Пример #8
0
        public static AuthenticationResult Login(ApiConfiguration configuration, HttpClient httpClient, string username, string password)
        {
            var requestUri = RequestUriBuilder.Build(configuration, "api/account/login");

            var body     = PostBodyBuilder.ConstructBody(new LoginInformation(username, password));
            var response = httpClient.PostAsync(requestUri, body).Result;

            if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Unauthorized)
            {
                var errorText = response.Content.ReadAsStringAsync().Result;
                throw new ApiException(response.StatusCode, errorText);
            }

            var json = response.Content.ReadAsStringAsync().Result;
            var authenticationResult = ConfiguredJsonSerializer.Deserialize <AuthenticationResult>(json);

            return(authenticationResult);
        }
Пример #9
0
        private static HttpContent ConstructCreateViewBody(string query, DateTime expires, string viewId = null)
        {
            var createViewBody = new CreateViewBody(query, expires, viewId);

            return(PostBodyBuilder.ConstructBody(createViewBody));
        }
        private static HttpContent ConstructSubscriptionBody(string dataType, IList <DataModificationType> modificationTypes, string filter)
        {
            var subscriptionBody = new SubscriptionBody(dataType, modificationTypes.ToList(), filter);

            return(PostBodyBuilder.ConstructBody(subscriptionBody));
        }