(function ($) {

    angular.module('dashnex')

        .service('proxyManager', ['$http', function ($http) {

            return {
                add: function (proxy) {
                    return $http({
                        method: 'post',
                        url: ajaxurl,
                        data: $.extend(
                            {action: 'dashnex-proxy-add'},
                            proxy
                        ),
                        responseType: 'json'
                    })
                },
                remove: function (proxy) {
                    return $http({
                        method: 'post',
                        url: ajaxurl,
                        data: $.extend(
                            {action: 'dashnex-proxy-delete'},
                            proxy
                        ),
                        responseType: 'json'
                    })
                },
                test: function (proxy) {
                    return $http({
                        method: 'post',
                        url: ajaxurl,
                        data: {
                            action: 'dashnex-proxy-test',
                            id: proxy.id
                        },
                        responseType: 'json'
                    });
                }
            }
        }])

})(jQuery);
