/// <summary> /// Creates the contact entity asyncrhounously. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public async Task <T> CreateAsync <T>(IEngagementHubSpotEntity entity) where T : IHubSpotEntity, new() { Logger.LogDebug("Contact CreateAsync"); var path = PathResolver(entity, HubSpotAction.Create); var data = await PostAsync <T>(path, entity); return(data); }
/// <summary> /// Resolve a hubspot API path based off the entity and opreation that is about to happen /// </summary> /// <param name="entity"></param> /// <param name="action"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public string PathResolver(IEngagementHubSpotEntity entity, HubSpotAction action) { switch (action) { case HubSpotAction.Create: return($"{entity.RouteBasePath}/engagements"); //case HubSpotAction.Get: // return $"{entity.RouteBasePath}/contact/vid/:contactId:/profile"; //case HubSpotAction.GetByEmail: // return $"{entity.RouteBasePath}/contact/email/:contactEmail:/profile"; //case HubSpotAction.List: // return $"{entity.RouteBasePath}/lists/all/contacts/all"; //case HubSpotAction.Update: // return $"{entity.RouteBasePath}/contact/vid/:contactId:/profile"; //case HubSpotAction.Delete: // return $"{entity.RouteBasePath}/contact/vid/:contactId:"; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }