bvalosek / infusionsoft-api

A promise-driven Node.js wrapper for the XML-RPC Infusionsoft API
MIT License
16 stars 14 forks source link

example query using this API #15

Closed Kezzsim closed 3 years ago

Kezzsim commented 3 years ago

Hello again

This API is very useful, but I seem to have difficulties using the queries that infusionSoft provides in their documentation.

If I write something like:

ifs.DataService.query('LeadSource', 1000, 1, "Id => [1,2,3,4]", leadSourceFields).then(leadSources => {
    console.log(leadSources);
    return leadSources;
}).catch(e => { console.log(e) });

Id => [1,2,3,4], one of the example queries copied from IFS's documentation, just seems to cause the program to crash with this: Error: XML-RPC fault: No method matching arguments: java.lang.String

In their documentation they say the query is of type "struct" but how do I declare that type inside javascript?

This really is a low priority thing but I'd appreciate the insight

Thank you

Kezzsim commented 3 years ago

I was able to make an example with some trial and error, basically Javascript Object == Java Struct Everything in the IFS API is Base 0 and MODULO is the wildcard character for some unknown reason



// Create an ifs object for all XML-RPC transactions.
var ifs = new api.DataContext('{IFSTOKEN}');

// Lead Source potential fields
var leadSourceFields = [
    "Id",
    "Name",
    "Vendor",
    "Status",
    "StartDate",
    "Message",
    "Medium",
    "LeadSourceCategoryId",
    "EndDate",
    "Description",
    "CostPerLead"
];

ifs.DataService.query('LeadSource', 1000, 0, {"Id" : "%"}, leadSourceFields).then(leadSources => {
    console.log(leadSources);
    return leadSources;
}).catch(e => { console.log(e) });```