const fetch = require("node-fetch")




class LocalClient {

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

    getToken() {
        return fetch(this.localhost + '/key', {
            method: 'GET',
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    saveChtodayNews(data) {
        return fetch(this.localhost + '/article', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    saveYoutubeVideo(data) {
        return fetch(this.localhost + '/youtube', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    saveYoutubeVideoCuration(data) {
        return fetch(this.localhost + '/youtube/curation', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.text())
    }

    deleteYoutubeVideoCuration(data) {
        return fetch(this.localhost + '/youtube/delete', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.text())
    }

    getYoutubeVideo(data) {
        return fetch(this.localhost + '/youtube/video', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    savePodbbangStation(data) {
        return fetch(this.localhost + '/pod/station', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    saveNaverPlace(data) {
        return fetch(this.localhost + '/place/save', {
            method: 'POST',
            body: JSON.stringify(data),
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }

    getChannel() {
        return fetch(this.localhost + '/youtube/channel', {
            method: 'GET',
            headers: {
                'content-type': 'application/json'
            }
        }).then(res => res.json())
    }
}


module.exports = new LocalClient;