<?php

namespace Asana\Resources\Gen;

class <%= plural(cap(resource.name)) + "Base" %>
{
    public function __construct($client)
    {
        $this->client = $client;
    }<% _.forEach(resource.actions, function(action) {
    if (action.no_code) {
      return;
    }

    var name = snake(action.name);
    var method = action.method.toLowerCase();
    if (action.collection) {
      method += "Collection";
    }

    var extraParam = null;
    if (action.method === "GET") {
      extraParam = {
        name: 'params',
        type: 'Object',
        comment: 'Parameters for the request'
      };
    } else if (action.method !== 'DELETE') {
      extraParam = {
        name: 'data',
        type: 'Object',
        comment: 'Data for the request'
      };
    }
    var params = paramsForAction(action);
    var pathParamNames = params.pathParams.map(function(param) { return param.name; });
    var explicitParams = params.pathParams.concat(params.explicitNonPathParams).concat(extraParam ? [extraParam] : []);
    var documentedParams = explicitParams.concat(params.optionParams);
    var phpPathParamNames = pathParamNames.map(function(p) { return "$" + p; });
  %>

    public function <%= action.name %>(<%= phpPathParamNames.concat([""]).join(", ") %>$params = array(), $options = array())
    {<% if (pathParamNames.length > 0) { %>
        $path = sprintf(<%= JSON.stringify(action.path) %>, <%= phpPathParamNames.join(", ") %>);
        return $this->client-><%= method %>($path, $params, $options);
    <% } else { %>
        return $this->client-><%= method %>(<%= JSON.stringify(action.path) %>, $params, $options);
    <% } %>}<% }); %>
}
