Skip to content

Instantly share code, notes, and snippets.

@halvardos
Created March 28, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halvardos/6d60e840bee18a0969649a15f3cf29f0 to your computer and use it in GitHub Desktop.
Save halvardos/6d60e840bee18a0969649a15f3cf29f0 to your computer and use it in GitHub Desktop.
uploaded_videos_pre_write: function(bundle) {
bundle.request.method = 'POST';
bundle.request.headers['X-Metabase-Session'] = bundle.auth_fields.user_token;
delete bundle.request.headers.username;
delete bundle.request.headers.password;
// the id of the card we want to query on metabase
var cardID = 99999;
var query = '{"cardID":'+cardID+',"parameters":[{"type":"category","target":["variable",["template-tag","customerID"]],"value":"'+bundle.action_fields_full.customerAccount+'"}]}';
bundle.request.data = query;
return bundle.request;
}
uploaded_videos_post_write: function(bundle) {
var response = JSON.parse(bundle.response.content);
var upload_count = 0;
if (response.data.rows[0] != null) {
upload_count = response.data.rows[0][0];
}
var uploadedAccount = {
customer_account: bundle.action_fields_full.customer_account,
number_of_uploads: upload_count,
account_email: bundle.action_fields_full.account_email
};
return uploadedAccount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment