/* * Copyright (C) 2016 Glyptodon LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /** * Service for operating on HTML patches via the REST API. */ angular.module('rest').factory('patchService', ['$injector', function patchService($injector) { // Required services var $http = $injector.get('$http'); var authenticationService = $injector.get('authenticationService'); var cacheService = $injector.get('cacheService'); var service = {}; /** * Makes a request to the REST API to get the list of patches, returning * a promise that provides the array of all applicable patches if * successful. Each patch is a string of raw HTML with meta information * describing the patch operation stored within meta tags. * * @returns {Promise.} * A promise which will resolve with an array of HTML patches upon * success. */ service.getPatches = function getPatches() { // Build HTTP parameters set var httpParameters = { token : authenticationService.getCurrentToken() }; // Retrieve all applicable HTML patches return $http({ cache : cacheService.patches, method : 'GET', url : 'api/patches', params : httpParameters }); }; return service; }]);