Last active
August 29, 2015 14:16
-
-
Save CoreyTrombley/5385e1ec2855419999f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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