Skip to content

Instantly share code, notes, and snippets.

@vistajess
Created November 26, 2016 18:49
Show Gist options
  • Save vistajess/d49090e538baca96d6a9c1f884a2cac6 to your computer and use it in GitHub Desktop.
Save vistajess/d49090e538baca96d6a9c1f884a2cac6 to your computer and use it in GitHub Desktop.
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