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

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

public class ServiceClassifieds_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceClassifieds, 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/classifieds");
    }
    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 getClassified(java.lang.String appId, java.lang.String id, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_id = id;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/"+(id== null? null : com.google.gwt.http.client.URL.encodePathSegment(id))+"")
    .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.dto.classifieds.ClassifiedsDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO_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 getClassifieds(java.lang.String appId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO> callback) {
    final java.lang.String final_appId = appId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/all")
    .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.dto.classifieds.ClassifiedsDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.classifieds.ClassifiedsDTO_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 sendMessageToOwner(java.lang.String appId, java.lang.String message, org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO dto, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_message = message;
    final org.silverpeas.mobile.shared.dto.classifieds.ClassifiedDTO final_dto = dto;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/{instanceId}/"+(message== null? null : com.google.gwt.http.client.URL.encodePathSegment(message))+"")
    .post();
    __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.classifieds.ClassifiedDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(dto));
    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);
    }
  }
}
