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)); }
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); }
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; } }
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}")); }
public Task UnassociateAsync(IHubSpotObject fromObject, IHubSpotObject toObject, CancellationToken cancellationToken = default) { var path = GetAssociationRoute <T>(fromObject, toObject); return(_client.ExecuteOnlyAsync(path, Method.DELETE, cancellationToken)); }
public UpdateRequest(IHubSpotObject obj) : base(obj) { Id = Properties["id"].ToString(); Properties.Remove("id"); }