
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
infusionsoft-api-auth-headers
Advanced tools
Javscript wrapper for the Infusionsoft API - Updated to comply with Legacy Key Sunsetting
A promise-driven, fluent-style Node.js wrapper for the XML-RPC Infusionsoft API (updated to support Legacy Key Sunsetting)..
Done as a one off upgrade: Not actively maintained or supported.
Write badass Infusionsoft apps on the server that are fully and natively asynchronous.
It's pretty dope.
Install via npm:
$ npm install infusionsoft-api-auth-headers
Do cool stuff:
var api = require('infusionsoft-api-auth-headers');
var infusionsoft = new api.DataContext('myapp', 'MY_API_KEY');
infusionsoft.Contacts
.where(Contact.FirstName, 'Brandon')
.like(Contact.LastName, 'V%')
.select(Contact.Id, Contact.Email)
.orderByDescending('LastName')
.take(100)
.toArray()
.done(function(result) {
console.log(result);
});
You can also use the API Services directly:
infusionsoft.ContactService
.findByEmail('brandon@aol.com', ['Id', 'FirstName', 'LastName']);
Awesome.
All asynchronous methods return a Promise that represents the eventual value that will be returned.
Promises are glorious and make writing heavily asynchronous code much less awful than it would otherwise be.
See the More Examples section to see them in action.
This project creates interfaces and classes for the API services and tables via
the grunt-infusionsoft grunt
plugin. To recreate the generated files, run grunt infusionsoft.
Check out the infusionsoft directory to see the output.
All examples use infusionsoft as an instantiated DataContext with your app
name and API key. ie:
var infusionsoft = new api.DataContext('myAppName', 'MY_API_KEY');
infusionsoft.Payments
.like(Payment.PayDate, '2013-06%')
.sum(function(x) { return x.PayAmt; })
.done(function(total) {
console.log('total revenue: ' + total);
});
And an example of using the fail method to catch any problems.
infusionsoft.DataService
.authenticateUser('user@email.com', 'md5-hash-of-password')
.then(function(userId) {
return infusionsoft.Users.where(User.Id, userId).first();
})
.then(function(user) {
console.log('Hello ' + user.FirstName + ' ' + user.LastName);
})
.fail(function(err) {
console.log('uh oh: ' + err);
});
Uses underscore.
infusionsoft.Invoices
.like(Invoice.DateCreated, '2013-08%')
.groupBy(function(x) { return x.ProductSold; })
.done(function(result) {
_(result).each(function(invoices, productId) {
console.log(productId, invoices.length);
});
});
Same as above, but use the spread function to wait on 2 promises to get the
corresponding product names. The API hits for querying both the Product table
and the Invoice table will actually fire off at the same time.
Hashtag asynchronous.
var products = infusionsoft.Products.toArray();
var invoices = infusionsoft.Invoices
.like(Invoice.DateCreated, '2013-08%')
.groupBy(function(x) { return x.ProductSold; });
Q.spread([products, invoices], function(products, invoices) {
_(invoices).each(function(invoices, productId) {
var productName = _(products)
.find(function(x) { return x.Id == productId; })
.ProductName;
console.log(productName, invoices.length);
});
});
sdk.Contacts
.where(Contact.Email, 'some@email.com')
.first()
.then(function(contact) {
return sdk.ContactGroupAssigns
.where(ContactGroupAssign.ContactId, contact.Id)
.toArray();
})
.then(function(cgas) {
cgas.forEach(function(group) {
console.log(group.ContactGroup, group.DateCreated);
});
});
Okay, take a deep breath. We can do (inner) joins. We fake it though... the
inner part of the join has to be loaded entirely and then we do a O(n^2)
iteration to make it, but we can still do it. If the inner is cheap, this
isn't too bad. Especially when the SDK will handle loading, paging, waiting,
etc... all for you.
Syntax (stolen from C#'s LINQ):
join (innerQueryable, outerKey, innerKey, selectorFn)Let's do this:
var pc = infusionsoft.ProductCategories;
var pca = infusionsoft.ProductCategoryAssigns;
var plans = infusionsoft.SubscriptionPlans;
// Join the categories onto itself for creating the full category name
// (category parent name + category name)
var categories = pc
.join(pc, 'ParentId', 'Id', function(pc, parent) {
return {
Id: pc.Id,
Name: parent.CategoryDisplayName + ' ' + pc.CategoryDisplayName
}; });
var subPlans = plans
// Join the sub plan (which only has product Id) onto the PCA table to get
// the product category ID
.join(pca, 'ProductId', 'ProductId', function(plan, pca) {
plan.ProductCategoryId = pca.ProductCategoryId;
return plan;
})
// Join our categories object we made above onto the projection from the
// most recent join to get the full category name + subscription plan Id
.join(categories, 'ProductCategoryId', 'Id', function(plan, category) {
return { planId: plan.Id, category: category.Name }; });
subPlans.toArray().done(function(d) { console.log(d); });
What happens magically behind the scenes is pretty nice. When we call
toArray() at the end, we first query the SubscriptionPlan table (aliased as
plans). It then knows we need to join the ProductCategoryAssign table on
there, so it fetches that (which may be more than one page). It finally gets
the ProductCategory table (in its entirety), and joins them all up.
The syntax looks nasty, but that is somewhat unavoidable with a join
function.
Copyright 2013 Brandon Valosek
Infusionsoft API is released under the MIT license.
FAQs
Javscript wrapper for the Infusionsoft API - Updated to comply with Legacy Key Sunsetting
The npm package infusionsoft-api-auth-headers receives a total of 1 weekly downloads. As such, infusionsoft-api-auth-headers popularity was classified as not popular.
We found that infusionsoft-api-auth-headers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.