Ejemplo n.º 1
0
        public void Notify(string key, object queryString = null, object body = null)
        {
            try
            {
                if (!ConfigSection.Webhook.Hooks.Enable)
                {
                    return;
                }

                var qs   = ClientHelpers.GetQueryString(queryString);
                var json = ClientHelpers.GetJsonBody(body);

                var data = ConfigSection.Webhook.Data[key];
                if (data.Method == "GET")
                {
                    var url = data.Url + (data.Url.Contains("?") ? "&" : "?") + qs;
                    _client.httpGetRequest(url);
                }
                else if (data.Method == "POST")
                {
                    _client.httpPostRequest(data.Url, json);
                }
                else
                {
                    throw new NotImplementedException(String.Format("Http method {0} is not implemented yet", data.Method));
                }
            }
            catch (Exception ex)
            {
                if (OnError != null)
                {
                    OnError(ex);
                }
            }
        }