from flask import Flask
from flask_restful import Resource, Api


# import json
from facebook import facebook_json
from instagram import instagram_json
from twitter import twitter_json
import requests_cache
import os
# from youtube import youtube_json
# import pdb


app = Flask(__name__)
api = Api(app)
requests_cache.install_cache('request_cache', backend='sqlite', expire_after=1800)

# rename the class to whatever you want. Used DJ Khaled as an example


class Khaled(Resource):
    fb_id = os.environ['KHALED_FB_ID']  # use your own facebook ID
    instagram_id = os.environ['KHALED_INSTA_ID']  # use your Instagram ID

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        # instagram = instagram_json(user_id=self.instagram_id)
        twitter = twitter_json(screen_name='djkhaled')

        return {'facebook': facebook, 'twitter': twitter}


class Khalifa(Resource):

    fb_id = os.environ['KHALIFA_FB_ID']
    instagram = os.environ['KHALIFA_INSTA_ID']

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        # instagram = instagram_json(user_id=self.instagram_id)
        twitter = twitter_json(screen_name='wizkhalifa')

        return {'facebook': facebook, 'twitter': twitter}


class JuicyJ(Resource):

    fb_id = os.environ['JUICYJ_FB_ID']
    instagram = os.environ['JUICYJ_INSTA_ID']

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        twitter = twitter_json(screen_name='therealjuicyj')

        return {'facebook': facebook, 'twitter': twitter}


class TyDollaSign(Resource):

    fb_id = os.environ['TYDOLLASIGN_FB_ID']
    instagram = os.environ['TYDOLLASIGN_INSTA_ID']

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        twitter = twitter_json(screen_name='tydollarsign')

        return {'facebook': facebook, 'twitter': twitter}


class ChevyWoods(Resource):

    fb_id = os.environ['CHEVYWOODS_FB_ID']
    instagram = os.environ['CHEVYWOODS_INSTA_ID']

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        twitter = twitter_json(screen_name='chevywoods')

        return {'facebook': facebook, 'twitter': twitter}


class Berner(Resource):

    fb_id = os.environ['BERNER_FB_ID']
    instagram = os.environ['BERNER_INSTA_ID']

    def get(self):
        facebook = facebook_json(user_id=self.fb_id)
        twitter = twitter_json(screen_name='berner415')

        return {'facebook': facebook, 'twitter': twitter}


# class CourtneyNoelle(Resource):

#     # fb_id =
#     instagram = os.environ['COURNTEY_INSTA_ID']

#     def get(self):
#         facebook = facebook_json(user_id=self.fb_id)
#         twitter = twitter_json(screen_name='berner415')

#         return {'facebook': facebook, 'twitter': twitter}


class Sledgren(Resource):

    # fb_id =
    instagram = os.environ['SLEDGREN_INSTA_ID']

    def get(self):

        twitter = twitter_json(screen_name='ImSledgren')

        return {'twitter': twitter}


class TukiCarter(Resource):

    instagram = os.environ['TUKI_INSTA_ID']

    def get(self):

        twitter = twitter_json(screen_name='tukicarter')

        return {'twitter': twitter}


class JRDonato(Resource):

    fb_id = os.environ['JR_FB_ID']
    instagram = os.environ['JR_INSTA_ID']

    def get(self):

        facebook = facebook_json(user_id=self.fb_id)
        twitter = twitter_json(screen_name='RealJRDonato')

        return {'facebook': facebook, 'twitter': twitter}


API_ENDPOINT = '/social_media/'

api.add_resource(Khaled, API_ENDPOINT + 'khaled')
api.add_resource(Khalifa, API_ENDPOINT + 'khalifa')
api.add_resource(JuicyJ, API_ENDPOINT + 'juicyj')
api.add_resource(TyDollaSign, API_ENDPOINT + 'tydollarsign')
api.add_resource(ChevyWoods, API_ENDPOINT + 'chevywoods')
api.add_resource(Berner, API_ENDPOINT + 'berner')
api.add_resource(Sledgren, API_ENDPOINT + 'sledgren')
api.add_resource(TukiCarter, API_ENDPOINT + 'tukicarter')
api.add_resource(JRDonato, API_ENDPOINT + 'jrdonato')



