/// <summary> /// The Subscribe method /// </summary> /// <param name="merchantId">The merchantId parameter</param> /// <param name="eventTypeId">The eventTypeId parameter</param> /// <param name="description">The description parameter</param> /// <param name="notificationType">The notificationType parameter</param> /// <param name="notificationEndpoint">The notificationEndpoint parameter</param> /// <returns>The AuthNet.PoC.EventModel.Entities.Subscription type object</returns> public override Subscription Subscribe(int merchantId, int eventTypeId, string description, string notificationType, NotificationEndpoint notificationEndpoint) { return Business.SubscribeV2(merchantId, eventTypeId, description, notificationType, notificationEndpoint); }
/// <summary> /// The Subscribe method /// </summary> /// <param name="merchantId">The merchantId parameter</param> /// <param name="eventTypeId">The eventTypeId parameter</param> /// <param name="description">The description parameter</param> /// <param name="notificationType">The notificationType parameter</param> /// <param name="notificationEndpoint">The notificationEndpoint parameter</param> /// <returns>The AuthNet.PoC.EventModel.Entities.Subscription type object</returns> public virtual Subscription Subscribe(int merchantId, int eventTypeId, string description, string notificationType, NotificationEndpoint notificationEndpoint) { return this.Business.Subscribe(merchantId, eventTypeId, description, notificationType, notificationEndpoint); }
/// <summary> /// The SubscribeToEvent method subscribes to an event /// </summary> /// <param name="subscriberId">The subscriberId parameter</param> /// <param name="eventTypeId">The eventTypeId parameter</param> /// <param name="description">The description parameter</param> /// <param name="notificationType">The notificationType parameter</param> /// <param name="notificationEndpoint">The notificationEndpoint parameter</param> /// <returns>The AuthNet.PoC.EventModel.Entities.Subscription type object</returns> public Subscription SubscribeToEvent(int subscriberId, int eventTypeId, string description, string notificationType, NotificationEndpoint notificationEndpoint) { Subscription events = new Subscription(); List<DbParameter> parameters = new List<DbParameter>(); parameters.Add(new IntParameter(Constants.Parameters.SubscriberId, subscriberId)); parameters.Add(new IntParameter(Constants.Parameters.EventTypeId, eventTypeId)); parameters.Add(new StringParameter(Constants.Parameters.Description, description)); parameters.Add(new StringParameter(Constants.Parameters.NotificationType, notificationType)); int subscriptionId = 0; using (IDataReader reader = ExecuteStoredProcReader(Constants.StoredProcedures.GetSubscribers, parameters)) { while (reader.Read()) { subscriptionId = int.Parse(reader[0].ToString()); } } List<DbParameter> innerParameters = new List<DbParameter>(); if (notificationType.Equals("Email")) { EmailNotificationSetting emailAddress = (EmailNotificationSetting)notificationEndpoint; string email = emailAddress.EmailAddress; innerParameters.Add(new IntParameter("subscriptionId", subscriptionId)); innerParameters.Add(new StringParameter("email", email)); this.ExecuteStoredProcNonQuery("CreateEmailNotificationSetting", innerParameters); } else if (notificationType.Equals("SMS")) { SmsNotificationSetting phoneNumber = (SmsNotificationSetting)notificationEndpoint; string phone = phoneNumber.PhoneNumber; innerParameters.Add(new IntParameter("subscriptionId", subscriptionId)); innerParameters.Add(new StringParameter("phone", phone)); this.ExecuteStoredProcNonQuery("CreateSmsNotificationSetting", innerParameters); } else if (notificationType.Equals("Webhook")) { WebhookNotificationSetting webhook = (WebhookNotificationSetting)notificationEndpoint; string webUrl = webhook.Url; innerParameters.Add(new IntParameter("subscriptionId", subscriptionId)); innerParameters.Add(new StringParameter("Url", webUrl)); this.ExecuteStoredProcNonQuery("CreateWebhookNotificationSetting", innerParameters); } return events; }
/// <summary> /// The SubscribeV2 method overload /// </summary> /// <param name="merchantId">The merchantId parameter</param> /// <param name="eventTypeId">The eventTypeId parameter</param> /// <param name="description">The description parameter</param> /// <param name="notificationType">The notificationType parameter</param> /// <param name="notificationEndpoint">The notificationEndpoint parameter</param> /// <returns>returns subscription object</returns> public Subscription SubscribeV2(int merchantId, int eventTypeId, string description, string notificationType, NotificationEndpoint notificationEndpoint) { return this.subscriptionDAL.SubscribeToEvent(merchantId, eventTypeId, description, notificationType, notificationEndpoint); }
/// <summary> /// The GetNotification method gets the notification /// </summary> /// <param name="notificationType">The notificationType parameter</param> /// <param name="connectionString">The connectionString parameter</param> /// <param name="subscriptionId">The subscriptionId parameter</param> /// <returns>returns the notification endpoint object</returns> public NotificationEndpoint GetNotification(string notificationType, string connectionString, int subscriptionId) { NotificationEndpoint newNotification = new NotificationEndpoint(); List<DbParameter> parameters = new List<DbParameter>(); parameters.Add(new IntParameter("subscriptionId", subscriptionId)); if (string.Compare(notificationType, "Email") == 0) { EmailNotificationSetting emailNotification = new EmailNotificationSetting() { NotificationType = AuthNet.PoC.EventModel.Entities.NotificationTypes.Email }; using (IDataReader reader = ExecuteStoredProcReader("GetEmailNotificationSetting", parameters)) { while (reader.Read()) { emailNotification.EmailAddress = reader[2].ToString(); } } newNotification = emailNotification; } else if (string.Compare(notificationType, "SMS") == 0) { SmsNotificationSetting smsNotification = new SmsNotificationSetting() { NotificationType = NotificationTypes.SMS }; using (IDataReader reader = ExecuteStoredProcReader("GetSmsNotificationSetting", parameters)) { while (reader.Read()) { smsNotification.PhoneNumber = reader[2].ToString(); } } newNotification = smsNotification; } else if (string.Compare(notificationType, "Webhook") == 0) { WebhookNotificationSetting webhookNotification = new WebhookNotificationSetting() { NotificationType = NotificationTypes.Webhook }; using (IDataReader reader = ExecuteStoredProcReader("GetWebhookNotificationSetting", parameters)) { while (reader.Read()) { webhookNotification.Url = reader[2].ToString(); } } newNotification = webhookNotification; } return newNotification; }