{"_id":"infusionsoft-api","_rev":"27-829cf1988a03dc626cce022a86352ea8","name":"infusionsoft-api","description":"Javscript wrapper for the Infusionsoft API","dist-tags":{"latest":"0.6.0"},"versions":{"0.0.1":{"name":"infusionsoft-api","version":"0.0.1","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","cheerio":"~0.12.0","request":"~2.25.0","underscore":"~1.5.1","wordwrap":"0.0.2"},"devDependencies":{"grunt":"~0.4.1"},"_id":"infusionsoft-api@0.0.1","dist":{"shasum":"945de19da4c31ddb6ffc869d9c01c5da9fac97a6","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.0.1.tgz","integrity":"sha512-OlevUAEjfUcQb8XKSpenLMgRzN3emUvovZsRVllcUMnJidGCzj2+ywHFdnVHqQ88I+BqZcbS0RqW5x6tz4jHeQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGDt6rDLqlWX21ZheY6mhrcLecP/8pz/O4kMcZQXPL7bAiEAuOuGpyEOMqXUSV896Kx3PgNkFlCCXFoeeQmLbQiBgjI="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.1.0":{"name":"infusionsoft-api","version":"0.1.0","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","cheerio":"~0.12.0","request":"~2.25.0","underscore":"~1.5.1","wordwrap":"0.0.2","inflection":"~1.2.6"},"devDependencies":{"grunt":"~0.4.1"},"_id":"infusionsoft-api@0.1.0","dist":{"shasum":"cc7b2aea2b13b2675a7abf6081f99e809a9b496e","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.1.0.tgz","integrity":"sha512-9SYJJ7FbGoB95iC525R6+oSc0bvZjjGANEAGcVYyOxkP0T59lLyAv3vj6XKkYikyOIyieHwtmEaPEhLo6ZHlUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC2yrvp0kaeaVeKcD0CBjKdr5QujvvVyp4hF0CRj+m+dwIhAMnTLymluIuksLb00FPJ+W+wfkQpQ7zWwi7j60lpf6q2"}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.2.0":{"name":"infusionsoft-api","version":"0.2.0","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","cheerio":"~0.12.0","request":"~2.25.0","underscore":"~1.5.1","wordwrap":"0.0.2","inflection":"~1.2.6"},"devDependencies":{"grunt":"~0.4.1"},"_id":"infusionsoft-api@0.2.0","dist":{"shasum":"7652f71869581cee9764029e0dc33fd07f613cd9","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.2.0.tgz","noattachment":true},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.0":{"name":"infusionsoft-api","version":"0.3.0","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","cheerio":"~0.12.0","request":"~2.25.0","underscore":"~1.5.1","wordwrap":"0.0.2","inflection":"~1.2.6"},"devDependencies":{"grunt":"~0.4.1"},"_id":"infusionsoft-api@0.3.0","dist":{"shasum":"f2d3c154d53836a0ff65f0e7aa463a0db75433bc","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.0.tgz","integrity":"sha512-YCRS5icIhB4O4F4rNaLQdPL69rmUzfTWL/aCGFYbArRyUVX3hamgKnQAflhS0hV4IBZlSBxJ4Q7gxhsv2jo7JA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBga9M1DMGtr/1V6fpWRIfqIXnw2xU8Y82mmZmWU1SxTAiEA4QeNT2p4Cg+mketFKlo5nPbVMdT/TPOyrGo3Bn5pGF4="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.1":{"name":"infusionsoft-api","version":"0.3.1","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2"},"_id":"infusionsoft-api@0.3.1","dist":{"shasum":"f1019f2d11140ff36609bbc42a483aef971b3792","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.1.tgz","integrity":"sha512-zc5IK8CPhbEOzD/pcI+pCKrJS9Rp5awX8cI1sHqOLqB6Jv00vt4X9aekb4uKuQj/WRCMROdnOJ5iRQfGTzABAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwNHthkQKlsr3a7apZDDkF3TP0zoTY0l9b3N6WOfyp0wIgT3q5CEDier0MD9sXoKJKevhR9LbYFBiowtoTCbH61xc="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.2":{"name":"infusionsoft-api","version":"0.3.2","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.5.0"},"_id":"infusionsoft-api@0.3.2","dist":{"shasum":"bc924e2a78a052d57c910699f922dc1a5781256d","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.2.tgz","integrity":"sha512-l0DEX6hObQTHOdh0/5U2tTsDUwqyBBUkiu4nN7wZQCrSPdSZ3o7qcefyS4/Q2EJUltSwwbWNvtQX8/WqfuyhZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEvV/xAGlQyfCTjSKqPuRhuaBf+5ia/sR/tYwSNT1SP3AiEApaHLmB86UrtifShlpzMWN6vkplJTEJWmLbwdoNGav7k="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.3":{"name":"infusionsoft-api","version":"0.3.3","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.5.0"},"_id":"infusionsoft-api@0.3.3","dist":{"shasum":"700a1aabf696ccd6ccac440fe8338b8757986e28","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.3.tgz","integrity":"sha512-eL7g5xBDVrJBNEVSCQb/F0jlLp4ex6oTu0zVEgwOweH70s5cSnOLberBPfCqjzJAfvhivZSIctmJLhnX0AcEDg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDrolvsjd/Kdc6qkGDW2qkH3uSFBdhOjf3NYFd/EO/SFAIgeleKqPJSX6yHwOQpKrGHAu05Vuvw6qnN6SnokXvZ3Dw="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.4":{"name":"infusionsoft-api","version":"0.3.4","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1","q":"~0.9.6"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.5.0"},"_id":"infusionsoft-api@0.3.4","dist":{"shasum":"a0440737a6d8111fd52f45f480628ecb642dd9b5","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.4.tgz","integrity":"sha512-1NDGMXp/KjvRoWHadsWhyzbWC3D6JZB/inF+8oTSal5NSyG0bh+AgVnxFBKUxK7s/1KBzc4Ibn5YCMUAGeY5lw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmWrPwwOZRsxj7h+TBgiUS9Bun0ZRYMkwrT9O0qZzIoAiBfBqKzQDHhXwgs8vRz1wPtJ7l5VNCiNc8C6eYrYrsfxQ=="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.3.5":{"name":"infusionsoft-api","version":"0.3.5","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1","q":"~0.9.6","inflection":"~1.2.6"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.5.0"},"_id":"infusionsoft-api@0.3.5","dist":{"shasum":"f546b9f182a80545537987aec925b9dc45fe4bee","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.3.5.tgz","integrity":"sha512-ztdfP3GVya/5abavuaWHjntn5Z3+qOtQ8r6srFzWR7+4fM21LCPNDUFSmUfV5Z2NLdg30ehTzNN0hsCsWa+sCw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFFT/s8GoBym2NLySEAQddkXFMe1a7eua+H6IKgH8cjkAiBuwj44ntgPipRXdngvijTj2CXlus6CIJvWvOiSWnF5gw=="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.4.1":{"name":"infusionsoft-api","version":"0.4.1","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1","q":"~0.9.6","inflection":"~1.2.6"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.6.0"},"_id":"infusionsoft-api@0.4.1","dist":{"shasum":"07fe616944316298577e5c7cc611e7233eea2dd1","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.4.1.tgz","integrity":"sha512-4KbagVO1GE56DSZbJW+mIA6twCHM1meC/CqdCpfgpXQWqAcNK5IkkpYBBcmEZDxrE05X3i3DonTWhYjv1AC8Uw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTFkMsGtu0OisKCur7wfGYsaREtb14SUZ7Rear6YXO7AIgdkAtfdquYRiUspVh18arA2D68FdZoMia1haWBjcEvoI="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"directories":{}},"0.5.0":{"name":"infusionsoft-api","version":"0.5.0","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1","q":"~0.9.6","inflection":"~1.2.6"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.6.1"},"homepage":"https://github.com/bvalosek/infusionsoft-api","_id":"infusionsoft-api@0.5.0","dist":{"shasum":"ad5cfbebabcfdc098e4278ed51f6b6e976b3d14c","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.5.0.tgz","integrity":"sha512-1u6NP480pCwbAYQ/yGEB06L82U/MIBHWJS4XiqVDjRPAY9ScvI+lHohtxdN8hbfyGQXta2gSxKkBZNnQdSWyxA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA7xlBG0G6ZJ6iXqyrZlq0O+olt9OaoZzA+UVDSiAjDXAiBQHce3Lihpnib4xEQYWrXre5CCS4s9yTTZBoqhTY5cEA=="}]},"_from":".","_npmVersion":"1.3.23","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}]},"0.6.0":{"name":"infusionsoft-api","version":"0.6.0","description":"Javscript wrapper for the Infusionsoft API","main":"index.js","scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"keywords":["infusionsoft","api"],"author":{"name":"Brandon Valosek"},"license":"MIT","bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"dependencies":{"typedef":"~0.13.2","xmlrpc":"~1.1.0","underscore":"~1.5.1","q":"~0.9.6","inflection":"~1.2.6"},"devDependencies":{"grunt-contrib-jshint":"~0.6.2","grunt-infusionsoft":"~0.6.1"},"homepage":"https://github.com/bvalosek/infusionsoft-api","_id":"infusionsoft-api@0.6.0","dist":{"shasum":"e4e1983d83634a8b34a0ccf9722722d4fe15cbb4","tarball":"https://registry.npmjs.org/infusionsoft-api/-/infusionsoft-api-0.6.0.tgz","integrity":"sha512-Z6lpaQ7Lx6fbbNhjdNFlON0tjAYT+t+jZu+ksjW1lCP0lNENRQ8IHODdeb5myXZcZFOq3FlmZtMLZulF5LdZVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDgPZLdcubWyXriLct8CHOfHs1cxQhWZxs9c9qRNvMieAIgTNE6KLj5xx9iRG9auau4qLzxLI14pYuJ71jKZsxihFg="}]},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"bvalosek","email":"bvalosek@gmail.com"},"maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}]}},"readme":"# Infusionsoft API\n\nA promise-driven, fluent-style Node.js wrapper for the XML-RPC [Infusionsoft API](http://help.infusionsoft.com/developers/api-basics).\n\nWrite badass Infusionsoft apps on the server that are fully and natively asynchronous.\n\nIt's pretty dope.\n\n## Usage\n\nInstall via `npm`:\n\n```\n$ npm install infusionsoft-api\n```\n\nDo cool stuff:\n\n```javascript\nvar api = require('infusionsoft-api');\n\nvar infusionsoft = new api.DataContext('myapp', 'MY_API_KEY');\n\ninfusionsoft.Contacts\n    .where(Contact.FirstName, 'Brandon')\n    .like(Contact.LastName, 'V%')\n    .select(Contact.Id, Contact.Email)\n    .orderByDescending('LastName')\n    .take(100)\n    .toArray()\n    .done(function(result) {\n        console.log(result);\n    });\n```\n\nYou can also use the API Services directly:\n\n```javascript\ninfusionsoft.ContactService\n    .findByEmail('brandon@aol.com', ['Id', 'FirstName', 'LastName']);\n```\n\nAwesome.\n\n## Promises\n\nAll asynchronous methods return a [Promise](https://github.com/kriskowal/q)\nthat represents the eventual value that will be returned.\n\nPromises are glorious and make writing heavily asynchronous code much less\nawful than it would otherwise be.\n\nSee the **More Examples** section to see them in action.\n\n\n## API Scraper\n\nThis project creates interfaces and classes for the API services and tables via\nthe [grunt-infusionsoft](http://github.com/bvalosek/grunt-infusionsoft) grunt\nplugin. To recreate the generated files, run `grunt infusionsoft`.\n\nCheck out the `infusionsoft` directory to see the output.\n\n## More Examples\n\nAll examples use `infusionsoft` as an instantiated DataContext with your app\nname and API key. ie:\n\n```javascript\nvar infusionsoft = new api.DataContext('myAppName', 'MY_API_KEY');\n```\n\n### Get monthly revenue from a particular month\n\n```javascript\ninfusionsoft.Payments\n    .like(Payment.PayDate, '2013-06%')\n    .sum(function(x) { return x.PayAmt; })\n    .done(function(total) {\n        console.log('total revenue: ' + total);\n    });\n```\n\n### Login a user and get their info\n\nAnd an example of using the `fail` method to catch any problems.\n\n```javascript\ninfusionsoft.DataService\n    .authenticateUser('user@email.com', 'md5-hash-of-password')\n    .then(function(userId) {\n        return infusionsoft.Users.where(User.Id, userId).first();\n    })\n    .then(function(user) {\n        console.log('Hello ' + user.FirstName + ' ' + user.LastName);\n    })\n    .fail(function(err) {\n        console.log('uh oh: ' + err);\n    });\n```\n\n### Get all invoices for a specific month, grouped by product\n\nUses [underscore](http://underscorejs.org/).\n\n```javascript\ninfusionsoft.Invoices\n    .like(Invoice.DateCreated, '2013-08%')\n    .groupBy(function(x) { return x.ProductSold; })\n    .done(function(result) {\n        _(result).each(function(invoices, productId) {\n            console.log(productId, invoices.length);\n        });\n    });\n```\n\nSame as above, but use the `spread` function to wait on 2 promises to get the\ncorresponding product names. The API hits for querying both the `Product` table\nand the `Invoice` table will actually fire off at the same time.\n\nHashtag asynchronous.\n\n```javascript\nvar products = infusionsoft.Products.toArray();\nvar invoices = infusionsoft.Invoices\n    .like(Invoice.DateCreated, '2013-08%')\n    .groupBy(function(x) { return x.ProductSold; });\n\nQ.spread([products, invoices], function(products, invoices) {\n   _(invoices).each(function(invoices, productId)  {\n        var productName = _(products)\n            .find(function(x) { return x.Id == productId; })\n            .ProductName;\n\n        console.log(productName, invoices.length);\n   });\n});\n```\n\n### From an email address, get a contact's tags\n\n```javascript\nsdk.Contacts\n    .where(Contact.Email, 'some@email.com')\n    .first()\n    .then(function(contact) {\n        return sdk.ContactGroupAssigns\n            .where(ContactGroupAssign.ContactId, contact.Id)\n            .toArray();\n    })\n    .then(function(cgas) {\n        cgas.forEach(function(group) {\n            console.log(group.ContactGroup, group.DateCreated);\n        });\n    });\n```\n\n### Get the full Product Category Name for all subscription plans\n\nOkay, take a deep breath. We can do (inner) joins. We fake it though... the\n`inner` part of the join has to be loaded entirely and then we do a `O(n^2)`\niteration to make it, but we can still do it. If the `inner` is cheap, this\nisn't too bad. Especially when the SDK will handle loading, paging, waiting,\netc... all for you.\n\nSyntax (stolen from C#'s LINQ):\n\n### `join` (`innerQueryable`, `outerKey`, `innerKey`, `selectorFn`)\n\nLet's do this:\n\n\n```javascript\nvar pc    = infusionsoft.ProductCategories;\nvar pca   = infusionsoft.ProductCategoryAssigns;\nvar plans = infusionsoft.SubscriptionPlans;\n\n// Join the categories onto itself for creating the full category name\n// (category parent name + category name)\nvar categories = pc\n    .join(pc, 'ParentId', 'Id', function(pc, parent) {\n        return {\n            Id: pc.Id,\n            Name: parent.CategoryDisplayName + ' ' + pc.CategoryDisplayName\n        }; });\n\nvar subPlans = plans\n\n    // Join the sub plan (which only has product Id) onto the PCA table to get\n    // the product category ID\n    .join(pca, 'ProductId', 'ProductId', function(plan, pca) {\n        plan.ProductCategoryId = pca.ProductCategoryId;\n        return plan;\n    })\n\n\n    // Join our categories object we made above onto the projection from the\n    // most recent join to get the full category name + subscription plan Id\n    .join(categories, 'ProductCategoryId', 'Id', function(plan, category) {\n        return { planId: plan.Id, category: category.Name }; });\n\nsubPlans.toArray().done(function(d) { console.log(d); });\n```\n\nWhat happens magically behind the scenes is pretty nice. When we call\n`toArray()` at the end, we first query the SubscriptionPlan table (aliased as\n`plans`). It then knows we need to join the `ProductCategoryAssign` table on\nthere, so it fetches that (which may be more than one page). It finally gets\nthe `ProductCategory` table (in its entirety), and joins them all up.\n\nThe syntax looks nasty, but that is somewhat unavoidable with a `join`\nfunction.\n\n\n## License\nCopyright 2013 Brandon Valosek\n\n**Infusionsoft API** is released under the MIT license.\n\n","maintainers":[{"name":"bvalosek","email":"bvalosek@gmail.com"}],"time":{"modified":"2022-07-13T13:34:37.081Z","created":"2013-07-31T01:29:45.776Z","0.0.1":"2013-07-31T01:29:46.524Z","0.1.0":"2013-08-03T03:11:37.676Z","0.2.0":"2013-08-05T13:22:04.518Z","0.3.0":"2013-08-07T02:28:38.140Z","0.3.1":"2013-08-08T21:22:34.900Z","0.3.2":"2013-08-09T05:49:39.693Z","0.3.3":"2013-08-09T05:54:11.264Z","0.3.4":"2013-08-09T05:56:32.086Z","0.3.5":"2013-08-09T05:58:06.171Z","0.4.1":"2013-08-20T02:32:19.793Z","0.5.0":"2014-01-08T20:25:12.171Z","0.6.0":"2014-04-16T01:37:27.655Z"},"author":{"name":"Brandon Valosek"},"repository":{"type":"git","url":"git@github.com:bvalosek/infusionsoft-api"},"users":{"bkwarner":true},"homepage":"https://github.com/bvalosek/infusionsoft-api","keywords":["infusionsoft","api"],"bugs":{"url":"https://github.com/bvalosek/infusionsoft-api/issues"},"license":"MIT","readmeFilename":"README.md"}