Skip to content

Instantly share code, notes, and snippets.

@CoreyTrombley
Last active August 29, 2015 14:16
Show Gist options
  • Save CoreyTrombley/5385e1ec2855419999f7 to your computer and use it in GitHub Desktop.
Save CoreyTrombley/5385e1ec2855419999f7 to your computer and use it in GitHub Desktop.
/**
* @file Status toggle mixin
*/
var _ = require('lodash');
var config = require('../../../shared/config');
var Api = require('../../../shared/lib/api')(config());
var authToken = window.authToken;
module.exports = {
status: '',
body: {},
getParams: {},
request: '',
facebookStatusToggle: function(object) {
this.status = object.state.disabled ? 'ACTIVE' : 'PAUSED';
this.body = {'campaign_group_status': this.status};
this.getParams = {
campaignId: object.props.id,
publisherName: object.props.publisher
};
this.request = 'updateStatus';
return this;
},
twitterStatusToggle: function(object) {
this.request = 'patchCampaignTwitter';
this.status = !(object.state.disabled);
this.body = {'paused': this.status};
this.getParams = {
adCampaignIds: object.props.id,
adAccountId: object.props.campaign.account_id,
publisherName: object.props.publisher
};
return this;
},
publisherRequest: function(cb) {
Api.publishers.request(this.request, this.getParams, {token: authToken, body: this.body}, function(data) {
cb(data);
});
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment