Skip to content

Commit

Permalink
add the logic for the create webhook button #229
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Mar 13, 2018
1 parent 45e9d8c commit 782bb28
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions view/adminhtml/web/js/configapikey.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define(
"options": {
"storeUrl": "",
"detailsUrl": "",
"storeGridUrl": ""
"storeGridUrl": "",
"createWebhookUrl": ""
},

_init: function () {
Expand All @@ -38,9 +39,30 @@ define(
if ($('#mailchimp_general_monkeystore option').length>1) {
$('#row_mailchimp_general_monkeystore .note').hide();
}
//$('#mailchimp_general_monkeylist').prop('disabled', true);
$('#mailchimp_general_webhook_create').click(function() {
var apiKey = $('#mailchimp_general_apikey').find(':selected').val();
var listId = $('#mailchimp_general_monkeylist').find(':selected').val();
self._createWebhook(apiKey, listId);
});
},
_createWebhook: function(apiKey, listId) {
var createWebhookUrl = this.options.createWebhookUrl;
$.ajax({
url: createWebhookUrl,
data: {'form_key': window.FORM_KEY,'apikey': apiKey, 'listId': listId},
type: 'POST',
success: function(data){
if(data.valid==0) {
alert('Error: '+data.message);
}
else if(data.valid==1) {
alert('WebHook created');
}
}
}).done(function(a) {
console.log(a);
});
},

_loadStores: function (apiKey) {
var self = this;
var storeUrl = this.options.storeUrl;
Expand Down

0 comments on commit 782bb28

Please sign in to comment.