diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/gcore-angular.js b/gcore-angular.js index 68154da..bcd6ec9 100644 --- a/gcore-angular.js +++ b/gcore-angular.js @@ -173,8 +173,49 @@ angular.module('gcore', ['ngCookies']) }); }, - - /*** Orders ***/ + + /*** Re-factored Reports ***/ + reports: { + list: function( store, type, params ) { + var url = endpoint + "/stores/" + store + "/reports/" + type; + url += self.url_params(params); + return $http.get( + url, {headers: self.get_request_headers()} + ); + }, + update: function ( store, type, params ) { + var url = endpoint + "/stores/" + store + "/reports/" + type; + url += self.url_params(params); + return $http.put( + url, + params['_json'] ? JSON.stringify(params['_json']) : JSON.stringify(params), + {headers: self.get_request_headers()} + ); + } + }, + + /*** Re-factored Orders ***/ + orders: { + list: function( id, params ) { + + if (id !== null || undefined) { + self.list_orders(params); + } + else { + self.show_orders(id, params); + } + }, + update: function ( id, params ) { + if (id !== null || undefined) { + self.update_orders(id, params); + } + else { + self.mass_update_orders(params); + } + } + }, + + /*** Orders ***/ list_orders: function(params) { @@ -226,9 +267,58 @@ angular.module('gcore', ['ngCookies']) {headers: self.get_request_headers()} ); }, - - - /*** Products ***/ + + /*** Re-Factored Products ***/ + products: { + list: function( id, params ) { + var url; + if (id !== null || undefined) { + url = endpoint + "/stores/" + params['stores'] + "/products" + id; + url += self.url_params(params); + return $http.get( + url, {headers: self.get_request_headers()} + ); + } + else { + self.list_products(params); + } + }, + update: function ( id, params ) { + var url; + if (id !== null || undefined) { + url = endpoint + "/stores/" + params['stores'] + "/products" + id; + } + else { + url = endpoint + "/stores/" + params['stores'] + "/products"; + } + return $http.put( + url, + params['_json'] ? JSON.stringify(params['_json']) : JSON.stringify(params), + {headers: self.get_request_headers()} + ); + }, + create: function ( params ) { + var url = endpoint + "/stores/" + params['stores'] + "/products"; + return $http.post( + url, + params['_json'] ? JSON.stringify(params['_json']) : JSON.stringify(params), + {headers: self.get_request_headers()} + ); + }, + remove: function ( id, params ) { + var url = null; + if (id !== null || undefined) { + url = endpoint + "/stores/" + params['stores'] + "/products" + id; + } + return $http.delete( + url, + params['_json'] ? JSON.stringify(params['_json']) : JSON.stringify(params), + {headers: self.get_request_headers()} + ); + } + }, + + /*** Products ***/ list_products: function(params) {