public IUploadMediaItemRequestParametersBuilder <IMediaResourceUploadRequest> ItemDataStream(Stream itemDataStream)
 {
     BaseValidator.CheckNullAndThrow(itemDataStream, this.GetType().Name + ".ItemDataStream");
     BaseValidator.CheckForTwiceSetAndThrow(this.itemDataStream, this.GetType().Name + ".ItemDataStream");
     this.itemDataStream = itemDataStream;
     return(this);
 }
        public IScopedRequestParametersBuilder <T> AddScope(params ScopeType[] scope)
        {
            BaseValidator.CheckNullAndThrow(scope, this.GetType().Name + ".Scope");

            IEnumerable <ScopeType> castedScope = scope;

            return(this.AddScope(castedScope));
        }
Beispiel #3
0
        private void Validate()
        {
            BaseValidator.CheckNullAndThrow(this.itemSource, this.GetType().Name + ".itemSource");

            BaseValidator.CheckNullAndThrow(this.restGrammar, this.GetType().Name + ".restGrammar");

            BaseValidator.CheckNullAndThrow(this.sessionConfig, this.GetType().Name + ".sessionConfig");
        }
        public RunStoredSearchRequestBuilder Term(string term)
        {
            BaseValidator.CheckNullAndThrow(term, this.GetType().Name + ".Term");

            this.term = term;

            return(this);
        }
Beispiel #5
0
        protected void Validate(TRequest request)
        {
            BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".request");

            BaseValidator.CheckNullAndThrow(request.SessionConfig, this.GetType().Name + ".SessionConfig");

            BaseValidator.CheckNullAndThrow(request.SessionConfig.InstanceUrl, this.GetType().Name + ".InstanceUrl");

            this.ValidateSpecificPart(request);
        }
Beispiel #6
0
        public IInteractionParametersBuilder <T> AddEvents(Collection <IUTEvent> utEvents)
        {
            BaseValidator.CheckNullAndThrow(utEvents, this.GetType().Name + ".utEvents");

            foreach (IUTEvent singleElem in utEvents)
            {
                this.AddEvents(singleElem);
            }

            return(this);
        }
Beispiel #7
0
        public void CheckDefaultsAndThrow(bool denyEmptyEvent = true)
        {
            if (denyEmptyEvent)
            {
                BaseValidator.CheckCollectionForNullAndEmptyOrThrow(this.EventsAggregator, this.GetType().Name + ".utEvents");
            }

            BaseValidator.CheckNullAndThrow(this.ContactAggregator, this.GetType().Name + ".utContact");
            BaseValidator.CheckNullAndThrow(this.InteractioinParametersAccumulator.Initiator, this.GetType().Name + ".utInitiator");
            BaseValidator.CheckNullAndThrow(this.InteractioinParametersAccumulator.ChannelId, this.GetType().Name + ".utChannelId");
        }
Beispiel #8
0
        private ISearchItemRequestParametersBuilder <T> AddFieldsToSort(IEnumerable <string> fields, string sortOrder)
        {
            BaseValidator.CheckNullAndThrow(fields, this.GetType().Name + ".FieldsToSort");

            if (!fields.Any())
            {
                return(this);
            }

            Func <string, bool> fieldNameValidator =
                fieldName => !string.IsNullOrWhiteSpace(fieldName);
            var validFieldsNoOrder = fields.Where(fieldNameValidator).ToList();

            //adding sort order
            var validFields = new List <string>();

            foreach (string field in validFieldsNoOrder)
            {
                validFields.Add(sortOrder + field);
            }

            IEnumerable <string> currentFields = this.sortParameters.Fields;

            if (null == currentFields)
            {
                currentFields = new string[0] {
                };
            }
            ;

            int myFieldsCount  = currentFields.Count();
            int newFieldsCount = validFields.Count;

            int appendedFieldsCount = myFieldsCount + newFieldsCount;

            string[] newFields = new string[appendedFieldsCount];

            currentFields.ToArray().CopyTo(newFields, 0);
            validFields.CopyTo(newFields, myFieldsCount);

            bool isFieldListHasDuplicates = DuplicateEntryValidator.IsDuplicatedFieldsInTheList(newFields);

            if (isFieldListHasDuplicates)
            {
                throw new InvalidOperationException(this.GetType().Name + ".Fields" + " : duplicate fields are not allowed");
            }

            this.sortParameters = new SortParameters(newFields);

            return(this);
        }
        public IBaseRequestParametersBuilder <T> AddFieldsToRead(IEnumerable <string> fields)
        {
            BaseValidator.CheckNullAndThrow(fields, this.GetType().Name + ".Fields");

            if (!fields.Any())
            {
                return(this);
            }

            Func <string, bool> fieldNameValidator =
                fieldName => !string.IsNullOrWhiteSpace(fieldName);
            var validFields = fields.Where(fieldNameValidator).ToList();

            IEnumerable <string> currentFields = this.queryParameters.Fields;

            if (null == currentFields)
            {
                currentFields = new string[0] {
                };
            }
            ;



            int myFieldsCount  = currentFields.Count();
            int newFieldsCount = validFields.Count;

            int appendedFieldsCount = myFieldsCount + newFieldsCount;

            string[] newFields = new string[appendedFieldsCount];


            currentFields.ToArray().CopyTo(newFields, 0);
            validFields.CopyTo(newFields, myFieldsCount);

            bool isFieldListHasDuplicates = DuplicateEntryValidator.IsDuplicatedFieldsInTheList(newFields);

            if (isFieldListHasDuplicates)
            {
                throw new InvalidOperationException(this.GetType().Name + ".Fields" + " : duplicate fields are not allowed");
            }

            this.queryParameters = new QueryParameters(
                this.queryParameters.Payload,
                this.queryParameters.ScopeParameters,
                newFields);

            return(this);
        }
