Ejemplo n.º 1
0
        /// <summary>
        /// This endpoint deletes a collection of objects. Use caution with this endpoint.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        /// <returns>A list of objects matching the query.</returns>
        public virtual async Task DeleteAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object?>()
                        .AddSearchOptions(searchOptions, true);

            await ApiRequest.DeleteAsync <object>(
                EndpointPlural, query).ConfigureAwait(false);
        }
        /// <summary>
        /// Voids a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task VoidAsync(ApiSearchOptions searchOptions, CancellationToken cancellationToken = default)
        {
            var query = new Dictionary <string, object?>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PutAsync <object>(
                "transaction/void", query, cancellationToken).ConfigureAwait(false);
        }
        /// <summary>
        /// Reruns a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task RerunAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PostAsync <object>(
                "transaction/rerun", query);
        }
        /// <summary>
        /// Writes off a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task WriteOffAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object?>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PutAsync <object>(
                "transaction/writeOff", query).ConfigureAwait(false);
        }
        /// <summary>
        /// Reruns partner commissions for a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task RerunCommissionsAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object?>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PutAsync <object>(
                "transaction/rerunCommission", query).ConfigureAwait(false);
        }
        /// <summary>
        /// Resends an invoice for a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task ResendInvoiceAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object?>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PostAsync <object>(
                "transaction/resendInvoice", query).ConfigureAwait(false);
        }
        /// <summary>
        /// Voids a previously charged transaction.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        public async Task VoidAsync(ApiSearchOptions searchOptions)
        {
            var query = new Dictionary <string, object>()
                        .AddSearchOptions(searchOptions);

            await ApiRequest.PutAsync <object>(
                "transaction/void", query);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieves the number of objects having a specified tag.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="tagId">The ID of the tag you would like to filter your objects by. Either TagId or TagName is required.</param>
        /// <param name="tagName">The name of the tag you would like to filter your objects by. Either TagId or TagName is required.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="sortOptions">The sort options.</param>
        /// <param name="externs">If you have a relationship between your object and another object, you may want to include the data from a related field in your results. Each external field is listed in the format {object}//{field}.</param>
        /// <param name="listFields">A string array of the fields which should be returned in your results.</param>
        /// <returns>The number of objects matching the query.</returns>
        public async Task <int> GetCountByTagAsync(ApiObjectType objectType,
                                                   int?tagId = null, string tagName = null,
                                                   ApiSearchOptions searchOptions = null, ApiSortOptions sortOptions      = null,
                                                   IEnumerable <string> externs   = null, IEnumerable <string> listFields = null)
        {
            var json = await SelectByTagAsync(objectType, tagId, tagName, searchOptions, sortOptions, externs, listFields, true);

            return(json["data"]["count"].Value <string>().Convert <int>());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Retrieves a collection of objects having a specified tag.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="tagId">The ID of the tag you would like to filter your objects by. Either TagId or TagName is required.</param>
        /// <param name="tagName">The name of the tag you would like to filter your objects by. Either TagId or TagName is required.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="sortOptions">The sort options.</param>
        /// <param name="externs">If you have a relationship between your object and another object, you may want to include the data from a related field in your results. Each external field is listed in the format {object}//{field}.</param>
        /// <param name="listFields">A string array of the fields which should be returned in your results.</param>
        /// <returns>A list of objects matching the query.</returns>
        public async Task <List <Dictionary <string, string> > > SelectByTagAsync(ApiObjectType objectType,
                                                                                  int?tagId = null, string tagName = null,
                                                                                  ApiSearchOptions searchOptions = null, ApiSortOptions sortOptions      = null,
                                                                                  IEnumerable <string> externs   = null, IEnumerable <string> listFields = null)
        {
            var json = await SelectByTagAsync(objectType, tagId, tagName, searchOptions, sortOptions, externs, listFields, false);

            return(json["data"].ToObject <List <Dictionary <string, string> > >());
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Retrieves information about a collection of objects, such as the number of objects that match the given criteria.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        /// <returns>A ResponseCollectionInfo object.</returns>
        public async Task <ResponseCollectionInfo> GetCollectionInfoAsync(ApiSearchOptions searchOptions = null)
        {
            var query = new Dictionary <string, object>()
                        .AddSearchOptions(searchOptions);

            var json = await ApiRequest.GetAsync <JObject>(
                $"{EndpointPlural}/getInfo", query);

            return(OnParseGetCollectionInfo(json));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Cancels one or more tasks.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        public async Task CancelAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null)
        {
            var query = new Dictionary<string, object>
            {
                { "objectID", (int)objectType }
            }
                .AddSearchOptions(searchOptions, true);

            await ApiRequest.PostAsync<object>(
                "task/cancel", query);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This endpoint deletes a collection of objects. Use caution with this endpoint.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <returns>A list of objects matching the query.</returns>
        public async Task DeleteMultipleAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null)
        {
            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
            }
            .AddSearchOptions(searchOptions, true);

            await _apiRequest.DeleteAsync <object>(
                "objects", query);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Marks one or more tasks as completed.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="data">Additional data to set, see documentation.</param>
        /// <returns></returns>
        public async Task CompleteAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null, IDictionary<string, object> data = null)
        {
            var query = new Dictionary<string, object>
            {
                { "objectID", (int)objectType }
            }
                .AddSearchOptions(searchOptions, true)
                .AddIfHasValue("data", data);

            await ApiRequest.PostAsync<object>(
                "task/complete", query);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Assigns a task to one or more contacts.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="message">Data for the task message to assign to contacts.</param>
        public async Task AssignAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null, AssignTaskMessage message = null)
        {
            var query = new Dictionary<string, object>
            {
                { "object_type_id", (int)objectType },
            }
                .AddSearchOptions(searchOptions, true)
                .AddIfHasValue("message", message);

            await ApiRequest.PostAsync<object>(
                "task/assign", query);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Adds one or more objects to one or more sequences.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="sequenceIds">A list of the sequence(s) to which objects should be added.</param>
        public async Task AddToSequenceAsync(ApiObjectType objectType, ApiSearchOptions searchOptions, IEnumerable <int> sequenceIds, CancellationToken cancellationToken = default)
        {
            sequenceIds.CheckNotNullOrEmpty(nameof(sequenceIds));

            var query = new Dictionary <string, object?>
            {
                { "objectID", (int)objectType },
                { "add_list", sequenceIds },
            }
            .AddSearchOptions(searchOptions, true);

            await _apiRequest.PutAsync <object>(
                "objects/sequence", query, cancellationToken).ConfigureAwait(false);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Retrieves a collection of objects based on a set of parameters.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="sortOptions">The sort options.</param>
        /// <param name="externs">If you have a relationship between your object and another object, you may want to include the data from a related field in your results. Each external field is listed in the format {object}//{field}.</param>
        /// <param name="listFields">A string array of the fields which should be returned in your results.</param>
        /// <returns>A list of objects matching the query.</returns>
        public async Task <IList <T> > SelectAsync(
            ApiSearchOptions searchOptions = null, ApiSortOptions sortOptions      = null,
            IEnumerable <string> externs   = null, IEnumerable <string> listFields = null)
        {
            var query = new Dictionary <string, object>()
                        .AddSearchOptions(searchOptions)
                        .AddSortOptions(sortOptions)
                        .AddIfHasValue("externs", externs)
                        .AddIfHasValue("listFields", externs);

            var json = await ApiRequest.GetAsync <JObject>(
                $"{EndpointPlural}", query);

            return(await OnParseSelectMultipleAsync(json));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Retrieves a collection of objects based on a set of parameters.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <param name="sortOptions">The sort options.</param>
        /// <param name="externs">If you have a relationship between your object and another object, you may want to include the data from a related field in your results. Each external field is listed in the format {object}//{field}.</param>
        /// <param name="listFields">A string array of the fields which should be returned in your results.</param>
        /// <returns>A list of objects matching the query.</returns>
        public async Task <List <Dictionary <string, string> > > SelectAsync(ApiObjectType objectType,
                                                                             ApiSearchOptions searchOptions = null, ApiSortOptions sortOptions      = null,
                                                                             IEnumerable <string> externs   = null, IEnumerable <string> listFields = null)
        {
            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType }
            }
            .AddSearchOptions(searchOptions)
            .AddSortOptions(sortOptions)
            .AddIfHasValue("externs", externs)
            .AddIfHasValue("listFields", listFields);

            return(await _apiRequest.GetAsync <List <Dictionary <string, string> > >(
                       "objects", query));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Unpauses rules, sequences, and sequence subscribers.
        /// </summary>
        /// <param name="objectType">The object type: Rule, Sequence or Sequence Subscriber.</param>
        /// <param name="searchOptions">The search options.</param>
        public async Task UnpauseRuleOrSequenceAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null)
        {
            if (objectType != ApiObjectType.Rule && objectType != ApiObjectType.Sequence && objectType != ApiObjectType.SequenceSubscriber)
            {
                throw new ArgumentException("objectType must be Rule, Sequence or SequenceSubscriber.");
            }

            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
            }
            .AddSearchOptions(searchOptions);

            await _apiRequest.PostAsync <object>(
                "objects/unpause", query);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Removes one or more objects from one or more campaigns.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="campaignIds">A list of the campaign(s) from which objects should be removed.</param>
        /// <param name="searchOptions">The search options.</param>
        public async Task RemoveFromCampaignAsync(ApiObjectType objectType,
                                                  IEnumerable <int> campaignIds, ApiSearchOptions searchOptions = null)
        {
            if (campaignIds == null || !campaignIds.Any())
            {
                throw new ArgumentException("campaignIds is required.");
            }

            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
                { "remove_list", campaignIds },
            }
            .AddSearchOptions(searchOptions);

            await _apiRequest.DeleteAsync <object>(
                "objects/subscribe", query);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Removes one or more tags from one or more objects by the tag name.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="tagNames">A list of the names of the tag(s) which should be removed from objects.</param>
        /// <param name="searchOptions">The search options.</param>
        public async Task RemoveTagNamesAsync(ApiObjectType objectType,
                                              IEnumerable <string> tagNames, ApiSearchOptions searchOptions = null)
        {
            if (tagNames == null || !tagNames.Any())
            {
                throw new ArgumentException("tagNames is required.");
            }

            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
                { "remove_names", tagNames },
            }
            .AddSearchOptions(searchOptions);

            await _apiRequest.DeleteAsync <object>(
                "objects/tagByName", query);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds one or more tags to one or more objects.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="tagIds">A list of the IDs of the tag(s) which should be added to objects.</param>
        /// <param name="searchOptions">The search options.</param>
        public async Task AddTagAsync(ApiObjectType objectType,
                                      IEnumerable <int> tagIds, ApiSearchOptions searchOptions = null)
        {
            if (tagIds == null || !tagIds.Any())
            {
                throw new ArgumentException("tagIds is required.");
            }

            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
                { "add_list", tagIds },
            }
            .AddSearchOptions(searchOptions, true);

            await _apiRequest.PutAsync <object>(
                "objects/tag", query);
        }
Ejemplo n.º 22
0
        private async Task <JObject> SelectByTagAsync(ApiObjectType objectType,
                                                      int?tagId = null, string tagName = null,
                                                      ApiSearchOptions searchOptions = null, ApiSortOptions sortOptions      = null,
                                                      IEnumerable <string> externs   = null, IEnumerable <string> listFields = null, bool count = false)
        {
            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
                { tagId.HasValue ? "tag_id" : "tag_name", (object)tagId ?? tagName },
                { "count", count ? "true" : "false" },
            }
            .AddSearchOptions(searchOptions)
            .AddSortOptions(sortOptions)
            .AddIfHasValue("externs", externs)
            .AddIfHasValue("listFields", listFields);

            return(await _apiRequest.GetAsync <JObject>(
                       "objects/tag", query));
        }
 /// <summary>
 /// Adds one or more tags to one or more objects.
 /// </summary>
 /// <param name="tagIds">A list of the IDs of the tag(s) which should be added to objects.</param>
 /// <param name="searchOptions">The search options.</param>
 public async Task AddTagAsync(IEnumerable <int> tagIds, ApiSearchOptions searchOptions = null) =>
 await _ontraObjects.AddTagAsync((ApiObjectType)_objectTypeId, tagIds, searchOptions);
 /// <summary>
 /// Adds one or more objects to one or more sequences.
 /// </summary>
 /// <param name="sequenceIds">A list of the sequence(s) to which objects should be added.</param>
 /// <param name="searchOptions">The search options.</param>
 public async Task AddToSequenceAsync(IEnumerable <int> sequenceIds, ApiSearchOptions searchOptions = null) =>
 await _ontraObjects.AddToSequenceAsync((ApiObjectType)_objectTypeId, sequenceIds, searchOptions);
 /// <summary>
 /// Unpauses rules, sequences, and sequence subscribers.
 /// </summary>
 /// <param name="searchOptions">The search options.</param>
 public async Task UnpauseRuleOrSequenceAsync(ApiSearchOptions searchOptions = null) =>
 await _ontraObjects.UnpauseRuleOrSequenceAsync((ApiObjectType)_objectTypeId, searchOptions);
 /// <summary>
 /// Removes one or more objects from one or more campaigns.
 /// </summary>
 /// <param name="campaignIds">A list of the campaign(s) from which objects should be removed.</param>
 /// <param name="searchOptions">The search options.</param>
 public async Task RemoveFromCampaignAsync(IEnumerable <int> campaignIds, ApiSearchOptions searchOptions = null) =>
 await _ontraObjects.RemoveFromCampaignAsync((ApiObjectType)_objectTypeId, campaignIds, searchOptions);
 /// <summary>
 /// Removes one or more tags from one or more objects by the tag name.
 /// </summary>
 /// <param name="tagNames">A list of the names of the tag(s) which should be removed from objects.</param>
 /// <param name="searchOptions">The search options.</param>
 public async Task RemoveTagNamesAsync(IEnumerable <string> tagNames, ApiSearchOptions searchOptions = null) =>
 await _ontraObjects.RemoveTagNamesAsync((ApiObjectType)_objectTypeId, tagNames, searchOptions);
 /// <summary>
 /// Removes one or more objects from one or more campaigns.
 /// </summary>
 /// <param name="searchOptions">The search options.</param>
 /// <param name="campaignIds">A list of the campaign(s) from which objects should be removed.</param>
 public async Task RemoveFromCampaignAsync(ApiSearchOptions searchOptions, IEnumerable <int> campaignIds) =>
 await _ontraObjects.RemoveFromCampaignAsync((ApiObjectType)_objectTypeId, searchOptions, campaignIds).ConfigureAwait(false);
 /// <summary>
 /// Unpauses rules, sequences, and sequence subscribers.
 /// </summary>
 /// <param name="searchOptions">The search options.</param>
 public async Task UnpauseRuleOrSequenceAsync(ApiSearchOptions searchOptions) =>
 await _ontraObjects.UnpauseRuleOrSequenceAsync((ApiObjectType)_objectTypeId, searchOptions).ConfigureAwait(false);
Ejemplo n.º 30
0
        /// <summary>
        /// Retrieves information about a collection of objects, such as the number of objects that match the given criteria.
        /// </summary>
        /// <param name="objectType">The object type.</param>
        /// <param name="searchOptions">The search options.</param>
        /// <returns>A ResponseCollectionInfo object.</returns>
        public async Task <ResponseCollectionInfo> GetCollectionInfoAsync(ApiObjectType objectType, ApiSearchOptions searchOptions = null)
        {
            var query = new Dictionary <string, object>
            {
                { "objectID", (int)objectType },
            }
            .AddSearchOptions(searchOptions);

            return(await _apiRequest.GetAsync <ResponseCollectionInfo>(
                       "objects/getInfo", query));
        }