# Class Ext.data.Api

Package: | Ext.data
Defined In: | Api.js
Class: | Api
Extends: | Object

Ext.data.Api is a singleton designed to manage the data API including methods for validating a developer's DataProxy API. Defines variables for CRUD actions create, read, update and destroy in addition to a mapping of RESTful HTTP methods GET, POST, PUT and DELETE to CRUD actions.
This class is a singleton and cannot be created directly.

## Public Properties

Property | Defined By
--- | ---
| actions : Object Defined actions corresponding to remote actions: actions: { create : 'create', // Text representing the remote-... Defined actions corresponding to remote actions:
    actions: {
        create  : 'create',  // Text representing the remote-action to create records on server.
        read    : 'read',    // Text representing the remote-action to read/load data from server.
        update  : 'update',  // Text representing the remote-action to update records on server.
        destroy : 'destroy'  // Text representing the remote-action to destroy records on server.
    }
| Api
| restActions : Object Defined {CRUD action}:{HTTP method} pairs to associate HTTP methods with the corresponding actions for RESTful proxie... Defined {CRUD action}:{HTTP method} pairs to associate HTTP methods with the corresponding actions for RESTful proxies. Defaults to:
    restActions : {
        create  : 'POST',
        read    : 'GET',
        update  : 'PUT',
        destroy : 'DELETE'
    },
| Api

## Public Methods

Method | Defined By
--- | ---
| Response() : void Ext.data.Response Experimental. Do not use directly. Ext.data.Response Experimental. Do not use directly. Parameters: None. Returns: void | Api
| getVerb( String name ) : String||null Returns the actual CRUD action KEY "create", "read", "update" or "destroy" from the supplied action-name. This metho... Returns the actual CRUD action KEY "create", "read", "update" or "destroy" from the supplied action-name. This method is used internally and shouldn't generally need to be used directly. The key/value pair of Ext.data.Api.actions will often be identical but this is not necessarily true. A developer can override this naming convention if desired. However, the framework internally calls methods based upon the KEY so a way of retreiving the the words "create", "read", "update" and "destroy" is required. This method will cache discovered KEYS into the private validActions hash. Parameters: `name` : String The runtime name of the action. Returns: `String||null` returns the action-key, or verb of the user-action or null if invalid. | Api
| hasUniqueUrl( Ext.data.DataProxy proxy, String verb ) : Boolean Returns true if the supplied verb upon the supplied proxy points to a unique url in that none of the other api-action... Returns true if the supplied verb upon the supplied proxy points to a unique url in that none of the other api-actions point to the same url. The question is important for deciding whether to insert the "xaction" HTTP parameter within an Ajax request. This method is used internally and shouldn't generally need to be called directly. Parameters: `proxy` : Ext.data.DataProxy `verb` : String Returns: `Boolean` | Api
| isAction( String action ) : Boolean Returns true if supplied action-name is a valid API action defined in actions constants Returns true if supplied action-name is a valid API action defined in `actions` constants Parameters: `action` : String Action to test for availability. Returns: `Boolean` | Api
| isValid() : String[]|true Returns true if the supplied API is valid; that is, check that all keys match defined actions otherwise returns an ar... Returns true if the supplied API is valid; that is, check that all keys match defined actions otherwise returns an array of mistakes. Parameters: None. Returns: `String[]|true` | Api
| prepare( Ext.data.DataProxy proxy ) : void This method is used internally by DataProxy and should not generally need to be used directly. Each action of a DataP... This method is used internally by `DataProxy` and should not generally need to be used directly. Each action of a DataProxy api can be initially defined as either a String or an Object. When specified as an object, one can explicitly define the HTTP method (GET|POST) to use for each CRUD action. This method will prepare the supplied API, setting each action to the Object form. If your API-actions do not explicitly define the HTTP method, the "method" configuration-parameter will be used. If the method configuration parameter is not specified, POST will be used.
    new Ext.data.HttpProxy({
        method: "POST",     // <-- default HTTP method when not specified.
        api: {
            create: 'create.php',
            load: 'read.php',
            save: 'save.php',
            destroy: 'destroy.php'
        }
    });

    // Alternatively, one can use the object-form to specify the API
    new Ext.data.HttpProxy({
        api: {
            load: {url: 'read.php', method: 'GET'},
            create: 'create.php',
            destroy: 'destroy.php',
            save: 'update.php'
        }
    });
Parameters: `proxy` : Ext.data.DataProxy Returns: void | Api
| restify( Ext.data.DataProxy proxy ) : void Prepares a supplied Proxy to be RESTful. Sets the HTTP method for each api-action to be one of GET, POST, PUT, DELET... Prepares a supplied Proxy to be RESTful. Sets the HTTP method for each api-action to be one of GET, POST, PUT, DELETE according to the defined restActions. Parameters: `proxy` : Ext.data.DataProxy Returns: void | Api

## Public Events

This class has no public events.