/// <summary> /// /// </summary> /// <param name="certificateThumprint">Your cert thumbprint as registered in MSM Portal</param> /// <param name="siteId">Your site Id as generated in MSM Portal</param> /// <param name="partnerName">Application name or Partner Name</param> /// <param name="accountNameForRespectiveSfmcChildAccountAsRegistered">Specify Account Name mentioned for your Sfmc account registration with IRIS (MUCP)</param> /// <param name="externalKeyOfTriggeredSendDefnUnderThisAccountName">Specify External Key of your Triggered Send Definition</param> public void InitializeIrisApi(string certificateThumprint, long siteId, string partnerName, string accountNameForRespectiveSfmcChildAccountAsRegistered, string externalKeyOfTriggeredSendDefnUnderThisAccountName, string topicId, TimeSpan validity) { // Try to load the cert from the local machine store, fail if not present. var certificate = CertificateHelper.GetCertificateByThumbprint(certificateThumprint, StoreLocation.LocalMachine); if (certificate == null) { var message = string.Format( CultureInfo.InvariantCulture, "Unable to find client certificate with thumb-print: {0}", certificateThumprint); throw new InvalidOperationException(message); } // Getting a S2S ticket (note that we use MembershipAuthN package) s2sAuthClient = S2SAuthClient.Create(siteId, certificate, new Uri(S2SMsaIntAuthenticationEndpoint)); // Note that the endpoint can be overridden publisher = new Publisher(partnerName, certificate, ignoreServerCertificateValidation: true, endpoint: new Uri(MucpEndpoint)); exactTargetDelivery = new ExactTargetDelivery { AccountName = accountNameForRespectiveSfmcChildAccountAsRegistered, TemplateKey = externalKeyOfTriggeredSendDefnUnderThisAccountName, TopicId = topicId, Validity = validity }; }
/// <summary> /// /// </summary> /// <param name="emailRecipients"></param> /// <param name="conversationId"></param> /// <param name="properties"></param> /// <param name="exactTargetDelivery"></param> /// <param name="externalKeyOfTriggeredSendDefn"></param> /// <returns></returns> private async static Task ForwardRequestToIrisApi(EmailRecipients emailRecipients, Guid conversationId, Dictionary <string, string> properties, ExactTargetDelivery exactTargetDelivery, string externalKeyOfTriggeredSendDefn) { var appTicket = s2sAuthClient.GetAccessTokenAsync(MucpTargetSite, CancellationToken.None).Result; await publisher .CreateRequest() .WithEventName(externalKeyOfTriggeredSendDefn) .WithModelProperties(properties) .WithInstanceId(conversationId) .WithDelivery(exactTargetDelivery) .WithRecipient(emailRecipients) .WithAppTicket(appTicket) .SendAsync(TimeSpan.FromSeconds(120)).ConfigureAwait(false); }