Beispiel #1
0
        public T Execute <T>(MandrillRestRequest request) where T : new()
        {
            var response = _client.Execute <T>(request);


            return(response.Data);
        }
Beispiel #2
0
        public string Execute(MandrillRestRequest request)
        {
            var res = _client.Execute(request);

            ValidateMandrillRestResponse((RestResponse)res);
            return(res.Content);
        }
Beispiel #3
0
        /// <summary>Sendtemplate will Send a new transactional message through Mandrill using a template</summary>
        /// <param name="key">the users api key</param>
        /// <param name="TemplateName">A string value of the name of the template</param>
        /// <param name="templateContent">An array of template content</param>
        /// <param name="message">A message struct of the other info to send (same as messagesend w/out the html)</param>
        /// <returns>A struct of type RecipientReturn</returns>
        public List <RecipientReturn> sendtemplate(string TemplateName, List <object> templateContent, object message)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/send-template.xml", messages)
            };

            request.AddBody(new { key = _ApiKey, template_name = TemplateName, template_content = templateContent, message = message });
            return(Execute <List <RecipientReturn> >(request));
        }
Beispiel #4
0
        /// <summary>Get the list of all webhooks defined on the account</summary>
        /// <param name="key">the users api key</param>
        /// <returns>A struct of the webhook information</returns>
        public WebhookInfo Webhookslist()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/list.json", webhooks)
            };

            request.AddBody(new { key = _ApiKey });
            return(Execute <WebhookInfo>(request));
        }
Beispiel #5
0
        /// <summar>Return the recent history (hourly stats for the last 30 days) for a template</summar></summary>
        /// <param name="key">the users api key</param>
        /// <param name="name">the name of an existing template</param>
        /// <returns>the array of history information</returns>
        public List <TemplateTimeSeries> TemplateTimeSeries(string name)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/time-series.json", templates)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <List <TemplateTimeSeries> >(request));
        }
Beispiel #6
0
        /// <summaryReturn all of the user-defined tag information</summary>
        /// <param name="key">the users api key</param>
        /// <param name="tag"> an existing tag name</param>
        /// <returns>struct of the detailed information about the tag</returns>
        public List <DetailedTags> info(string tag)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/info.json", tags)
            };

            request.AddBody(new { key = _ApiKey, tag = tag });

            return(Execute <List <DetailedTags> >(request));
        }
Beispiel #7
0
        /// <summary>Return the 100 most clicked URLs that match the search query given</summary>
        /// <param name="key">the users api key</param>
        /// <param name="q">a search query</param>
        /// <returns>the 100 most clicked URLs and their stats</returns>
        public List <URLStats> UrlSearch(string q)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/search.json", url)
            };

            request.AddBody(new { key = _ApiKey, q = q });

            return(Execute <List <URLStats> >(request));
        }
Beispiel #8
0
        /// <summary>"time-series" Return the recent history (hourly stats for the last 30 days) for a sender</summary>
        /// <param name="key">the users api key</param>
        /// <param name="address">The email address of the sender</param>
        /// <returns>the array of history information</returns>
        public List <TimeSeries> SenderTimeSeries(string Address)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/time-series.json", sender)
            };

            request.AddBody(new { key = _ApiKey, address = Address });

            return(Execute <List <TimeSeries> >(request));
        }
Beispiel #9
0
        /// <summary>"Domains" Returns the sender domains that have been added to this account.</summary>
        /// <param name="key">the users api key</param>
        /// <returns>Return the senders that have tried to use this account.</returns>
        public List <SenderDomains> SenderDomains()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/domains.json", sender)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <List <SenderDomains> >(request));
        }
Beispiel #10
0
        /// <summary>Search the content of recently sent messages and optionally narrow by date range, tags and senders</summary>
        /// <param name="key">the users api key</param>
        /// <param name="query">the search items to find matching messages to</param>
        /// <param name="date_from">start date</param>
        /// <param name="date_to">end date</param>
        /// <param name="tags">array of string containing tag names</param>
        /// <param name="senders">array of senders addresses</param>
        /// <param name="limit">maximum number of results to return</param>
        /// <returns>A struct of type RecipientReturn</returns>
        public List <SearchReturn> search(string query, string date_from, string date_to, List <string> tags, List <string> senders, int limit)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/search.xml", messages)
            };

            request.AddBody(new { key = _ApiKey, query = query, date_from = date_from, tags = tags, senders = senders, limit = limit });

            return(Execute <List <SearchReturn> >(request));
        }
Beispiel #11
0
        /// <summary>Send will send a new transactional message through Mandrill</summary>
        /// <param name="key">the users api key</param>
        /// <param name="T">The message data</param>
        /// <returns>A struct of type RecipientReturn</returns>
        public List <RecipientReturn> send(object T)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/search.json", messages)
            };

            request.AddBody(new { key = _ApiKey, message = T });

            return(Execute <List <RecipientReturn> >(request));
        }
Beispiel #12
0
        /// <summary>Update an existing webhook</summary>
        /// <param name="key">the users api key</param>
        /// <param name="id">the unique identifier of a webhook belonging to this account</param>
        /// <param name="url">the URL to POST batches of events</param>
        /// <param name="T">an optional list of events that will be posted to the webhook</param>
        /// <returns>the information for the updated webhook</returns>
        public WebhookInfo Webhooksupdate(int id, string url, List <object> T)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/update.json", webhooks)
            };

            request.AddBody(new { key = _ApiKey, id = id, url = url, events = T });

            return(Execute <WebhookInfo>(request));
        }
