示例#1
0
        /// <summary>
        /// Subscribe an email address to the target subscriber list
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <returns></returns>
        public async Task <ResultSubscriberSubscribe> SubscribeAsync(ParamSubscriberSubscribe param)
        {
            if (param.IsNull())
            {
                throw new ArgumentNullException($"{nameof( param )}");
            }

            var arry = new Dictionary <string, string> {
                { nameof(param.ListID), param.ListID.ToString() },
                { nameof(param.EmailAddress), param.EmailAddress },
                { nameof(param.SubscriptionIP), param.SubscriptionIP }
            };

            if (param.Fields.IsNotNull())
            {
                foreach (var paramField in param.Fields)
                {
                    arry.Add($"Fields[{paramField.Key}]", paramField.Value);
                }
            }

            return(await _http.Value.PostAsync <ResultSubscriberSubscribe>(SendloopAddress.SubscriberSubscribe, arry));
        }
示例#2
0
 /// <summary>
 /// Subscribe an email address to the target subscriber list
 /// </summary>
 /// <returns></returns>
 public ResultSubscriberSubscribe Subscribe(ParamSubscriberSubscribe param)
 => SubscribeAsync(param).GetAwaiter().GetResult();