use of com.microsoft.graph.extensions.IEventCollectionPage in project android-java-snippets-sample by microsoftgraph.
the class EventsSnippets method getEventsSnippets.
static EventsSnippets[] getEventsSnippets() {
return new EventsSnippets[] { // Marker element
new EventsSnippets(null) {
@Override
public void request(ICallback callback) {
// No implementation
}
}, /*
* Get all events for the signed in user.
* GET https://graph.microsoft.com/{version}/me/events
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_list_events
*/
new EventsSnippets<JsonObject>(get_user_events) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().getEvents().buildRequest().get(new ICallback<IEventCollectionPage>() {
@Override
public void success(IEventCollectionPage iEventCollectionPage) {
callback.success(iEventCollectionPage.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /*
* Adds an event to the signed-in user\'s calendar.
* POST https://graph.microsoft.com/{version}/me/events
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_post_events
*/
new EventsSnippets<JsonObject>(create_event) {
@Override
public void request(final ICallback<JsonObject> callback) {
Event event = createEventObject();
mGraphServiceClient.getMe().getEvents().buildRequest().post(event, new ICallback<Event>() {
@Override
public void success(Event event) {
callback.success(event.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /*
* Update an event
* PATCH https://graph.microsoft.com/{version}/me/events/{Event.Id}
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/event_update
*/
new EventsSnippets<JsonObject>(update_event) {
@Override
public void request(final ICallback<JsonObject> callback) {
Event event = createEventObject();
mGraphServiceClient.getMe().getEvents().buildRequest().post(event, new ICallback<Event>() {
@Override
public void success(Event event) {
// Update the event object
event.subject = "Updated event";
mGraphServiceClient.getMe().getEvents().byId(event.id).buildRequest().patch(event, new ICallback<Event>() {
@Override
public void success(Event event) {
callback.success(event.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /*
* Delete an event
* DELETE https://graph.microsoft.com/{version}/me/events/{Event.Id}
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/event_delete
*/
new EventsSnippets<JsonObject>(delete_event) {
@Override
public void request(final ICallback<JsonObject> callback) {
Event event = createEventObject();
mGraphServiceClient.getMe().getEvents().buildRequest().post(event, new ICallback<Event>() {
@Override
public void success(Event event) {
// Update the event object
event.subject = "Updated event";
mGraphServiceClient.getMe().getEvents().byId(event.id).buildRequest().delete(new ICallback<Void>() {
@Override
public void success(Void aVoid) {
callback.success(null);
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
} };
}
Aggregations