Beispiel #13
0
        /// <summary>Add a new webhook</summary>
        /// <param name="key">the users api key</param>
        /// <param name="url">the URL to POST batches of events</param>
        /// <param name="T">an optional list of events that will be posted to the webhook</param>
        /// <returns>the information saved about the new webhook</returns>
        public WebhookInfo Webhooksadd(string url, List <object> T)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/add.json", webhooks)
            };

            request.AddBody(new { key = _ApiKey, message = T });

            return(Execute <WebhookInfo>(request));
        }
Beispiel #14
0
        /// <summaryReturn the recent history (hourly stats for the last 30 days) for a tag</summary>
        /// <param name="key">the users api key</param>
        /// <returns>struct of the detailed information about the tag</returns>
        public List <TimeSeries> AllTimeSeries()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/all-time-series.json", tags)
            };

            request.AddBody(new { key = _ApiKey });

            return(Execute <List <TimeSeries> >(request));
        }
Beispiel #15
0
        /// <summar>Delete a template</summar></summary>
        /// <param name="key">the users api key</param>
        /// <param name="name">the name of an existing template</param>
        /// <returns>the information saved about the deleted template</returns>
        public TemplateInfo Templatedelete(string name)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/delete.json", templates)
            };

            request.AddBody(new { key = _ApiKey, name = name });

            return(Execute <TemplateInfo>(request));
        }
Beispiel #16
0
        /// <summary>Retrieves your email rejection blacklist. You can provide an email
        /// address to limit the results. Returns up to 1000 results</summary>
        /// <param name="key">the users api key</param>
        /// <param name="Email">an optional email address to search by</param>
        /// <returns>the information for each rejection blacklist entry</returns>
        public List <BlackList> list(string Email)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/list.xml", tags)
            };

            request.AddBody(new { key = _ApiKey, email = Email });

            return(Execute <List <BlackList> >(request));
        }
Beispiel #17
0
        /// <summar>Delete a template</summar></summary>
        /// <param name="key">the users api key</param>
        /// <returns>an array of the information about each template</returns>
        public List <TemplateInfo> Templatelist()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/list.json", templates)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <List <TemplateInfo> >(request));
        }
Beispiel #18
0
        /// <summary>Deletes an email rejection. There is no limit to how many rejections
        /// you can remove from your blacklist, but keep in mind that each deletion
        /// has an affect on your reputation.</summary>
        /// <param name="key">the users api key</param>
        /// <param name="Email">an email address</param>
        /// <returns>a status object containing the address and whether the deletion succeeded.</returns>
        public List <DeletedSuccesses> delete(string Email)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/delete.xml", tags)
            };

            request.AddBody(new { key = _ApiKey, email = Email });

            return(Execute <List <DeletedSuccesses> >(request));
        }
Beispiel #19
0
        /// <summary>Info returns more detailed information about a single sender,
        /// including aggregates of recent stats</summary>
        /// <param name="key">the user api key</param>
        /// <param name="address">The email address of the sender</param>
        /// <returns>a struct of the detailed information about the sender</returns>
        public List <SenderData> SenderInfo(string Address)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/info.json", sender)
            };

            request.AddBody(new { key = _ApiKey, address = Address });

            return(Execute <List <SenderData> >(request));
        }
Beispiel #20
0
        /// <summary>Validate an API key and respond to a ping (anal JSON parser version)</summary>
        /// <param name="key">the users api key</param>
        /// <returns>a struct with one key "PING" with a static value "PONG!"</returns>
        public string Ping2()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/ping2.xml", users)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute(request).ToString());
        }
Beispiel #21
0
        /// <summary>Get the 100 most clicked URLs</summary>
        /// <param name="key">the users api key</param>
        /// <returns>the 100 most clicked URLs and their stats</returns>
        public List <URLStats> UrlList()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/list.json", url)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <List <URLStats> >(request));
        }
Beispiel #22
0
        /// <summary> "Info" retrieves infomation about the user</summary>
        /// <param name="key">the users api key</param>
        /// <returns>Return the information about the API-connected user</returns>
        //public UserInformation info()
        public object info()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/info.xml", users)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <UserInformation>(request));
        }
Beispiel #23
0
        /// <summary>Return the recent history (hourly stats for the last 30 days) for a url</summary>
        /// <param name="key">the users api key</param>
        /// <param name="url">an existing url</param>
        /// <returns>the array of history information</returns>
        public List <URLHistory> UrlTimeSeries(string url)
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/time-series.json", url)
            };

            request.AddParameter("key", _ApiKey);

            return(Execute <List <URLHistory> >(request));
        }
Beispiel #24
0
        /// <summaryReturn all of the user-defined tag information</summary>
        /// <param name="key">the users api key</param>
        /// <returns>Return the 100 most clicked URLs that match the search query given</returns>
        public List <Tags> list()
        {
            var request = new MandrillRestRequest
            {
                Method   = RestSharp.Method.POST,
                Resource = string.Format("{0}/list.json", tags)
            };

            request.AddBody(new { key = _ApiKey });

            return(Execute <List <Tags> >(request));
        }