package com.gurkensalat.android.xingsync.api;

import org.json.JSONArray;
import org.json.JSONException;

import android.util.Log;

import com.googlecode.androidannotations.annotations.EBean;

@EBean
public class MeCall // implements XingApiCall
{
	private static final String TAG = "xingsync.MeCall";

	public JSONArray perform(final String... args)
	{
		// Hardcoded Mock for now

		StringBuffer sb = new StringBuffer(1024);

		sb.append("{");
		sb.append("  \"users\": [");
		sb.append("    {");
		sb.append("      \"id\": \"3382304_64b174\",");
		sb.append("      \"first_name\": \"Hakan\",");
		sb.append("      \"last_name\": \"Tandogan\",");
		sb.append("      \"display_name\": \"Hakan Tandogan\"");
		sb.append("    }");
		sb.append("  ]");
		sb.append("}");

		Log.i(TAG, sb.toString());

		JSONArray jsonArray = new JSONArray();
		try
		{
			jsonArray = new JSONArray(sb.toString());
			Log.i(TAG, jsonArray.toString());
		}
		catch (JSONException e)
		{
			Log.e(TAG, "while parsing answer string", e);
		}

		return jsonArray;
	}
}

@@ -97,16 +97,44 @@
 ception;
+%0Aimport org.json.JSONObject;
 %0A%0Aimport
@@ -336,21 +336,22 @@
 lic JSON
-Array
+Object
  perform
@@ -831,23 +831,19 @@
 JSON
-Array jsonArray
+Object json
  = n
@@ -849,21 +849,22 @@
 new JSON
-Array
+Object
 ();%0A%09%09tr
@@ -876,21 +876,16 @@
 %0A%09%09%09json
-Array
  = new J
@@ -887,21 +887,22 @@
 new JSON
-Array
+Object
 (sb.toSt
@@ -928,21 +928,16 @@
 AG, json
-Array
 .toStrin
@@ -1043,20 +1043,15 @@
 urn json
-Array
 ;%0A%09%7D%0A%7D%0A

Make the contract a JSONObject