示例#1
0
        public Task <T> GetByIdAsync <T>(long lineItemId, LineItemGetRequestOptions opts = null) where T : IHubSpotEntity, new()
        {
            Logger.LogDebug("Line Item Get by id");
            var path = PathResolver(new LineItemHubSpotEntity(), HubSpotAction.Get)
                       .Replace(":lineItemId:", lineItemId.ToString());

            path = ApplyGetRequestOptions(path, opts);

            return(GetAsync <T>(path));
        }
示例#2
0
        private string ApplyGetRequestOptions(string path, LineItemGetRequestOptions opts = null)
        {
            opts ??= new LineItemGetRequestOptions();

            if (opts.PropertiesToInclude.Any())
            {
                path = path.SetQueryParam("properties", opts.PropertiesToInclude);
            }
            if (opts.PropertiesWithHistoryToInclude.Any())
            {
                path = path.SetQueryParam("propertiesWithHistory", opts.PropertiesWithHistoryToInclude);
            }
            if (opts.IncludeDeletes)
            {
                path = path.SetQueryParam("includeDeletes", "true");
            }

            return(path);
        }
示例#3
0
        public async Task <IDictionary <long, T> > ReadBatchAsync <T>(ListOfLineItemIds lineItemIds, LineItemGetRequestOptions opts = null) where T : IHubSpotEntity, new()
        {
            Logger.LogDebug("Line Item Batch Read");
            var path = PathResolver(new LineItemHubSpotEntity(), HubSpotAction.ReadBatch);

            path = ApplyGetRequestOptions(path, opts);

            var request = _serializer.SerializeEntity(lineItemIds);

            IDictionary <long, T> result = null;
            var success = await SendRequestAsync(path, HttpMethod.Post, request, response =>
            {
                result = _serializer.DeserializeDictionaryOfEntities <long, T>(response);
                return(true);
            });

            return(success ? result : new Dictionary <long, T>());
        }