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

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

public class ServiceNotifications_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceNotifications, 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("/mobile/notification");
    }
    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 delete(java.util.List<org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO> selection, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final java.util.List<org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO> final_selection = selection;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("")
    .delete();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(toJSON(selection, org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO_Generated_JsonEncoderDecoder_.INSTANCE));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Void>(__method, callback) {
        protected java.lang.Void parseResult() throws Exception {
          return (java.lang.Void) null;
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getAllowedUsersAndGroups(java.lang.String componentId, java.lang.String contentId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO>> callback) {
    final java.lang.String final_componentId = componentId;
    final java.lang.String final_contentId = contentId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("allowedUsersAndGroups/"+(componentId== null? null : com.google.gwt.http.client.URL.encodePathSegment(componentId))+"/"+(contentId== null? null : com.google.gwt.http.client.URL.encodePathSegment(contentId))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.BaseDTO_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 getUserNotifications(int callNumber, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationReceivedDTO>> callback) {
    final int final_callNumber = callNumber;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("received/"+(""+callNumber== null? null : com.google.gwt.http.client.URL.encodePathSegment(""+callNumber))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationReceivedDTO>>(__method, callback) {
        protected org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationReceivedDTO> parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.StreamingList__org_silverpeas_mobile_shared_dto_notifications_NotificationReceivedDTO_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 getUserSendedNotifications(int callNumber, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationSendedDTO>> callback) {
    final int final_callNumber = callNumber;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("sended/"+(""+callNumber== null? null : com.google.gwt.http.client.URL.encodePathSegment(""+callNumber))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationSendedDTO>>(__method, callback) {
        protected org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.notifications.NotificationSendedDTO> parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.StreamingList__org_silverpeas_mobile_shared_dto_notifications_NotificationSendedDTO_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 markAsRead(java.util.List<org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO> selection, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final java.util.List<org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO> final_selection = selection;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("readed/")
    .put();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(toJSON(selection, org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO_Generated_JsonEncoderDecoder_.INSTANCE));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Void>(__method, callback) {
        protected java.lang.Void parseResult() throws Exception {
          return (java.lang.Void) null;
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void markAsReaden(long id, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final long final_id = id;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("readed/"+(""+id== null? null : com.google.gwt.http.client.URL.encodePathSegment(""+id))+"")
    .put();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Void>(__method, callback) {
        protected java.lang.Void parseResult() throws Exception {
          return (java.lang.Void) null;
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void send(org.silverpeas.mobile.shared.dto.notifications.NotificationToSendDTO notification, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final org.silverpeas.mobile.shared.dto.notifications.NotificationToSendDTO final_notification = notification;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("send/")
    .put();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(org.silverpeas.mobile.shared.dto.notifications.NotificationToSendDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(notification));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Void>(__method, callback) {
        protected java.lang.Void parseResult() throws Exception {
          return (java.lang.Void) null;
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
}
