Skip to content

Instantly share code, notes, and snippets.

@lele85
Created September 1, 2015 12:13
Show Gist options
  • Select an option

  • Save lele85/f0c5f5c0bc88489b057b to your computer and use it in GitHub Desktop.

Select an option

Save lele85/f0c5f5c0bc88489b057b to your computer and use it in GitHub Desktop.
import _ from "underscore";
const baseConfigData = {
"shows": [
{
"show_id": 200,
"title": "Elevate Your Energy 2",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/elevate_your_energy",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/3f6575306aabb45f8301c8093d58c518.jpg"
},
{
"show_id": 1,
"title": "la bamba #2",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/la-bamba",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/2cfb88bf52b05b84b5f6543841e91f58.jpg"
},
{
"show_id": 64,
"title": "la bambo",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/la-bambo",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/9b043842c596d3ec5fd03280bd48c7ef.jpg"
},
{
"show_id": 236,
"title": "New One",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/new-one",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/dab8defff5801fd4dd6dfb0bd0bbb15a.jpg"
},
{
"show_id": 323,
"title": "One Direction - Up all night",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/one-direction-up-all-night",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/81f24041f5f1947416b68c8612cd3c47.jpg"
},
{
"show_id": 220,
"title": "Rock me up",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/new-test",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/3a7ddbae965256690dbae79026f8f832.jpg"
},
{
"show_id": 296,
"title": "Testa",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/testa_6",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/95b97f1b722ccdc5a949600e41407f36.jpg"
}
],
"autoshares": [
{
"service": "FACEBOOK",
"label": "Facebook",
"enabled": true
},
{
"service": "TWITTER",
"label": "Twitter",
"enabled": false
},
{
"service": "SOUNDCLOUD",
"label": "SoundCloud",
"enabled": false
},
{
"service": "TUMBLR",
"label": "Tumblr",
"enabled": false
},
{
"service": "YOUTUBE",
"label": "YouTube",
"enabled": false
}
],
"nonstop_streams": [
{
"episode_id": 1701,
"show_id": 220,
"user_id": 1,
"stream_id": "YRTAS1",
"title": "Nicecast",
"description": "Nicecast description",
"explicit": true,
"autoshares": ["TWITTER", "TUMBLR"],
"show": {
"show_id": 220,
"title": "Rock me up",
"site_url": "https:\/\/www.spreaker-beta.com\/show\/new-test",
"image_original_url": "https:\/\/d1botjg6upurv.cloudfront.net\/images.spreaker-beta.com\/original\/3a7ddbae965256690dbae79026f8f832.jpg"
}
}
]
};
export default function buildResponse() {
let configData = _(baseConfigData).deepClone();
let builder = {
end() {
return { response: { config: configData } };
},
enableAutoshare(name) {
configData.autoshares.find((share) => { return share.service === name; }).enabled = true;
return this;
},
disableAutoshare(name) {
configData.autoshares.find((share) => { return share.service === name; }).enabled = false;
return this;
},
enableAllAutoshare() {
["FACEBOOK", "TWITTER", "SOUNDCLOUD", "TUMBLR", "YOUTUBE"].forEach(this.enableAutoshare);
return this;
},
disableAllAutoshare() {
["FACEBOOK", "TWITTER", "SOUNDCLOUD", "TUMBLR", "YOUTUBE"].forEach(this.disableAutoshare);
return this;
},
disableAllAutoshareBut(name){
this.disableAllAutoshare();
this.enableAutoshare(name);
return this;
},
enableAllAutoshareBut(name){
this.enableAllAutoshare();
this.disableAutoshare(name);
return this;
}
};
return builder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment