TribeFire API call demo

by tonytlwu

HTML

<p>Retrieving data from a data source:</p>
<pre id="debug"></pre>

JavaScript

var tribefireHostAuthenticate = 'http://codelabs.tribefire.com:80/tribefire-services/rest/authenticate',
    tribefireServiceCreate = 'http://codelabs.tribefire.com/tribefire-services/rest/create',

    openSession = function () {
        var params = {
            user: 'cortex',
            password: 'cortex'
        };

        $.get(tribefireHostAuthenticate, params, function (result) {

            var sessionID = result;
            params = {
                sessionId: sessionID,
                accessId: 'custom.CodeLabsSalesModel',
                type: 'com.braintribe.model.sales.Opportunity'
            };

            $.get(tribefireServiceCreate, params, function (result) {
                $('#debug').html( JSON.stringify( result, null, "\t" ) );
            });

        });
    };
openSession();