コード例 #1
0
        protected string GetAssociationRoute <T, TAssoc>(IHubSpotObject fromObject)
            where T : IHubSpotObject
            where TAssoc : IHubSpotObject
        {
            var toObject = Activator.CreateInstance <TAssoc>();

            return(GetRoute <T>(fromObject.Id, "associations", toObject.ObjectType));
        }
コード例 #2
0
        public async Task <ListResult <TTo> > ListAssociationsAsync <TTo>(IHubSpotObject fromObject, CancellationToken cancellationToken = default)
            where TTo : IHubSpotObject, new()
        {
            var path   = GetAssociationRoute <T, TTo>(fromObject);
            var result = await _client.ExecuteAsync <ListResult <TTo> >(path, Method.GET, cancellationToken);

            return(result);
        }
コード例 #3
0
        public CreateRequest(IHubSpotObject obj)
        {
            var properties = obj.GetType().GetProperties();

            foreach (var prop in properties)
            {
                var memberAttrib = prop.GetCustomAttribute(typeof(DataMemberAttribute)) as DataMemberAttribute;
                var value        = prop.GetValue(obj);

                if (value == null || memberAttrib == null)
                {
                    continue;
                }

                Properties[memberAttrib.Name] = value;
            }
        }
コード例 #4
0
 protected string GetAssociationRoute <T>(IHubSpotObject fromObject, IHubSpotObject toObject)
     where T : IHubSpotObject
 {
     return(GetRoute <T>(fromObject.Id, "associations", toObject.ObjectType,
                         toObject.Id, $"{fromObject.ObjectType}_to_{toObject.ObjectType}"));
 }
コード例 #5
0
        public Task UnassociateAsync(IHubSpotObject fromObject, IHubSpotObject toObject, CancellationToken cancellationToken = default)
        {
            var path = GetAssociationRoute <T>(fromObject, toObject);

            return(_client.ExecuteOnlyAsync(path, Method.DELETE, cancellationToken));
        }
コード例 #6
0
 public UpdateRequest(IHubSpotObject obj) : base(obj)
 {
     Id = Properties["id"].ToString();
     Properties.Remove("id");
 }