mapping
7 years ago
angular-chosen.directive.js
7 years ago
attributes.service.js
7 years ago
autodetect.directive.js
7 years ago
cascade.directive.js
7 years ago
contenteditable.directive.js
7 years ago
currency.service.js
7 years ago
droppable.directive.js
7 years ago
export.service.js
7 years ago
focusMeWhenEnabled.directive.js
7 years ago
googleCategoriesService.js
7 years ago
main.controller.js
7 years ago
styledInput.directive.js
7 years ago
template.service.js
7 years ago
tipsy.directive.js
7 years ago
wpHttp.service.js
7 years ago
export.service.js
41 lines
| 1 | GoogleMerchants.factory('exportService', ['$q', '$log', 'wpHttp', function($q, $log, wpHttp){ |
| 2 | |
| 3 | var getExport = function(id) { |
| 4 | |
| 5 | var deferred = $q.defer(); |
| 6 | |
| 7 | var query = 'export/get'; |
| 8 | |
| 9 | if(id !== null) { |
| 10 | query = query + '&id='+id; |
| 11 | } |
| 12 | wpHttp.get(query).then(function(data){ |
| 13 | deferred.resolve(data); |
| 14 | }, function(msg, code){ |
| 15 | deferred.reject(msg,code); |
| 16 | $log.error('There was a problem getting the export'); |
| 17 | }); |
| 18 | |
| 19 | return deferred.promise; |
| 20 | }; |
| 21 | |
| 22 | var saveExport = function(exportData) { |
| 23 | var deferred = $q.defer(); |
| 24 | |
| 25 | var url = 'export/save'; |
| 26 | |
| 27 | wpHttp.post(url , exportData).then(function(data){ |
| 28 | deferred.resolve(data); |
| 29 | },function(msg,code){ |
| 30 | deferred.reject(msg); |
| 31 | $log.error(msg,code); |
| 32 | }); |
| 33 | |
| 34 | return deferred.promise; |
| 35 | }; |
| 36 | |
| 37 | return { |
| 38 | getExport: getExport, |
| 39 | saveExport: saveExport |
| 40 | } |
| 41 | }]); |