jonbo / node-steam-webapi

Steam WebAPI wrapper for node.js
MIT License
48 stars 20 forks source link

How to specify interface? #12

Open srlowe opened 9 years ago

srlowe commented 9 years ago

Some steam methods exist on multiple interfaces, e.g.:

ISteamMicroTxn.initTxn ISteamMicroTxnSandbox.initTxn

How do you select between the two with this wrapper? (as it seems to omit the interface name).

jonbo commented 9 years ago

Yeah, this does cause a slight issue with the normal usage of the library. However, it should be possible to call them like-so: https://github.com/jonbo/node-steam-webapi/blob/master/index.js#L249 where 'this' should be your steam instance object. (I believe, let me know if it doesn't work :)

var steam = new Steam({...});
Steam.INTERFACES['ISteamMicroTxnSandbox']['initTxn'].call(steam, steamObj, callback);
srlowe commented 9 years ago

Thanks. In the end I did something similar to the method version selector. Seems to work ok:

    var wrapperMethod = function(steamObj, callback) {
        var params = getParams(this, steamObj, requiredParams, optionalParams);
        var version = steamObj.version || defaultVersion;
        var selectedInterfaceName = steamObj.interfaceName || interfaceName;
        this.request(selectedInterfaceName, funcName, version, httpMethod, params, callback);
    };
srlowe commented 9 years ago

Hmm, looks like my method is not working after all (seems to use the sandbox interface even when I specify the non-sandbox one). Looking into that now.

I tried your workaround too, but could not get it to work. UPDATE: it works, but the method names need capitalising, ie:

 Steam.INTERFACES['ISteamMicroTxnSandbox']['InitTxn'].call(steam, steamObj, callback);