@honkandgo/spotifyads
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,2 +0,2 @@ | ||
var t,e=(t=require("node-fetch"))&&"object"==typeof t&&"default"in t?t.default:t,n=require("querystring"),r=["clientId","clientSecret"];module.exports=function(t){void 0===t&&(t={});var u=function(t){var u=t.clientId,o=t.clientSecret,c=function(t,e){if(null==t)return{};var n,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(u[n]=t[n]);return u}(t,r),s=function(t){void 0===t&&(t=3600);var e={},n=function(t){var n=e[t];if(n){var r=Date.now();if(n.inserted+1e3*n.maxAge>r)return n.value;delete e[t]}};return{get:n,set:function(n,r,u){e[n]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==n(t)}}}(1800),a=function(t,r,a,i){try{return void 0===i&&(i=c.refreshToken),Promise.resolve(function(t){try{return s.has(t)||s.set(t,function(t){try{return Promise.resolve(e("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:n.stringify({refresh_token:t,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(t)),Promise.resolve(s.get(t))}catch(t){return Promise.reject(t)}}(i)).then(function(n){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===t&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(e(u,{method:t,headers:{"Content-Type":"application/json",Authorization:"Bearer "+n},body:a&&"GET"!==t?JSON.stringify(a):null})).then(function(t){return function(e,n){try{var r=Promise.resolve(t.json())}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(e){if(200!==t.status)throw new Error(JSON.stringify(e))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,e,n){return a("GET",t,e,n)},post:function(t,e,n){return a("POST",t,e,n)},put:function(t,e,n){return a("PUT",t,e,n)}}}(t),o=u.get,c=u.post,s=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,e,n){return c("/adAccounts/"+t+"/campaigns",e,n)},updateCampaign:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e,n,r)},updateCampaignStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e+"/status/"+n,null,r)},getCampaign:function(t,e,n,r){return o("/adAccounts/"+t+"/campaigns/"+e,n,r)},getCampaignsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/campaigns",null,e)},createAd:function(t,e,n){return c("/adAccounts/"+t+"/ads",e,n)},updateAd:function(t,e,n,r){return s("/adAccounts/"+t+"/ads/"+e,n,r)},getAd:function(t,e,n,r){return o("/adAccounts/"+t+"/ads/"+e,n,r)},getAds:function(t,e){return c("/ads",t,e)},getAdsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/ads",null,e)},createAdvertiser:function(t,e,n){return c("/adAccounts/"+t+"/advertisers",e,n)},getAdvertisersByAdAccount:function(t,e){return o("/adAccounts/"+t+"/advertisers",null,e)},getImageUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/image",e,n)},getImageAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/image",e,n)},getVideoAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/video",e,n)},getVideoUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/video",e,n)},getAudioAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/audio",e,n)},getAudioUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/fullmix",e,n)},getAdSets:function(t,e){return c("/adSets",t,e)},updateAdSetStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e+"/status/"+n,null,r)},updateAdSet:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e,n,r)},createAdSet:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e+"/adSets",n,r)},createReport:function(t,e){return c("/report",t,e)},getGeoTargets:function(t){return o("/targets/geos",t)}}}; | ||
var t,e=(t=require("node-fetch"))&&"object"==typeof t&&"default"in t?t.default:t,n=require("querystring"),r=["clientId","clientSecret"];module.exports=function(t){void 0===t&&(t={});var u=function(t){var u=t.clientId,o=t.clientSecret,s=function(t,e){if(null==t)return{};var n,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(u[n]=t[n]);return u}(t,r),c=function(t){void 0===t&&(t=3600);var e={},n=function(t){var n=e[t];if(n){var r=Date.now();if(n.inserted+1e3*n.maxAge>r)return n.value;delete e[t]}};return{get:n,set:function(n,r,u){e[n]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==n(t)}}}(1800),a=function(t,r,a,i){try{return void 0===i&&(i=s.refreshToken),Promise.resolve(function(t){try{return c.has(t)||c.set(t,function(t){try{return Promise.resolve(e("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:n.stringify({refresh_token:t,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(t)),Promise.resolve(c.get(t))}catch(t){return Promise.reject(t)}}(i)).then(function(n){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===t&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(e(u,{method:t,headers:{"Content-Type":"application/json",Authorization:"Bearer "+n},body:a&&"GET"!==t?JSON.stringify(a):null})).then(function(t){return function(e,n){try{var r=Promise.resolve(t.json())}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(e){if(200!==t.status)throw new Error(JSON.stringify(e))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,e,n){return a("GET",t,e,n)},post:function(t,e,n){return a("POST",t,e,n)},put:function(t,e,n){return a("PUT",t,e,n)}}}(t),o=u.get,s=u.post,c=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,e,n){return s("/adAccounts/"+t+"/campaigns",e,n)},updateCampaign:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e,n,r)},updateCampaignStatus:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e+"/status/"+n,null,r)},getCampaign:function(t,e,n,r){return o("/adAccounts/"+t+"/campaigns/"+e,n,r)},getCampaignsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/campaigns",null,e)},createAd:function(t,e,n){return s("/adAccounts/"+t+"/ads",e,n)},updateAd:function(t,e,n,r){return c("/adAccounts/"+t+"/ads/"+e,n,r)},getAd:function(t,e,n,r){return o("/adAccounts/"+t+"/ads/"+e,n,r)},getAds:function(t,e){return s("/ads",t,e)},getAdsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/ads",null,e)},createAdvertiser:function(t,e,n){return s("/adAccounts/"+t+"/advertisers",e,n)},getAdvertisersByAdAccount:function(t,e){return o("/adAccounts/"+t+"/advertisers",null,e)},getImageUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/image",e,n)},getImageAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/image",e,n)},getVideoAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/video",e,n)},getVideoUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/video",e,n)},getAudioAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/audio",e,n)},getAudioUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/fullmix",e,n)},getAdSets:function(t,e){return s("/adSets",t,e)},updateAdSetStatus:function(t,e,n,r){return c("/adAccounts/"+t+"/adSets/"+e+"/status/"+n,null,r)},updateAdSet:function(t,e,n,r){return c("/adAccounts/"+t+"/adSets/"+e,n,r)},createAdSet:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e+"/adSets",n,r)},createReport:function(t,e){return s("/report",t,e)},getGeoTargets:function(t){return o("/targets/geos",t)},getGenreTargets:function(t){return o("/targets/genre",t)},getPlaylistTargets:function(t){return o("/targets/playlist",t)},getAudienceEstimate:function(t,e,n){return s("adAccounts/"+t+"/estimate/audience",e,n)}}}; | ||
//# sourceMappingURL=spotifyads.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"node-fetch";import{stringify as e}from"querystring";const s=["clientId","clientSecret"];export default function(a={}){const{get:n,post:c,put:o}=(a=>{let{clientId:n,clientSecret:c}=a,o=function(t,e){if(null==t)return{};var s,a,n={},c=Object.keys(t);for(a=0;a<c.length;a++)e.indexOf(s=c[a])>=0||(n[s]=t[s]);return n}(a,s);const r=((t=3600)=>{const e={},s=t=>{const s=e[t];if(s){const a=Date.now();if(s.inserted+1e3*s.maxAge>a)return s.value;delete e[t]}};return{get:s,set:(s,a,n)=>{e[s]={value:a,maxAge:n||t,inserted:Date.now()}},has:t=>void 0!==s(t)}})(1800),d=async(s,a,d,u=o.refreshToken)=>{const i=await(async s=>(r.has(s)||r.set(s,(async s=>t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(`${n}:${c}`).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:e({refresh_token:s,grant_type:"refresh_token"})}).then(t=>t.json()).then(t=>t.access_token))(s)),r.get(s)))(u);let A=`https://api-partner.spotify.com/ads/v1.4${a.startsWith("/")?"":"/"}${a}`;A="GET"===s&&d?A+"?"+new URLSearchParams(d):A;const g=await t(A,{method:s,headers:{"Content-Type":"application/json",Authorization:"Bearer "+i},body:d&&"GET"!==s?JSON.stringify(d):null});try{return await g.json()}catch(t){if(200!==g.status)throw new Error(JSON.stringify(t))}};return{get:async(t,e,s)=>d("GET",t,e,s),post:async(t,e,s)=>d("POST",t,e,s),put:async(t,e,s)=>d("PUT",t,e,s)}})(a);return{listAdAccounts:t=>n("/currentUser/adAccounts",null,t),createCampaign:(t,e,s)=>c(`/adAccounts/${t}/campaigns`,e,s),updateCampaign:(t,e,s,a)=>o(`/adAccounts/${t}/campaigns/${e}`,s,a),updateCampaignStatus:(t,e,s,a)=>o(`/adAccounts/${t}/campaigns/${e}/status/${s}`,null,a),getCampaign:(t,e,s,a)=>n(`/adAccounts/${t}/campaigns/${e}`,s,a),getCampaignsByAdAccount:(t,e)=>n(`/adAccounts/${t}/campaigns`,null,e),createAd:(t,e,s)=>c(`/adAccounts/${t}/ads`,e,s),updateAd:(t,e,s,a)=>o(`/adAccounts/${t}/ads/${e}`,s,a),getAd:(t,e,s,a)=>n(`/adAccounts/${t}/ads/${e}`,s,a),getAds:(t,e)=>c("/ads",t,e),getAdsByAdAccount:(t,e)=>n(`/adAccounts/${t}/ads`,null,e),createAdvertiser:(t,e,s)=>c(`/adAccounts/${t}/advertisers`,e,s),getAdvertisersByAdAccount:(t,e)=>n(`/adAccounts/${t}/advertisers`,null,e),getImageUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/image`,e,s),getImageAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/image`,e,s),getVideoAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/video`,e,s),getVideoUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/video`,e,s),getAudioAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/audio`,e,s),getAudioUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/fullmix`,e,s),getAdSets:(t,e)=>c("/adSets",t,e),updateAdSetStatus:(t,e,s,a)=>o(`/adAccounts/${t}/adSets/${e}/status/${s}`,null,a),updateAdSet:(t,e,s,a)=>o(`/adAccounts/${t}/adSets/${e}`,s,a),createAdSet:(t,e,s,a)=>c(`/adAccounts/${t}/campaigns/${e}/adSets`,s,a),createReport:(t,e)=>c("/report",t,e),getGeoTargets:t=>n("/targets/geos",t)}} | ||
import t from"node-fetch";import{stringify as e}from"querystring";const s=["clientId","clientSecret"];export default function(a={}){const{get:n,post:c,put:o}=(a=>{let{clientId:n,clientSecret:c}=a,o=function(t,e){if(null==t)return{};var s,a,n={},c=Object.keys(t);for(a=0;a<c.length;a++)e.indexOf(s=c[a])>=0||(n[s]=t[s]);return n}(a,s);const r=((t=3600)=>{const e={},s=t=>{const s=e[t];if(s){const a=Date.now();if(s.inserted+1e3*s.maxAge>a)return s.value;delete e[t]}};return{get:s,set:(s,a,n)=>{e[s]={value:a,maxAge:n||t,inserted:Date.now()}},has:t=>void 0!==s(t)}})(1800),d=async(s,a,d,i=o.refreshToken)=>{const u=await(async s=>(r.has(s)||r.set(s,(async s=>t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(`${n}:${c}`).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:e({refresh_token:s,grant_type:"refresh_token"})}).then(t=>t.json()).then(t=>t.access_token))(s)),r.get(s)))(i);let g=`https://api-partner.spotify.com/ads/v1.4${a.startsWith("/")?"":"/"}${a}`;g="GET"===s&&d?g+"?"+new URLSearchParams(d):g;const A=await t(g,{method:s,headers:{"Content-Type":"application/json",Authorization:"Bearer "+u},body:d&&"GET"!==s?JSON.stringify(d):null});try{return await A.json()}catch(t){if(200!==A.status)throw new Error(JSON.stringify(t))}};return{get:async(t,e,s)=>d("GET",t,e,s),post:async(t,e,s)=>d("POST",t,e,s),put:async(t,e,s)=>d("PUT",t,e,s)}})(a);return{listAdAccounts:t=>n("/currentUser/adAccounts",null,t),createCampaign:(t,e,s)=>c(`/adAccounts/${t}/campaigns`,e,s),updateCampaign:(t,e,s,a)=>o(`/adAccounts/${t}/campaigns/${e}`,s,a),updateCampaignStatus:(t,e,s,a)=>o(`/adAccounts/${t}/campaigns/${e}/status/${s}`,null,a),getCampaign:(t,e,s,a)=>n(`/adAccounts/${t}/campaigns/${e}`,s,a),getCampaignsByAdAccount:(t,e)=>n(`/adAccounts/${t}/campaigns`,null,e),createAd:(t,e,s)=>c(`/adAccounts/${t}/ads`,e,s),updateAd:(t,e,s,a)=>o(`/adAccounts/${t}/ads/${e}`,s,a),getAd:(t,e,s,a)=>n(`/adAccounts/${t}/ads/${e}`,s,a),getAds:(t,e)=>c("/ads",t,e),getAdsByAdAccount:(t,e)=>n(`/adAccounts/${t}/ads`,null,e),createAdvertiser:(t,e,s)=>c(`/adAccounts/${t}/advertisers`,e,s),getAdvertisersByAdAccount:(t,e)=>n(`/adAccounts/${t}/advertisers`,null,e),getImageUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/image`,e,s),getImageAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/image`,e,s),getVideoAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/video`,e,s),getVideoUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/video`,e,s),getAudioAssets:(t,e,s)=>n(`/adAccounts/${t}/assets/audio`,e,s),getAudioUploadUrl:(t,e,s)=>c(`/adAccounts/${t}/assets/fullmix`,e,s),getAdSets:(t,e)=>c("/adSets",t,e),updateAdSetStatus:(t,e,s,a)=>o(`/adAccounts/${t}/adSets/${e}/status/${s}`,null,a),updateAdSet:(t,e,s,a)=>o(`/adAccounts/${t}/adSets/${e}`,s,a),createAdSet:(t,e,s,a)=>c(`/adAccounts/${t}/campaigns/${e}/adSets`,s,a),createReport:(t,e)=>c("/report",t,e),getGeoTargets:t=>n("/targets/geos",t),getGenreTargets:t=>n("/targets/genre",t),getPlaylistTargets:t=>n("/targets/playlist",t),getAudienceEstimate:(t,e,s)=>c(`adAccounts/${t}/estimate/audience`,e,s)}} | ||
//# sourceMappingURL=spotifyads.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"node-fetch";import{stringify as n}from"querystring";var e=["clientId","clientSecret"];export default function(r){void 0===r&&(r={});var u=function(r){var u=r.clientId,o=r.clientSecret,c=function(t,n){if(null==t)return{};var e,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)n.indexOf(e=o[r])>=0||(u[e]=t[e]);return u}(r,e),s=function(t){void 0===t&&(t=3600);var n={},e=function(t){var e=n[t];if(e){var r=Date.now();if(e.inserted+1e3*e.maxAge>r)return e.value;delete n[t]}};return{get:e,set:function(e,r,u){n[e]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==e(t)}}}(1800),a=function(e,r,a,i){try{return void 0===i&&(i=c.refreshToken),Promise.resolve(function(e){try{return s.has(e)||s.set(e,function(e){try{return Promise.resolve(t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:n({refresh_token:e,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(e)),Promise.resolve(s.get(e))}catch(t){return Promise.reject(t)}}(i)).then(function(n){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===e&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(t(u,{method:e,headers:{"Content-Type":"application/json",Authorization:"Bearer "+n},body:a&&"GET"!==e?JSON.stringify(a):null})).then(function(t){return function(n,e){try{var r=Promise.resolve(t.json())}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(n){if(200!==t.status)throw new Error(JSON.stringify(n))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,n,e){return a("GET",t,n,e)},post:function(t,n,e){return a("POST",t,n,e)},put:function(t,n,e){return a("PUT",t,n,e)}}}(r),o=u.get,c=u.post,s=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,n,e){return c("/adAccounts/"+t+"/campaigns",n,e)},updateCampaign:function(t,n,e,r){return s("/adAccounts/"+t+"/campaigns/"+n,e,r)},updateCampaignStatus:function(t,n,e,r){return s("/adAccounts/"+t+"/campaigns/"+n+"/status/"+e,null,r)},getCampaign:function(t,n,e,r){return o("/adAccounts/"+t+"/campaigns/"+n,e,r)},getCampaignsByAdAccount:function(t,n){return o("/adAccounts/"+t+"/campaigns",null,n)},createAd:function(t,n,e){return c("/adAccounts/"+t+"/ads",n,e)},updateAd:function(t,n,e,r){return s("/adAccounts/"+t+"/ads/"+n,e,r)},getAd:function(t,n,e,r){return o("/adAccounts/"+t+"/ads/"+n,e,r)},getAds:function(t,n){return c("/ads",t,n)},getAdsByAdAccount:function(t,n){return o("/adAccounts/"+t+"/ads",null,n)},createAdvertiser:function(t,n,e){return c("/adAccounts/"+t+"/advertisers",n,e)},getAdvertisersByAdAccount:function(t,n){return o("/adAccounts/"+t+"/advertisers",null,n)},getImageUploadUrl:function(t,n,e){return c("/adAccounts/"+t+"/assets/image",n,e)},getImageAssets:function(t,n,e){return o("/adAccounts/"+t+"/assets/image",n,e)},getVideoAssets:function(t,n,e){return o("/adAccounts/"+t+"/assets/video",n,e)},getVideoUploadUrl:function(t,n,e){return c("/adAccounts/"+t+"/assets/video",n,e)},getAudioAssets:function(t,n,e){return o("/adAccounts/"+t+"/assets/audio",n,e)},getAudioUploadUrl:function(t,n,e){return c("/adAccounts/"+t+"/assets/fullmix",n,e)},getAdSets:function(t,n){return c("/adSets",t,n)},updateAdSetStatus:function(t,n,e,r){return s("/adAccounts/"+t+"/adSets/"+n+"/status/"+e,null,r)},updateAdSet:function(t,n,e,r){return s("/adAccounts/"+t+"/adSets/"+n,e,r)},createAdSet:function(t,n,e,r){return c("/adAccounts/"+t+"/campaigns/"+n+"/adSets",e,r)},createReport:function(t,n){return c("/report",t,n)},getGeoTargets:function(t){return o("/targets/geos",t)}}} | ||
import t from"node-fetch";import{stringify as e}from"querystring";var n=["clientId","clientSecret"];export default function(r){void 0===r&&(r={});var u=function(r){var u=r.clientId,o=r.clientSecret,c=function(t,e){if(null==t)return{};var n,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(u[n]=t[n]);return u}(r,n),s=function(t){void 0===t&&(t=3600);var e={},n=function(t){var n=e[t];if(n){var r=Date.now();if(n.inserted+1e3*n.maxAge>r)return n.value;delete e[t]}};return{get:n,set:function(n,r,u){e[n]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==n(t)}}}(1800),a=function(n,r,a,i){try{return void 0===i&&(i=c.refreshToken),Promise.resolve(function(n){try{return s.has(n)||s.set(n,function(n){try{return Promise.resolve(t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:e({refresh_token:n,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(n)),Promise.resolve(s.get(n))}catch(t){return Promise.reject(t)}}(i)).then(function(e){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===n&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(t(u,{method:n,headers:{"Content-Type":"application/json",Authorization:"Bearer "+e},body:a&&"GET"!==n?JSON.stringify(a):null})).then(function(t){return function(e,n){try{var r=Promise.resolve(t.json())}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(e){if(200!==t.status)throw new Error(JSON.stringify(e))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,e,n){return a("GET",t,e,n)},post:function(t,e,n){return a("POST",t,e,n)},put:function(t,e,n){return a("PUT",t,e,n)}}}(r),o=u.get,c=u.post,s=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,e,n){return c("/adAccounts/"+t+"/campaigns",e,n)},updateCampaign:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e,n,r)},updateCampaignStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e+"/status/"+n,null,r)},getCampaign:function(t,e,n,r){return o("/adAccounts/"+t+"/campaigns/"+e,n,r)},getCampaignsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/campaigns",null,e)},createAd:function(t,e,n){return c("/adAccounts/"+t+"/ads",e,n)},updateAd:function(t,e,n,r){return s("/adAccounts/"+t+"/ads/"+e,n,r)},getAd:function(t,e,n,r){return o("/adAccounts/"+t+"/ads/"+e,n,r)},getAds:function(t,e){return c("/ads",t,e)},getAdsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/ads",null,e)},createAdvertiser:function(t,e,n){return c("/adAccounts/"+t+"/advertisers",e,n)},getAdvertisersByAdAccount:function(t,e){return o("/adAccounts/"+t+"/advertisers",null,e)},getImageUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/image",e,n)},getImageAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/image",e,n)},getVideoAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/video",e,n)},getVideoUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/video",e,n)},getAudioAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/audio",e,n)},getAudioUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/fullmix",e,n)},getAdSets:function(t,e){return c("/adSets",t,e)},updateAdSetStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e+"/status/"+n,null,r)},updateAdSet:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e,n,r)},createAdSet:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e+"/adSets",n,r)},createReport:function(t,e){return c("/report",t,e)},getGeoTargets:function(t){return o("/targets/geos",t)},getGenreTargets:function(t){return o("/targets/genre",t)},getPlaylistTargets:function(t){return o("/targets/playlist",t)},getAudienceEstimate:function(t,e,n){return c("adAccounts/"+t+"/estimate/audience",e,n)}}} | ||
//# sourceMappingURL=spotifyads.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("node-fetch"),require("querystring")):"function"==typeof define&&define.amd?define(["node-fetch","querystring"],e):(t=t||self).spotifyads=e(t.nodeFetch,t.querystring)}(this,function(t,e){t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var n=["clientId","clientSecret"];return function(r){void 0===r&&(r={});var u=function(r){var u=r.clientId,o=r.clientSecret,c=function(t,e){if(null==t)return{};var n,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(u[n]=t[n]);return u}(r,n),s=function(t){void 0===t&&(t=3600);var e={},n=function(t){var n=e[t];if(n){var r=Date.now();if(n.inserted+1e3*n.maxAge>r)return n.value;delete e[t]}};return{get:n,set:function(n,r,u){e[n]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==n(t)}}}(1800),a=function(n,r,a,i){try{return void 0===i&&(i=c.refreshToken),Promise.resolve(function(n){try{return s.has(n)||s.set(n,function(n){try{return Promise.resolve(t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:e.stringify({refresh_token:n,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(n)),Promise.resolve(s.get(n))}catch(t){return Promise.reject(t)}}(i)).then(function(e){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===n&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(t(u,{method:n,headers:{"Content-Type":"application/json",Authorization:"Bearer "+e},body:a&&"GET"!==n?JSON.stringify(a):null})).then(function(t){return function(e,n){try{var r=Promise.resolve(t.json())}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(e){if(200!==t.status)throw new Error(JSON.stringify(e))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,e,n){return a("GET",t,e,n)},post:function(t,e,n){return a("POST",t,e,n)},put:function(t,e,n){return a("PUT",t,e,n)}}}(r),o=u.get,c=u.post,s=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,e,n){return c("/adAccounts/"+t+"/campaigns",e,n)},updateCampaign:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e,n,r)},updateCampaignStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e+"/status/"+n,null,r)},getCampaign:function(t,e,n,r){return o("/adAccounts/"+t+"/campaigns/"+e,n,r)},getCampaignsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/campaigns",null,e)},createAd:function(t,e,n){return c("/adAccounts/"+t+"/ads",e,n)},updateAd:function(t,e,n,r){return s("/adAccounts/"+t+"/ads/"+e,n,r)},getAd:function(t,e,n,r){return o("/adAccounts/"+t+"/ads/"+e,n,r)},getAds:function(t,e){return c("/ads",t,e)},getAdsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/ads",null,e)},createAdvertiser:function(t,e,n){return c("/adAccounts/"+t+"/advertisers",e,n)},getAdvertisersByAdAccount:function(t,e){return o("/adAccounts/"+t+"/advertisers",null,e)},getImageUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/image",e,n)},getImageAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/image",e,n)},getVideoAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/video",e,n)},getVideoUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/video",e,n)},getAudioAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/audio",e,n)},getAudioUploadUrl:function(t,e,n){return c("/adAccounts/"+t+"/assets/fullmix",e,n)},getAdSets:function(t,e){return c("/adSets",t,e)},updateAdSetStatus:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e+"/status/"+n,null,r)},updateAdSet:function(t,e,n,r){return s("/adAccounts/"+t+"/adSets/"+e,n,r)},createAdSet:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e+"/adSets",n,r)},createReport:function(t,e){return c("/report",t,e)},getGeoTargets:function(t){return o("/targets/geos",t)}}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("node-fetch"),require("querystring")):"function"==typeof define&&define.amd?define(["node-fetch","querystring"],e):(t=t||self).spotifyads=e(t.nodeFetch,t.querystring)}(this,function(t,e){t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var n=["clientId","clientSecret"];return function(r){void 0===r&&(r={});var u=function(r){var u=r.clientId,o=r.clientSecret,s=function(t,e){if(null==t)return{};var n,r,u={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(u[n]=t[n]);return u}(r,n),c=function(t){void 0===t&&(t=3600);var e={},n=function(t){var n=e[t];if(n){var r=Date.now();if(n.inserted+1e3*n.maxAge>r)return n.value;delete e[t]}};return{get:n,set:function(n,r,u){e[n]={value:r,maxAge:u||t,inserted:Date.now()}},has:function(t){return void 0!==n(t)}}}(1800),a=function(n,r,a,i){try{return void 0===i&&(i=s.refreshToken),Promise.resolve(function(n){try{return c.has(n)||c.set(n,function(n){try{return Promise.resolve(t("https://accounts.spotify.com/api/token",{method:"POST",headers:{Authorization:"Basic "+Buffer.from(u+":"+o).toString("base64"),"Content-Type":"application/x-www-form-urlencoded"},body:e.stringify({refresh_token:n,grant_type:"refresh_token"})}).then(function(t){return t.json()}).then(function(t){return t.access_token}))}catch(t){return Promise.reject(t)}}(n)),Promise.resolve(c.get(n))}catch(t){return Promise.reject(t)}}(i)).then(function(e){var u="https://api-partner.spotify.com/ads/v1.4"+(r.startsWith("/")?"":"/")+r;return u="GET"===n&&a?u+"?"+new URLSearchParams(a):u,Promise.resolve(t(u,{method:n,headers:{"Content-Type":"application/json",Authorization:"Bearer "+e},body:a&&"GET"!==n?JSON.stringify(a):null})).then(function(t){return function(e,n){try{var r=Promise.resolve(t.json())}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(e){if(200!==t.status)throw new Error(JSON.stringify(e))})})})}catch(t){return Promise.reject(t)}};return{get:function(t,e,n){return a("GET",t,e,n)},post:function(t,e,n){return a("POST",t,e,n)},put:function(t,e,n){return a("PUT",t,e,n)}}}(r),o=u.get,s=u.post,c=u.put;return{listAdAccounts:function(t){return o("/currentUser/adAccounts",null,t)},createCampaign:function(t,e,n){return s("/adAccounts/"+t+"/campaigns",e,n)},updateCampaign:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e,n,r)},updateCampaignStatus:function(t,e,n,r){return c("/adAccounts/"+t+"/campaigns/"+e+"/status/"+n,null,r)},getCampaign:function(t,e,n,r){return o("/adAccounts/"+t+"/campaigns/"+e,n,r)},getCampaignsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/campaigns",null,e)},createAd:function(t,e,n){return s("/adAccounts/"+t+"/ads",e,n)},updateAd:function(t,e,n,r){return c("/adAccounts/"+t+"/ads/"+e,n,r)},getAd:function(t,e,n,r){return o("/adAccounts/"+t+"/ads/"+e,n,r)},getAds:function(t,e){return s("/ads",t,e)},getAdsByAdAccount:function(t,e){return o("/adAccounts/"+t+"/ads",null,e)},createAdvertiser:function(t,e,n){return s("/adAccounts/"+t+"/advertisers",e,n)},getAdvertisersByAdAccount:function(t,e){return o("/adAccounts/"+t+"/advertisers",null,e)},getImageUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/image",e,n)},getImageAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/image",e,n)},getVideoAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/video",e,n)},getVideoUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/video",e,n)},getAudioAssets:function(t,e,n){return o("/adAccounts/"+t+"/assets/audio",e,n)},getAudioUploadUrl:function(t,e,n){return s("/adAccounts/"+t+"/assets/fullmix",e,n)},getAdSets:function(t,e){return s("/adSets",t,e)},updateAdSetStatus:function(t,e,n,r){return c("/adAccounts/"+t+"/adSets/"+e+"/status/"+n,null,r)},updateAdSet:function(t,e,n,r){return c("/adAccounts/"+t+"/adSets/"+e,n,r)},createAdSet:function(t,e,n,r){return s("/adAccounts/"+t+"/campaigns/"+e+"/adSets",n,r)},createReport:function(t,e){return s("/report",t,e)},getGeoTargets:function(t){return o("/targets/geos",t)},getGenreTargets:function(t){return o("/targets/genre",t)},getPlaylistTargets:function(t){return o("/targets/playlist",t)},getAudienceEstimate:function(t,e,n){return s("adAccounts/"+t+"/estimate/audience",e,n)}}}}); | ||
//# sourceMappingURL=spotifyads.umd.js.map |
{ | ||
"name": "@honkandgo/spotifyads", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -114,3 +114,19 @@ import { makeApi } from './api' | ||
// Genre targets | ||
const getGenreTargets = (params) => { | ||
return get('/targets/genre', params) | ||
} | ||
// Playlist targets | ||
const getPlaylistTargets = (params) => { | ||
return get('/targets/playlist', params) | ||
} | ||
// Audience estimate | ||
const getAudienceEstimate = (adAccountId, params, refreshToken) => { | ||
return post(`adAccounts/${adAccountId}/estimate/audience`, params, refreshToken) | ||
} | ||
return { | ||
@@ -141,4 +157,7 @@ listAdAccounts, | ||
createReport, | ||
getGeoTargets | ||
getGeoTargets, | ||
getGenreTargets, | ||
getPlaylistTargets, | ||
getAudienceEstimate | ||
} | ||
} |
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
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
73403
273