public async Task <TContact> GetAsync <TContact>(IContactSelector selector) where TContact : Contact, new() { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } var properties = _typeManager.GetCustomProperties <TContact>(TypeManager.AllProperties).Select(p => new Property(p.FieldName)).ToArray(); try { var hubspotContact = await selector.GetContact(_client, properties).ConfigureAwait(false); var contact = _typeManager.ConvertTo <TContact>(hubspotContact); return(contact); } catch (NotFoundException) { return(null); } }
public static Task <Contact> GetAsync(this IHubSpotContactConnector connector, IContactSelector selector) => connector.GetAsync <Contact>(selector);