APIGallery ES6 refactoring

This commit is contained in:
tmshv committed 2016-02-20 17:03:06 +03:00
1 parent 59b99cdad8
commit f863db1d0a
3 files changed
+18 -24

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
/**
* Created by tmshv on 22/11/14.
*/
import EndPoint from './EndPoint';
export default class APIGallery extends EndPoint {
year(year) {
return this.request.get(`/gallery/${year}`, {cache: true});
}
album(year, course, album) {
let url = `/gallery/${year}/${course}/${album}`;
return this.request.get(url, {cache: true});
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
*/
import APIFeed from './APIFeed';
var APIGallery = require("./gallery");
import APIGallery from './APIGallery';
import APIDocument from './APIDocument';
module.exports = function (app) {
@@ -12,7 +12,7 @@ module.exports = function (app) {
app.factory("api", function ($http) {
var api = {};
api.news = new APIFeed($http);
api.gallery = new APIGallery($http, minute);
api.gallery = new APIGallery($http);
api.document = new APIDocument($http);
return api;
-22
View File
@@ -1,22 +0,0 @@
/**
* Created by tmshv on 22/11/14.
*/
function APIGallery(http){
this.request = http;
}
APIGallery.prototype.year = function(year) {
return this.request.get("/gallery/" + year, {cache: true});
};
APIGallery.prototype.album = function(year, course, album) {
var url = '/gallery/{year}/{course}/{album}'
.replace('{year}', year)
.replace('{course}', course)
.replace('{album}', album);
return this.request.get(url, {cache: true});
};
module.exports = APIGallery;