4d6c3c157705c101f044293dd642b62683918dedDav Glass * This class adds a sugar class to allow access to YQL (http://developer.yahoo.com/yql/).
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @module yql
4d6c3c157705c101f044293dd642b62683918dedDav Glass * Utility Class used under the hood my the YQL class
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @class YQLRequest
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @constructor
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @param {String} sql The SQL statement to execute
e185b559bf5512df7169f7901db9b2ec3771260bDav Glass * @param {Function/Object} callback The callback to execute after the query (Falls through to JSONP).
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @param {Object} params An object literal of extra parameters to pass along (optional).
7368220dd87582da2552f8152bbff2508e5ddf1dDav Glass * @param {Object} opts An object literal of configuration options (optional): proto (http|https), base (url)
e185b559bf5512df7169f7901db9b2ec3771260bDav Glass var YQLRequest = function (sql, callback, params, opts) {
fb1acfadd2c965ce38a6caa9cfa16e051ab70702Dav Glass //Allow format override.. JSON-P-X
9ce5c4aa30657fb7e4ef73dca0ab98c7a42d4cd4Dav Glass * @property _jsonp
9ce5c4aa30657fb7e4ef73dca0ab98c7a42d4cd4Dav Glass * @description Reference to the JSONP instance used to make the queries
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @property _opts
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @description Holder for the opts argument
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @property _callback
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @description Holder for the callback argument
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @property _params
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @description Holder for the params argument
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @method send
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @description The method that executes the YQL Request.
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass * @chainable
7174997a0a47d3123f24800d41907e92fa01811dDav Glass * @return {YQLRequest}
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass send: function() {
20128fa09a6536ce0e00f7b6dab83ab3bca6b698Dav Glass var qs = [], url = ((this._opts && this._opts.proto) ? this._opts.proto : Y.YQLRequest.PROTO);
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass url += ((this._opts && this._opts.base) ? this._opts.base : Y.YQLRequest.BASE_URL) + qs;
9ce5c4aa30657fb7e4ef73dca0ab98c7a42d4cd4Dav Glass var o = (!Y.Lang.isFunction(this._callback)) ? this._callback : { on: { success: this._callback } };
9ce5c4aa30657fb7e4ef73dca0ab98c7a42d4cd4Dav Glass if (o.allowCache !== false) {
9ce5c4aa30657fb7e4ef73dca0ab98c7a42d4cd4Dav Glass if (!this._jsonp) {
11173168fe9e382ff5a815fcf26d1686a0065c64Dav Glass return this;
fb1acfadd2c965ce38a6caa9cfa16e051ab70702Dav Glass * @property FORMAT
fb1acfadd2c965ce38a6caa9cfa16e051ab70702Dav Glass * @description Default format to use: json
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @property PROTO
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @description Default protocol to use: http
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @property BASE_URL
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @description The base URL to query: query.yahooapis.com/v1/public/yql?
e185b559bf5512df7169f7901db9b2ec3771260bDav Glass YQLRequest.BASE_URL = ':/'+'/query.yahooapis.com/v1/public/yql?';
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @property ENV
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @description The environment file to load: http://datatables.org/alltables.env
e185b559bf5512df7169f7901db9b2ec3771260bDav Glass YQLRequest.ENV = 'http:/'+'/datatables.org/alltables.env';
4d6c3c157705c101f044293dd642b62683918dedDav Glass * This class adds a sugar class to allow access to YQL (http://developer.yahoo.com/yql/).
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @class YQL
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @constructor
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @param {String} sql The SQL statement to execute
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @param {Function} callback The callback to execute after the query (optional).
4d6c3c157705c101f044293dd642b62683918dedDav Glass * @param {Object} params An object literal of extra parameters to pass along (optional).
56211303dc31245207d040e350e8a4a5e28f2f6bDav Glass * @param {Object} opts An object literal of configuration options (optional): proto (http|https), base (url)
56211303dc31245207d040e350e8a4a5e28f2f6bDav Glass return new Y.YQLRequest(sql, callback, params, opts).send();