@honkandgo/msads
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -1,2 +0,2 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,r){this.objects[e]={value:t,maxAge:r||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var r=Date.now();if(t.inserted+1e3*t.maxAge>r)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),r=require("node-fetch"),n=require("soap"),i=require("querystring").stringify;module.exports=function(){function o(e){var r=e.clientId,n=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=r,this.clientSecret=n,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,r("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,r,i){try{var o=this;return Promise.resolve(Promise.all([n.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var n=t[0];return n.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},r),"","tns"),n})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,r,n,i){void 0===r&&(r={}),void 0===n&&(n={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,r,i)).then(function(e){return function(r,i){try{var o=Promise.resolve(e[t+"Async"](n)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(r){throw console.warn("Error in "+t+". Request was "+e.lastRequest),r})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,r){try{return Promise.resolve(n.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][r],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return r(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}(); | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),n=require("node-fetch"),r=require("soap"),i=require("querystring").stringify;module.exports=function(){function o(e){var n=e.clientId,r=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=n,this.clientSecret=r,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,n,i){try{var o=this;return Promise.resolve(Promise.all([r.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var r=t[0];return r.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},n),"","tns"),r.addHttpHeader("Connection","keep-alive"),r})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,n,r,i){void 0===n&&(n={}),void 0===r&&(r={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,n,i)).then(function(e){return function(n,i){try{var o=Promise.resolve(e[t+"Async"](r)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(n){throw console.warn("Error in "+t+". Request was "+e.lastRequest),n})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,n){try{return Promise.resolve(r.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][n],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return n(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}(); | ||
//# sourceMappingURL=msads.js.map |
@@ -1,2 +0,2 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}class t{constructor(e=3600){this.objects={},this.maxAge=e}set(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}}get(e){const t=this.objects[e];if(t){const n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}}has(e){return void 0!==this.get(e)}}const n=require("node-fetch"),s=require("soap"),{stringify:i}=require("querystring");export default class{constructor({clientId:e,clientSecret:n,developerToken:s,refreshToken:i}){this.pool=new t,this.clientId=e,this.clientSecret=n,this.developerToken=s,this.refreshToken=i}async getAccessToken(e){return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(e=>e.json()).then(e=>{if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),this.pool.get(e)}async getSoapClient(t,n,i){const[r,a]=await Promise.all([s.createClientAsync(t),this.getAccessToken(i)]);return r.addSoapHeader(e({AuthenticationToken:a,DeveloperToken:this.developerToken},n),"","tns"),r}async callMethod(e,t,n={},s={},i=this.refreshToken){const r=await this.getSoapClient(e,n,i);try{return(await r[t+"Async"](s))[0]}catch(e){throw console.warn(`Error in ${t}. Request was ${r.lastRequest}`),e}}async describe(e,t,n){const i=await s.createClientAsync(e);console.log(JSON.stringify(i.describe()[t+"Service"][`BasicHttpBinding_I${t}Service`][n],null,2))}async describeCampaignManagement(e){this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e)}async describeCustomerManagement(e){this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e)}async describeBulk(e){this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e)}async describeReporting(e){this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e)}bulk(...e){return this.callMethod("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl",...e)}campaignManagement(...e){return this.callMethod("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl",...e)}customerManagement(...e){return this.callMethod("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl",...e)}reporting(...e){return this.callMethod("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl",...e)}async downloadFile(e,t){const s=await this.getAccessToken(t);return n(e,{headers:{AuthenticationToken:s}}).then(e=>e.buffer())}} | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}class t{constructor(e=3600){this.objects={},this.maxAge=e}set(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}}get(e){const t=this.objects[e];if(t){const n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}}has(e){return void 0!==this.get(e)}}const n=require("node-fetch"),s=require("soap"),{stringify:i}=require("querystring");export default class{constructor({clientId:e,clientSecret:n,developerToken:s,refreshToken:i}){this.pool=new t,this.clientId=e,this.clientSecret=n,this.developerToken=s,this.refreshToken=i}async getAccessToken(e){return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(e=>e.json()).then(e=>{if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),this.pool.get(e)}async getSoapClient(t,n,i){const[r,a]=await Promise.all([s.createClientAsync(t),this.getAccessToken(i)]);return r.addSoapHeader(e({AuthenticationToken:a,DeveloperToken:this.developerToken},n),"","tns"),r.addHttpHeader("Connection","keep-alive"),r}async callMethod(e,t,n={},s={},i=this.refreshToken){const r=await this.getSoapClient(e,n,i);try{return(await r[t+"Async"](s))[0]}catch(e){throw console.warn(`Error in ${t}. Request was ${r.lastRequest}`),e}}async describe(e,t,n){const i=await s.createClientAsync(e);console.log(JSON.stringify(i.describe()[t+"Service"][`BasicHttpBinding_I${t}Service`][n],null,2))}async describeCampaignManagement(e){this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e)}async describeCustomerManagement(e){this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e)}async describeBulk(e){this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e)}async describeReporting(e){this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e)}bulk(...e){return this.callMethod("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl",...e)}campaignManagement(...e){return this.callMethod("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl",...e)}customerManagement(...e){return this.callMethod("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl",...e)}reporting(...e){return this.callMethod("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl",...e)}async downloadFile(e,t){const s=await this.getAccessToken(t);return n(e,{headers:{AuthenticationToken:s}}).then(e=>e.buffer())}} | ||
//# sourceMappingURL=msads.modern.js.map |
@@ -1,2 +0,2 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,r){this.objects[e]={value:t,maxAge:r||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var r=Date.now();if(t.inserted+1e3*t.maxAge>r)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),r=require("node-fetch"),n=require("soap"),i=require("querystring").stringify,o=function(){function o(e){var r=e.clientId,n=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=r,this.clientSecret=n,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,r("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,r,i){try{var o=this;return Promise.resolve(Promise.all([n.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var n=t[0];return n.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},r),"","tns"),n})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,r,n,i){void 0===r&&(r={}),void 0===n&&(n={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,r,i)).then(function(e){return function(r,i){try{var o=Promise.resolve(e[t+"Async"](n)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(r){throw console.warn("Error in "+t+". Request was "+e.lastRequest),r})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,r){try{return Promise.resolve(n.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][r],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return r(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}();export default o; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),n=require("node-fetch"),r=require("soap"),i=require("querystring").stringify,o=function(){function o(e){var n=e.clientId,r=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=n,this.clientSecret=r,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,n,i){try{var o=this;return Promise.resolve(Promise.all([r.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var r=t[0];return r.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},n),"","tns"),r.addHttpHeader("Connection","keep-alive"),r})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,n,r,i){void 0===n&&(n={}),void 0===r&&(r={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,n,i)).then(function(e){return function(n,i){try{var o=Promise.resolve(e[t+"Async"](r)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(n){throw console.warn("Error in "+t+". Request was "+e.lastRequest),n})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,n){try{return Promise.resolve(r.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][n],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return n(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}();export default o; | ||
//# sourceMappingURL=msads.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).msads=t()}(this,function(){function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),n=require("node-fetch"),r=require("soap"),i=require("querystring").stringify;return function(){function o(e){var n=e.clientId,r=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=n,this.clientSecret=r,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,n,i){try{var o=this;return Promise.resolve(Promise.all([r.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var r=t[0];return r.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},n),"","tns"),r})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,n,r,i){void 0===n&&(n={}),void 0===r&&(r={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,n,i)).then(function(e){return function(n,i){try{var o=Promise.resolve(e[t+"Async"](r)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(n){throw console.warn("Error in "+t+". Request was "+e.lastRequest),n})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,n){try{return Promise.resolve(r.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][n],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return n(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}()}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).msads=t()}(this,function(){function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){function e(e){void 0===e&&(e=3600),this.objects={},this.maxAge=e}var t=e.prototype;return t.set=function(e,t,n){this.objects[e]={value:t,maxAge:n||this.maxAge,inserted:Date.now()}},t.get=function(e){var t=this.objects[e];if(t){var n=Date.now();if(t.inserted+1e3*t.maxAge>n)return t.value;delete this.objects[e]}},t.has=function(e){return void 0!==this.get(e)},e}(),n=require("node-fetch"),r=require("soap"),i=require("querystring").stringify;return function(){function o(e){var n=e.clientId,r=e.clientSecret,i=e.developerToken,o=e.refreshToken;this.pool=new t,this.clientId=n,this.clientSecret=r,this.developerToken=i,this.refreshToken=o}var s=o.prototype;return s.getAccessToken=function(e){try{return this.pool.has(e)||this.pool.set(e,n("https://login.microsoftonline.com/common/oauth2/v2.0/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i({client_id:this.clientId,client_secret:this.clientSecret,refresh_token:e,grant_type:"refresh_token",scope:"https://ads.microsoft.com/msads.manage"})}).then(function(e){return e.json()}).then(function(e){if(e.error)throw console.warn(e.error),new Error("Unable to access Microsoft Ads. Try reconnecting your Microsoft ad account in Relaxad.");return e.access_token})),Promise.resolve(this.pool.get(e))}catch(e){return Promise.reject(e)}},s.getSoapClient=function(t,n,i){try{var o=this;return Promise.resolve(Promise.all([r.createClientAsync(t),o.getAccessToken(i)])).then(function(t){var r=t[0];return r.addSoapHeader(e({AuthenticationToken:t[1],DeveloperToken:o.developerToken},n),"","tns"),r.addHttpHeader("Connection","keep-alive"),r})}catch(e){return Promise.reject(e)}},s.callMethod=function(e,t,n,r,i){void 0===n&&(n={}),void 0===r&&(r={});try{return void 0===i&&(i=this.refreshToken),Promise.resolve(this.getSoapClient(e,n,i)).then(function(e){return function(n,i){try{var o=Promise.resolve(e[t+"Async"](r)).then(function(e){return e[0]})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(n){throw console.warn("Error in "+t+". Request was "+e.lastRequest),n})})}catch(e){return Promise.reject(e)}},s.describe=function(e,t,n){try{return Promise.resolve(r.createClientAsync(e)).then(function(e){console.log(JSON.stringify(e.describe()[t+"Service"]["BasicHttpBinding_I"+t+"Service"][n],null,2))})}catch(e){return Promise.reject(e)}},s.describeCampaignManagement=function(e){try{return this.describe("https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl","CampaignManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeCustomerManagement=function(e){try{return this.describe("https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl","CustomerManagement",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeBulk=function(e){try{return this.describe("https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl","Bulk",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.describeReporting=function(e){try{return this.describe("https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl","Reporting",e),Promise.resolve()}catch(e){return Promise.reject(e)}},s.bulk=function(){return this.callMethod.apply(this,["https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/BulkService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.campaignManagement=function(){return this.callMethod.apply(this,["https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V13/CampaignManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.customerManagement=function(){return this.callMethod.apply(this,["https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.reporting=function(){return this.callMethod.apply(this,["https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl"].concat([].slice.call(arguments)))},s.downloadFile=function(e,t){try{return Promise.resolve(this.getAccessToken(t)).then(function(t){return n(e,{headers:{AuthenticationToken:t}}).then(function(e){return e.buffer()})})}catch(e){return Promise.reject(e)}},o}()}); | ||
//# sourceMappingURL=msads.umd.js.map |
{ | ||
"name": "@honkandgo/msads", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -60,2 +60,3 @@ const fetch = require('node-fetch') | ||
) | ||
soapClient.addHttpHeader('Connection', 'keep-alive') | ||
return soapClient | ||
@@ -62,0 +63,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72913
15
258
4
5