const fetch = require("node-fetch")

class YoutubeClient {

    constructor() {
        this.host = 'http://localhost:20116'
    }

    getChannel(body) {
        return fetch(this.host + '/v1/search.channel', {
            method: 'POST',
            body: JSON.stringify(body),
            headers: { 'Content-Type': 'application/json' }
        }).then(res => res.json())
    }

    getPlaylistItem(id, body) {
        return fetch(this.host + '/v1/search.playlist/' + id, {
            method: 'POST',
            body: JSON.stringify(body),
            headers: { 'Content-Type': 'application/json' }
        }).then(res => res.json())
    }

    getRecentVideo(body) {
        this.channels
        return fetch(this.host + '/v1/search.video', {
            method: 'POST',
            body: JSON.stringify(body),
            headers: { 'Content-Type': 'application/json' }
        }).then(res => res.json())
    }

    getVideo(id, body) {
        this.channels
        return fetch(this.host + '/v1/search.video/' + id, {
            method: 'POST',
            body: JSON.stringify(body),
            headers: { 'Content-Type': 'application/json' }
        }).then(res => res.json())
    }
}


module.exports = new YoutubeClient;