Beispiel #10
0
        public IInteractionParametersBuilder <T> AddEvents(IUTEvent utEvent)
        {
            BaseValidator.CheckNullAndThrow(utEvent, this.GetType().Name + ".utEvent");

            bool isDuplicated = DuplicateEntryValidator.IsObjectInTheList(this.EventsAggregator, utEvent);

            if (isDuplicated)
            {
                throw new InvalidOperationException(this.GetType().Name + ".utEvent : duplicate Events are not allowed");
            }

            this.EventsAggregator.Add(utEvent);

            return(this);
        }
Beispiel #11
0
        public ISearchItemRequestParametersBuilder <T> AddDescendingFieldsToSort(params string[] fieldParams)
        {
            BaseValidator.CheckNullAndThrow(fieldParams, this.GetType().Name + ".Fields");
            BaseValidator.CheckNullAndThrow(fieldParams[0], this.GetType().Name + ".Fields");

            if (1 == fieldParams.Length)
            {
                if (null == fieldParams[0])
                {
                    return(this);
                }
            }

            return(this.AddFieldsToSort((IEnumerable <string>)fieldParams, "d"));
        }
        public IRenderingHtmlRequestParametersBuilder <IGetRenderingHtmlRequest> AddRenderingParameterNameValue(IDictionary <string, string> parametersValuesByName)
        {
            BaseValidator.CheckNullAndThrow(parametersValuesByName, this.GetType().Name + ".ParametersValuesByName");

            if (parametersValuesByName.Count == 0)
            {
                return(this);
            }

            foreach (var parameter in parametersValuesByName)
            {
                this.AddRenderingParameterNameValue(parameter.Key, parameter.Value);
            }

            return(this);
        }
        public IEventRequestParametersBuilder <T> AddCustomValues(IDictionary <string, string> customValues)
        {
            BaseValidator.CheckNullAndThrow(customValues, this.GetType().Name + ".customFieldsValues");

            if (customValues.Count == 0)
            {
                return(this);
            }

            foreach (var fieldElem in customValues)
            {
                this.AddCustomValues(fieldElem.Key, fieldElem.Value);
            }

            return(this);
        }
        public IChangeEntityParametersBuilder <T> AddFieldsRawValuesByNameToSet(IDictionary <string, string> fieldsRawValuesByName)
        {
            BaseValidator.CheckNullAndThrow(fieldsRawValuesByName, this.GetType().Name + ".FieldsRawValuesByName");

            if (fieldsRawValuesByName.Count == 0)
            {
                return(this);
            }

            foreach (var fieldElem in fieldsRawValuesByName)
            {
                this.AddFieldsRawValuesByNameToSet(fieldElem.Key, fieldElem.Value);
            }

            return(this);
        }
        public IBaseEntityRequestParametersBuilder <T> AddParametersRawValues(IDictionary <string, string> parametersValuesByName)
        {
            BaseValidator.CheckNullAndThrow(parametersValuesByName, this.GetType().Name + ".AddParametersRawValues");

            if (parametersValuesByName.Count == 0)
            {
                return(this);
            }

            foreach (var paramElem in parametersValuesByName)
            {
                this.AddParametersRawValues(paramElem.Key, paramElem.Value);
            }

            return(this);
        }
        public IDeleteItemRequestBuilder <T> AddScope(IEnumerable <ScopeType> scope)
        {
            BaseValidator.CheckNullAndThrow(scope, this.GetType().Name + ".Scope");

            var scopeParams = new ScopeParameters(this.scopeParameters);

            foreach (var singleScope in scope)
            {
                if (!scopeParams.AddScope(singleScope))
                {
                    throw new InvalidOperationException(this.GetType().Name + ".Scope : Adding scope parameter duplicates is forbidden");
                }
            }
            this.scopeParameters = scopeParams;

            return(this);
        }
        public override ISitecoreStoredSearchRequest Build()
        {
            IPagingParameters pagingSettings = this.AccumulatedPagingParameters;

            BaseValidator.CheckNullAndThrow(this.term, "Search term can not be null");

            StoredSearchParameters result = new StoredSearchParameters(
                null,
                this.itemSourceAccumulator,
                this.queryParameters,
                pagingSettings,
                this.itemId,
                this.icludeStanderdTemplateFields,
                this.term);

            return(result);
        }
        public IMediaResourceUploadRequest Build()
        {
            BaseValidator.CheckNullAndThrow(this.itemDataStream, this.GetType().Name + ".ItemDataStream");
            BaseValidator.CheckNullAndThrow(this.itemName, this.GetType().Name + ".ItemName");
            BaseValidator.CheckNullAndThrow(this.fileName, this.GetType().Name + ".FileName");

            var createMediaParameters = new UploadMediaOptions(
                this.itemDataStream,
                this.fileName,
                this.itemName,
                this.itemTemplate,
                this.mediaPath,
                this.parentId,
                this.contentType
                );
            var result = new MediaResourceUploadParameters(null, this.itemSourceAccumulator, createMediaParameters);

            return(result);
        }
