cake-affiliate-api v0.0.3
CAKE Affiliate API for Node.js
CAKE is SaaS platform providing marketing intelligence for perforfmance marketers (LinkedIn). These guys have many different APIs thus they provide big marketing platform. This module covers Affiliate APIs group.
Requirements
- CoffeeScript installed globally (for
cake build)
Installation
npm install cake-affiliate-api --saveExample
'use strict'
var CakeAffiliateAPI = require('cake-affiliate-api')
, options
, client
options = {
"apiKey": "MY_API_KEY",
"affiliateId": "100500",
"baseUrl": "https://cake.coolnetwork.com",
"rawResponse": true
}
client = new CakeAffiliateAPI(options)
client.offerFeed({offerStatusId: 3}, handleResult)
function handleResult(err, data) {
if (err) {
// handle error...
}
else {
handleData(data)
}
}API
Keep in mind that every API option which is passed in camelcase is underscored before making HTTP call. So it's OK to name options like mediaTypeCategoryId (converted to media_type_category_id).
addLinkCreative(campaignId, data, callback)
data options:
- creativeName (required)
- offerLink (required)
descriptiondefaults tonull
applyForOffer(offerContractId, data, callback)
data options:
- mediaTypeId (required)
notesdefaults tonull- agreedToTerms defaults to
false - agreedFromIpAddress (required)
creativeFeed(exportFeedId, updatesSince, callback)
getCampaign(campaignId, callback)
getCreativeCode(campaignId, creativeId, callback)
getCreativeTypes(callback)
getFeaturedOffer(callback)
getMediaTypeCategories(callback)
getOfferStatuses(callback)
getPixelTokens(callback)
getSubAffiliates(query, callback)
query options:
startAtRowdefaults to1rowLimitdefaults to0
getSupressionList(offerId, callback)
getTags(callback)
getVerticalCategories(callback)
getVerticals(callback)
offerFeed(query, callback)
query options:
campaignNamedefaults''mediaTypeCategoryIddefaults to0verticalCategoryIddefaults to0verticalIddefaults to0offerStatusIddefaults to0tagIddefaults to0startAtRowdefaults to1rowLimitdefaults to0
sendCreativePack(campaignId, creativeId, contactId, callback)
setPixel(campaignId, pixelHtml, callback)
setPostbackURL(campaignId, postbackURL, callback)
setTestLink(campaignId, testLink, callback)
Options
apiKey defaults to
null- API key. Read Affiliate API Documentation Notes to know where to get it.
affiliateId defaults to
null- Affiliate Id. Read documentation above.
baseUrl defaults to
null- API endpoint of CAKE-based network.
rawResponse defaults
false- If
truexml2js is not called for XML response and it's returned as string.
- If
parser defaults to
null- Should be a function like
parse(xmlString, callback)wherecallbackaccepts(err, response)
- Should be a function like
xml2jsOptions defaults to
{explicitArray: false}- Options passed to
xml2js.parseString(). If specified will overwrite defaults. Also if specified, client won't try to process response smartly (i.e. if response outputs collection it will return rawxml2jsoutput instead of array).
- Options passed to
FAQ
Why module is writted on CoffeeScript but compiled to JavaScript after npm install?
I really like CoffeeScript for fast module development but dislike when people do something like this:
require('coffee-script');
require('./module.coffee');Why should we do this if in the end all is compiled to JavaScript? :wink:
TODO
- Implement ALL APIs