Пример #1
0
        private void LogContactFailure(IFailureDetails failure, IHubSpotContact hubSpotContact, int currentContactIndex, int contactCount)
        {
            // cast to print out the HTTP status code, just in case what's returned isn't
            // defined in the enum https://stackoverflow.com/a/22645395

            var hubSpotException = failure.Exception;

            _logger.LogWarning($@"REJECTED: contact {currentContactIndex + 1} of {contactCount}
httpstatuscode: {(int)failure.HttpStatusCode}
issue: {hubSpotException?.Message} for ({hubSpotException?.ValidationResults?.FirstOrDefault()?.Name})
error: {hubSpotException?.ValidationResults?.FirstOrDefault()?.Error}
contact: {_serializer.Serialize(hubSpotContact)}");
        }
 /// <summary>
 /// Ensures the Environment and lifecycle stage are included in the payload to be sent to HubSpot alongside each contact.
 /// </summary>
 /// <param name="hubSpotContact">Contact to which we will assign the integration attributes.</param>
 /// <param name="environmentName">Name of the environment in which the application is executing.</param>
 public static void AddTangentialAttributesToHubSpotProperties(IHubSpotContact hubSpotContact, string environmentName)
 {
     // preserve existing properties (the HashSet will keep the data clean/unique)
     hubSpotContact.Properties = new HashSet <HubSpotContactProperty>(hubSpotContact.Properties ?? Enumerable.Empty <HubSpotContactProperty>())
     {
         // captures reference metadata to pass along when updating HubSpot contact data
         new HubSpotContactProperty
         {
             Name  = "environment",
             Value = environmentName
         },
         new HubSpotContactProperty
         {
             Name  = "lifecyclestage",
             Value = "customer"
         }
     }.ToList();
 }
Пример #3
0
        private void SetFailureData(SerialSyncResult run, HttpResponseMessage response, IHubSpotContact hubSpotContact, int contactLength, int currentContactIndex)
        {
            run.FailureCount++;
            var failure = new SerialSyncFailure
            {
                HttpStatusCode = response.StatusCode,
                Exception      = _http.GetResponseContent <HubSpotException>(response),
                HubSpotContact = hubSpotContact
            };

            run.Failures.Add(failure);
            LogContactFailure(failure, hubSpotContact, currentContactIndex, contactLength);
        }