Beispiel #19
0
        public async Task <UTResponse> TrackInteractionAsync(ITrackInteractionRequest request, CancellationToken cancelToken)
        {
            BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".request");

            ITrackInteractionRequest requestCopy = request.DeepCopyTrackInteractionRequest();

            ITrackInteractionRequest autocompletedRequest = this.requestMerger.FillTrackInteractionGaps(requestCopy);

            var urlBuilder = new TrackInteractionUrlBuilder <ITrackInteractionRequest>(this.utGrammar);
            var taskFlow   = new TrackInteractionTask(urlBuilder, this.httpClient);

            var response = await RestApiCallFlow.LoadRequestFromNetworkFlow(autocompletedRequest, taskFlow, cancelToken);

            if (response.Successful)
            {
                //@igk order matters
                this.sessionConfig = new UTSessionConfig(this.sessionConfig.InstanceUrl, response.Description);
                this.requestMerger = new UserRequestMerger(this.sessionConfig, this.defaultDeviceIdentifier);
            }

            return(response);
        }
Beispiel #20
0
        public async Task <UTResponse> TrackDownloadEventAsync(ITrackDownloadRequest request, CancellationToken cancelToken = default(CancellationToken))
        {
            BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".DownloadRequest");

            ITrackDownloadRequest requestCopy = request.DeepCopyTrackDownloadRequest();

            ITrackDownloadRequest autocompletedRequest = this.requestMerger.FillTrackDownloadGaps(requestCopy);

            //FIXME: @igk
            if (this.InteractionNotExists())
            {
                return(await this.CreateInteractionAndSentEventAsync(request.Download, cancelToken));
            }

            var urlBuilder = new TrackEventUrlBuilder <ITrackDownloadRequest>(this.utGrammar);
            var taskFlow   = new TrackDownloadTask(urlBuilder, this.httpClient);

            var response = await RestApiCallFlow.LoadRequestFromNetworkFlow(autocompletedRequest, taskFlow, cancelToken);

            this.CheckResponseForValidInteraction(response);

            return(response);
        }
        public static UTResponse Parse(string responseString, int responseCode, CancellationToken cancelToken)
        {
            BaseValidator.CheckNullAndThrow(responseString, "UTTrackResponseParser.responseString");

            Debug.WriteLine("RESPONSE to PARSE RESULT: " + responseString);

            string description = null;

            Collection <string> errors = null;

            bool responseContainsArray = responseString.StartsWith("[", System.StringComparison.CurrentCultureIgnoreCase) &&
                                         responseString.EndsWith("]", System.StringComparison.CurrentCultureIgnoreCase);

            if (responseContainsArray)
            {
                errors = JsonConvert.DeserializeObject <Collection <string> >(responseString);
            }
            else
            {
                description = responseString;
            }
#warning not implemented!!!
            return(new UTResponse(responseCode, description, errors));
        }
Beispiel #22
0
 private void ValidateRequest(IReadItemsByQueryRequest request)
 {
     BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".request");
 }
Beispiel #23
0
        protected void Validate(TRequest request)
        {
            BaseValidator.CheckNullAndThrow(request, this.GetType().Name + ".request");

            this.ValidateSpecificPart(request);
        }
Beispiel #24
0
 private void Validate()
 {
     BaseValidator.CheckNullAndThrow(this.urlBuilder, this.GetType().Name + ".urlBuilder");
 }