Created
February 7, 2017 20:48
-
-
Save qetr1ck-op/c8a48683201ecd21525d635aaf53e013 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
export default class PromoCodeService { | |
constructor(Resource) { | |
this._resource = Resource; | |
} | |
create(eventId, promo) { | |
return this._resource.events(eventId).promoCodes().post(promo); | |
} | |
get(eventId, id) { | |
return this._resource.events(eventId).promoCodes(id).get().then(response => response.data); | |
} | |
getAll(eventId) { | |
return this._resource.events(eventId).promoCodes().get().then(response => response.data); | |
} | |
getAllActive(eventId) { | |
return this.getAll(eventId).then(data => { | |
if (Array.isArray(data.campaigns)) { | |
data.campaigns = data.campaigns.filter(x => x.isActive); | |
} | |
return data; | |
}); | |
} | |
delete(eventId, id) { | |
return this._resource.events(eventId).promoCodes(id).delete(); | |
} | |
update(eventId, promo) { | |
return this._resource.events(eventId).promoCodes(promo.id).put(promo); | |
} | |
patch(eventId, promo) { | |
return this._resource.events(eventId).promoCodes(promo.id).patch(promo); | |
} | |
static get $inject() { | |
return ['Resource']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment