Improved Parameter Passing in Javascript SDK

We the recent upgrades in the API iwth version 3, we are now able to improve the SDK as well.

Before API v3, the parameters had to be passed to the SDK using a Dictionary-like structure like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
var helloWorldSvc = new iKnodeSdk.ApplicationClient({
    userId: USERID,
    apiKey: APIKEY,
    appName: "HelloWorld"
});

var response = helloWorldSvc.execute({
    methodName: "HelloYou",
    parameters: [{
        name: "yourName",
        value: "John Doe"
    }]
});

Now you can do this:

1
2
3
4
5
6
7
8
9
10
11
12
var helloWorldSvc = new iKnodeSdk.ApplicationClient({
    userId: USERID,
    apiKey: APIKEY,
    appName: "HelloWorld"
});

var response = helloWorldSvc.execute({
    methodName: "HelloYou",
    parameters: {
        yourName: "John Doe"
    }]
});

Instead of passing the parameters as a Key-Value pair, you just pass the parameter in a common JSON object format. It is way more javascript friendly, and API friendly as well. No need to format the parameters in weird ways, and no need for the parameter formatting used before.

The latest Javascript SDK is backward compatible, but in order for the SDK to work with Key-Value pair parameters, just add the following flag:

1
2
3
4
5
6
7
8
var response = helloWorldSvc.execute({
    methodName: "HelloYou",
    formatParameters: true,
    parameters: [{
        name: "yourName",
        value: "John Doe"
    }]
});

Let us know waht you think.