public void should_correctly_prepare_redirect_type(RedirectType type, string expected)
        {
            var dto = new ZoneRedirectRequest
            {
                Name                = Name,
                RedirectType        = type,
                RedirectTo          = RedirectTo,
                RedirectQueryString = RedirectQueryString
            };

            var json = dto.Prepare();

            json.ShouldContain(expected);
        }
        public void should_correctly_create_dto_without_ifram_title()
        {
            var dto = new ZoneRedirectRequest
            {
                Name                = Name,
                RedirectType        = RedirectType.Permanently,
                RedirectTo          = RedirectTo,
                RedirectQueryString = RedirectQueryString
            };

            var json = dto.Prepare();

            json.ShouldContain(Name);
            json.ShouldContain(RedirectTo);
            json.ShouldNotContain(IframeTitle);
            json.ShouldContain("301");
        }
示例#3
0
        public async Task <ZoneRedirect> CreateRedirectAsync(int zoneId, string name,
                                                             string redirectTo, RedirectType type, bool redirectQueryString, string iframeTitle = null)
        {
            var requestDto = new ZoneRedirectRequest
            {
                IframeTitle         = iframeTitle,
                Name                = name,
                RedirectQueryString = redirectQueryString,
                RedirectTo          = redirectTo,
                RedirectType        = type
            };

            var response = await _client.Post($"{BaseUrl}/{zoneId}/redirects", requestDto.Prepare());

            ErrorHandler(response.StatusCode);

            var content = await response.Content.ReadAsStringAsync();

            var responseDto = JsonConvert.DeserializeObject <ZoneRedirectResponse>(content);

            return(responseDto.Extract());
        }