@Override
    public void genOperationFunction(StringBuffer buff, Operation o) {
        StringBuilder funcbuff = new StringBuilder();

        funcbuff.append(String.format("json.%s<-function(", o.name));
        if (o.parameters != null) {
            Request r = o.parameters.request;
            if (r.parameter != null) {
                for (Parameter p : r.parameter) {
                    if (p.mandatory != null && p.isMandatory()) {
                        funcbuff.append(String.format("%s=%s(), ", p.name,
                                convertPrimitiveRTypes(p.type)));
                    } else {
                        funcbuff.append(String.format("%s=NULL, ", p.name));
                    }
                }
                funcbuff.deleteCharAt(funcbuff.length() - 2);
                funcbuff.append(", exchange=.BetfairEnv$exchange, appKey=.BetfairEnv$appKey, sessionToken=.BetfairEnv$sessionToken");
            } else {
                funcbuff.append("exchange=.BetfairEnv$exchange, appKey=.BetfairEnv$appKey, sessionToken=.BetfairEnv$sessionToken");
            }
        } else {
            funcbuff.append("exchange=.BetfairEnv$exchange, appKey=.BetfairEnv$appKey, sessionToken=.BetfairEnv$sessionToken");
        }

        funcbuff.append(") {\n");

        String functxt = funcbuff.toString();
        functxt = WordUtils.wrap(functxt, 80, "\n  ", false);
        buff.append(functxt);

        StringBuilder parambuff = new StringBuilder();
        parambuff.append("  params = list(");
        if (o.parameters != null) {
            Request r = o.parameters.request;
            if (r.parameter != null) {
                for (Parameter p : r.parameter) {
                    parambuff.append(String.format("%s=%s, ", p.name, p.name));
                }
                parambuff.deleteCharAt(parambuff.length() - 2);
            }
        }

        parambuff.append(")\n");
        String paramtxt = parambuff.toString();
        paramtxt = WordUtils.wrap(paramtxt, 80, "\n  ", false);
        buff.append("  ").append(paramtxt);

        buff.append(String
                .format("  run.operation('%s',params,exchange,appKey,sessionToken,api='%s')\n",
                        o.name, api));
        buff.append("}\n\n");
    }