예제 #1
0
        public virtual Vision6ResponseObject Add(Vision6Autoresponder autoResponder)
        {
            var requestObject = new Vision6RequestObject
            {
                Method = Methods.AddAutoresponder,
            };

            requestObject.Params.Add(autoResponder);

            return(Requestor.Post(requestObject));
        }
예제 #2
0
        public virtual Vision6ResponseObject Add(Vision6Batch batch)
        {
            var requestObject = new Vision6RequestObject
            {
                Method = Methods.AddBatch,
            };

            requestObject.Params.Add(batch.MessageId);
            requestObject.Params.Add(batch.ContactList);

            return(Requestor.Post(requestObject));
        }
예제 #3
0
        /// <summary>
        /// Adds one or more Contacts to a SMS List.
        /// </summary>
        /// <param name="listId">The ID of the List to add the Contacts to.</param>
        /// <param name="contacts">An array containing one or more associative arrays of Contact details. The Contact details are indexed using each of the Field names in the List</param>
        /// <param name="overwrite">A flag that determines how the method handles duplicates.</param>
        /// <param name="removeUnsubscribers">A flag that determines how the method handles unsubscribed Contacts. Valid values are: 0 (default), 1, 2</param>
        /// <returns></returns>
        public virtual Vision6ResponseObject AddToSmsList(int listId, List <Vision6SmsContact> contacts, bool overwrite = false, int removeUnsubscribers = 0)
        {
            var requestObject = new Vision6RequestObject
            {
                Method = Methods.AddContacts,
            };

            requestObject.Params.Add(listId);

            requestObject.Params.Add(contacts);

            requestObject.Params.Add(overwrite);

            requestObject.Params.Add(removeUnsubscribers);

            return(Requestor.Post(requestObject));
        }
예제 #4
0
        /// <summary>
        /// Returns the Lists that match the search criteria.
        /// </summary>
        /// <param name="searchCriteria">An array of search criteria [http://developers.vision6.com.au/3.0/guide/search].</param>
        /// <param name="limit"></param>
        /// <param name="offset">Number of items to skip before beginning to return results</param>
        /// <param name="sortBy">The name of the value to sort the results by.</param>
        /// <param name="sortOrder">The order the results are returned in (either ascending or descending): DESC or ASC</param>
        /// <returns></returns>
        public virtual Vision6ResponseObject Search(List <string> searchCriteria, int limit = 0, int offset = 0, string sortBy = "Name", string sortOrder = "ASC")
        {
            var requestObject = new Vision6RequestObject
            {
                Method = Methods.SearchLists,
            };

            requestObject.Params.Add(searchCriteria);

            requestObject.Params.Add(limit);

            requestObject.Params.Add(offset);

            requestObject.Params.Add(sortBy);

            requestObject.Params.Add(sortOrder);

            return(Requestor.Post(requestObject));
        }
예제 #5
0
        public virtual Vision6ResponseObject Count(int listId, int messageId)
        {
            var requestObject = new Vision6RequestObject
            {
                Method = Methods.CountAutoresponders,
            };

            var conditions = new List <object>
            {
                new Vision6SearchCondition {
                    Parameter = "list_id", Comparison = Comparisons.Exactly, Value = listId
                }.ToList(),
                new Vision6SearchCondition {
                    Parameter = "message_id", Comparison = Comparisons.Exactly, Value = messageId
                }.ToList()
            };

            requestObject.Params.Add(new List <object> {
                conditions
            });

            return(Requestor.Post(requestObject));
        }
예제 #6
0
        public static Vision6ResponseObject Post(Vision6RequestObject requestObject)
        {
            var wr = GetWebRequest();

            return(ExecuteWebRequest(wr, requestObject));
        }
예제 #7
0
        private static Vision6ResponseObject ExecuteWebRequest(WebRequest webRequest, Vision6RequestObject requestObject)
        {
            try
            {
                using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
                {
                    string json = Newtonsoft.Json.JsonConvert.SerializeObject(requestObject);

                    streamWriter.Write(json);
                    streamWriter.Flush();
                }
                using (var response = webRequest.GetResponse())
                {
                    var responseString = ReadStream(response.GetResponseStream());
                    return(Newtonsoft.Json.JsonConvert.DeserializeObject <Vision6ResponseObject>(responseString));
                }
            }
            catch (WebException webException)
            {
                if (webException.Response != null)
                {
                    var statusCode = ((HttpWebResponse)webException.Response).StatusCode;

                    Vision6Error vision6Error;

                    if (webRequest.RequestUri.ToString().Contains("oauth"))
                    {
                        vision6Error = Mapper <Vision6Error> .MapFromJson(ReadStream(webException.Response.GetResponseStream()));
                    }
                    else
                    {
                        vision6Error = Mapper <Vision6Error> .MapFromJson(ReadStream(webException.Response.GetResponseStream()), "error");
                    }

                    throw new Vision6Exception(statusCode, vision6Error, vision6Error.Message);
                }

                throw;
            }
        }