Created
November 26, 2016 18:49
-
-
Save vistajess/d49090e538baca96d6a9c1f884a2cac6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlotService { | |
/*@ngInject*/ | |
constructor($http,CONFIG_CONSTANTS,$q, AuthService) { | |
this.API_URL = CONFIG_CONSTANTS.API_URL; | |
this.$http = $http; | |
this.$q = $q; | |
this.api_token = AuthService.api_token; | |
} | |
getSlotList(floorId) { | |
const deferred = this.$q.defer(); | |
this.$http.get(`${this.API_URL}/floor/${floorId}/slot?api_token=${this.api_token}`) | |
.success(response => deferred.resolve(response)) | |
.error(error => deferred.reject(error)); | |
return deferred.promise; | |
} | |
addSlots(payload) { | |
const deferred = this.$q.defer(); | |
this.$http.post(`${this.API_URL}/floor/${payload.floorId}/slot?api_token=${this.api_token}`, payload) | |
.success(response => deferred.resolve(response)) | |
.error(error => deferred.reject(error)); | |
return deferred.promise; | |
} | |
updateSlot(payload) { | |
const deferred = this.$q.defer(); | |
this.$http.post(`${this.API_URL}/floor/${payload.floorId}/slot/${payload.slotId}?api_token=${this.api_token}`, payload) | |
.success(response => deferred.resolve(response)) | |
.error(error => deferred.reject(error)); | |
return deferred.promise; | |
} | |
} | |
SlotService.$inject = [ | |
'$http', | |
'CONFIG_CONSTANTS', | |
'$q', | |
'AuthService' | |
]; | |
export default SlotService; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment