示例#1
0
 /// <summary>
 /// Reads contacts from bronto using a filter and the specified return fields and information
 /// </summary>
 /// <param name="filter">The filter to use when reading</param>
 /// <param name="options">The fields and information to return. Use the extension methods on the readDeliveries class to specify options</param>
 /// <returns>the list of contacts</returns>
 public List <deliveryObject> Read(deliveryFilter filter, readDeliveries options = null)
 {
     if (filter == null)
     {
         throw new ArgumentNullException("filter", "The filter must be specified. Alternatively call the Read() function");
     }
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
     {
         readDeliveries c = options ?? new readDeliveries();
         c.filter     = filter;
         c.pageNumber = 1;
         List <deliveryObject> list   = new List <deliveryObject>();
         deliveryObject[]      result = client.readDeliveries(session.SessionHeader, c);
         if (result != null)
         {
             list.AddRange(result);
         }
         while (result != null && result.Length > 0)
         {
             c.pageNumber += 1;
             result        = client.readDeliveries(session.SessionHeader, c);
             if (result != null)
             {
                 list.AddRange(result);
             }
         }
         return(list);
     }
 }
示例#2
0
        /// <summary>
        /// Reads contacts from bronto using a filter and the specified return fields and information
        /// </summary>
        /// <param name="filter">The filter to use when reading</param>
        /// <param name="options">The fields and information to return. Use the extension methods on the readMessages class to specify options</param>
        /// <returns>the list of contacts</returns>
        public async Task <List <messageObject> > ReadAsync(messageFilter filter, readMessages options = null)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter", "The filter must be specified. Alternatively call the Read() function");
            }
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
            {
                readMessages c = options ?? new readMessages();
                c.filter     = filter;
                c.pageNumber = 1;
                List <messageObject> list     = new List <messageObject>();
                readMessagesResponse response = await client.readMessagesAsync(session.SessionHeader, c);

                messageObject[] result = response.@return;
                if (result != null)
                {
                    list.AddRange(result);
                }
                while (result != null && result.Length > 0)
                {
                    c.pageNumber += 1;
                    response      = await client.readMessagesAsync(session.SessionHeader, c);

                    result = response.@return;
                    if (result != null)
                    {
                        list.AddRange(result);
                    }
                }
                return(list);
            }
        }
示例#3
0
        /// <summary>
        /// Add or updates a list of contacts in Bronto
        /// </summary>
        /// <param name="contact">The contacts to add or update</param>
        /// <returns>The result of the add or update operation <seealso cref="BrontoResult"/></returns>
        public BrontoResult AddOrUpdateIncremental(IEnumerable <contactObject> contacts)
        {
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
            {
                foreach (contactObject contact in contacts)
                {
                    var address = new stringValue {
                        value = contact.email
                    };

                    var emailAddressArray = new[] { address };

                    var filter = new contactFilter
                    {
                        email = emailAddressArray
                    };

                    var options = new readContacts()
                    {
                        includeLists          = true,
                        includeListsSpecified = true
                    };
                    var readResults     = Read(filter, options);
                    var existingContact = readResults.FirstOrDefault();

                    if (existingContact != null)
                    {
                        contact.listIds = contact.listIds.Concat(existingContact.listIds).ToArray();
                    }
                }
                writeResult response = client.addOrUpdateContacts(session.SessionHeader, contacts.ToArray());
                return(BrontoResult.Create(response));
            }
        }
示例#4
0
 public BrontoResult Add(IEnumerable <deliveryObject> deliveries)
 {
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
     {
         writeResult response = client.addDeliveries(session.SessionHeader, deliveries.ToArray());
         return(BrontoResult.Create(response));
     }
 }
示例#5
0
 public BrontoResult Delete(IEnumerable <mailListObject> mailLists)
 {
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
     {
         writeResult response = client.deleteLists(session.SessionHeader, mailLists.ToArray());
         return(BrontoResult.Create(response));
     }
 }
示例#6
0
 /// <summary>
 /// Updates a list of contacts in Bronto
 /// </summary>
 /// <param name="contacts">the list of contacts to update</param>
 /// <returns>The result of the add operation <seealso cref="BrontoResult"/></returns>
 public BrontoResult Update(IEnumerable <contactObject> contacts)
 {
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
     {
         writeResult response = client.updateContacts(session.SessionHeader, contacts.ToArray());
         return(BrontoResult.Create(response));
     }
 }
示例#7
0
        public async Task <BrontoResult> DeleteAsync(IEnumerable <mailListObject> mailLists)
        {
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
            {
                deleteListsResponse response = await client.deleteListsAsync(session.SessionHeader, mailLists.ToArray());

                return(BrontoResult.Create(response.@return));
            }
        }
示例#8
0
        /// <summary>
        /// Add or updates a list of contact in Bronto
        /// </summary>
        /// <param name="contact">The contacts to add or update</param>
        /// <returns>The result of the add or update operation <seealso cref="BrontoResult"/></returns>
        public async Task <BrontoResult> AddOrUpdateAsync(IEnumerable <contactObject> contacts)
        {
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
            {
                addOrUpdateContactsResponse response = await client.addOrUpdateContactsAsync(session.SessionHeader, contacts.ToArray());

                return(BrontoResult.Create(response.@return));
            }
        }
示例#9
0
        /// <summary>
        /// Creates a new Login session
        /// </summary>
        /// <param name="ApiToken">A valid API token. See dev.bronto.com for details</param>
        /// <returns>The Login session</returns>
        public static async Task <LoginSession> CreateAsync(string ApiToken)
        {
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create())
            {
                LoginSession  login    = new LoginSession();
                loginResponse response = await client.loginAsync(ApiToken);

                login.SessionId = response.@return;
                return(login);
            }
        }
示例#10
0
 /// <summary>
 /// Creates a new Login session
 /// </summary>
 /// <param name="ApiToken">A valid API token. See dev.bronto.com for details</param>
 /// <returns>The Login session</returns>
 public static LoginSession Create(string ApiToken)
 {
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create())
     {
         LoginSession login = new LoginSession()
         {
             SessionId = client.login(ApiToken)
         };
         return(login);
     }
 }
示例#11
0
 /// <summary>
 /// Creates a new Login session
 /// </summary>
 /// <param name="ApiToken">A valid API token. See dev.bronto.com for details</param>
 /// <returns>The Login session</returns>
 public static LoginSession Create(string ApiToken)
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create())
     {
         LoginSession login = new LoginSession()
         {
             SessionId = client.login(ApiToken)
         };
         return(login);
     }
 }
示例#12
0
 /// <summary>
 /// Adds a list of contacts to a mailing list
 /// </summary>
 /// <param name="list">the list to add</param>
 /// <param name="contacts">the list of contacts to add</param>
 /// <returns>The result of the addToList operation <seealso cref="BrontoResult"/></returns>
 public BrontoResult AddToList(mailListObject list, contactObject[] contacts)
 {
     using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
     {
         addToList addToList = new addToList()
         {
             list     = list,
             contacts = contacts
         };
         writeResult response = client.addToList(session.SessionHeader, addToList);
         return(BrontoResult.Create(response));
     }
 }