package org.silverpeas.mobile.shared.services.rest;

import static org.fusesource.restygwt.client.AbstractJsonEncoderDecoder.*;

public class ServiceAlmanach_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceAlmanach, org.fusesource.restygwt.client.RestServiceProxy {
  private org.fusesource.restygwt.client.Resource resource = null;
  
  public void setResource(org.fusesource.restygwt.client.Resource resource) {
    this.resource = resource;
  }
  public org.fusesource.restygwt.client.Resource getResource() {
    if (this.resource == null) {
      String serviceRoot = org.fusesource.restygwt.client.Defaults.getServiceRoot();
      this.resource = new org.fusesource.restygwt.client.Resource(serviceRoot).resolve("/almanach");
    }
    return this.resource;
  }
  private org.fusesource.restygwt.client.Dispatcher dispatcher = null;
  
  public void setDispatcher(org.fusesource.restygwt.client.Dispatcher dispatcher) {
    this.dispatcher = dispatcher;
  }
  
  public org.fusesource.restygwt.client.Dispatcher getDispatcher() {
    return this.dispatcher;
  }
  public void createEvent(java.lang.String componentInstanceId, java.lang.String calendarId, org.silverpeas.mobile.shared.dto.almanach.CalendarEventCreationDTO event, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO> callback) {
    final java.lang.String final_componentInstanceId = componentInstanceId;
    final java.lang.String final_calendarId = calendarId;
    final org.silverpeas.mobile.shared.dto.almanach.CalendarEventCreationDTO final_event = event;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(componentInstanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(componentInstanceId))+"/"+(calendarId== null? null : com.google.gwt.http.client.URL.encodePathSegment(calendarId))+"/events")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(org.silverpeas.mobile.shared.dto.almanach.CalendarEventCreationDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(event));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getCalendars(java.lang.String componentInstanceId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarDTO>> callback) {
    final java.lang.String final_componentInstanceId = componentInstanceId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(componentInstanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(componentInstanceId))+"/")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.almanach.CalendarDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getEvent(java.lang.String calendarId, java.lang.String eventId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO> callback) {
    final java.lang.String final_calendarId = calendarId;
    final java.lang.String final_eventId = eventId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(calendarId== null? null : com.google.gwt.http.client.URL.encodePathSegment(calendarId))+"/events/"+(eventId== null? null : com.google.gwt.http.client.URL.encodePathSegment(eventId))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getOccurences(java.lang.String componentInstanceId, java.lang.String calendarId, java.lang.String startDateOfWindowTime, java.lang.String endDateOfWindowTime, java.lang.String zoneid, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO>> callback) {
    final java.lang.String final_componentInstanceId = componentInstanceId;
    final java.lang.String final_calendarId = calendarId;
    final java.lang.String final_startDateOfWindowTime = startDateOfWindowTime;
    final java.lang.String final_endDateOfWindowTime = endDateOfWindowTime;
    final java.lang.String final_zoneid = zoneid;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(componentInstanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(componentInstanceId))+"/"+(calendarId== null? null : com.google.gwt.http.client.URL.encodePathSegment(calendarId))+"/events/occurrences/")
    .addQueryParam("startDateOfWindowTime", startDateOfWindowTime)
    .addQueryParam("endDateOfWindowTime", endDateOfWindowTime)
    .addQueryParam("zoneid", zoneid)
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void updateParticipation(java.lang.String componentInstanceId, java.lang.String calendarId, java.lang.String eventId, java.lang.String occurenceId, java.lang.String attendeeId, java.lang.String zoneid, org.silverpeas.mobile.shared.dto.almanach.CalendarEventAttendeeDTO dto, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO> callback) {
    final java.lang.String final_componentInstanceId = componentInstanceId;
    final java.lang.String final_calendarId = calendarId;
    final java.lang.String final_eventId = eventId;
    final java.lang.String final_occurenceId = occurenceId;
    final java.lang.String final_attendeeId = attendeeId;
    final java.lang.String final_zoneid = zoneid;
    final org.silverpeas.mobile.shared.dto.almanach.CalendarEventAttendeeDTO final_dto = dto;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(componentInstanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(componentInstanceId))+"/"+(calendarId== null? null : com.google.gwt.http.client.URL.encodePathSegment(calendarId))+"/events/"+(eventId== null? null : com.google.gwt.http.client.URL.encodePathSegment(eventId))+"/occurrences/"+(occurenceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(occurenceId))+"/attendees/"+(attendeeId== null? null : com.google.gwt.http.client.URL.encodePathSegment(attendeeId))+"")
    .addQueryParam("zoneid", zoneid)
    .put();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    __method.json(org.silverpeas.mobile.shared.dto.almanach.CalendarEventAttendeeDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(dto));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.almanach.CalendarEventDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
}
