Created
August 22, 2017 19:30
-
-
Save gusgard/4903800c5b35526a7c97259bf0e5f3d4 to your computer and use it in GitHub Desktop.
Event facade
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
import { HttpService } from 'App/src/common'; | |
import Event from './Event'; | |
class EventFacade { | |
static async create(payload) { | |
const event = Event.encode(payload); | |
const { data: { data } } = await HttpService.post('/events', event); | |
return Event.create(data); | |
} | |
static async fetchHosted() { | |
const { data: { data } } = await HttpService.get('/events'); | |
return data.map(e => Event.create(e)); | |
} | |
static async fetchInvited() { | |
const { data: { data } } = await HttpService.get('/events/invites'); | |
return data.map(e => Event.create(e)); | |
} | |
static async fetchOne(id) { | |
const { data: { data } } = await HttpService.get(`/events/${id}`); | |
return Event.create(data); | |
} | |
static async update(event) { | |
await HttpService.post(`/events/${event.id}`, event); | |
} | |
static async delete(id) { | |
await HttpService.delete(`/events/${id}`); | |
} | |
} | |
export default EventFacade; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment