package com.wasu.cs.protocol;

import org.json.JSONObject;

import com.wasu.cs.model.RecommendModel;
import com.wasu.cs.protocol.SearchProtocol.ProtocolCallbackBase;
import com.wasu.module.datafetch.DataFetchListener.JsonListener;
import com.wasu.module.datafetch.DataFetchModule;

public class RecommendProtocol extends BaseProtocol {

	public void fetch(String url, final ProtocolCallbackBase callback) {
		DataFetchModule.getInstance().fetchJsonGet(url, new JsonListener() {
			
			@Override
			public void onJsonGet(int retcode, String extraMsg, JSONObject jsonObj) {
				if (null == jsonObj) {
					callback.onProtocolCallback(false, "protocol return data is null", null);
				} else {
					RecommendModel model = new RecommendModel();
					if (model.from(jsonObj)) {
						callback.onProtocolCallback(true, null, model);
					} else {
						callback.onProtocolCallback(false, "parser result data fail", null);
					}
				}
			}
		});
	}

}
