Created
March 28, 2017 12:43
-
-
Save halvardos/6d60e840bee18a0969649a15f3cf29f0 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
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