from google.appengine.ext.ndb import BooleanProperty, DateProperty, DateTimeProperty, IntegerProperty, StringProperty, TextProperty
from google.appengine.ext.ndb.polymodel import PolyModel


class Intent(PolyModel):

	expires = DateTimeProperty()
	nonce = StringProperty()


class Login(PolyModel):

	created = DateTimeProperty(auto_now_add = True)
	user_id = IntegerProperty(default = 0)


class Session(Model):

	created = DateTimeProperty(auto_now_add = True)
	login_id = IntegerProperty(default = 0)
	user_id = IntegerProperty(default = 0)


class EmailLogin(Login):

	email = StringProperty()
	password = StringProperty()
	salt = StringProperty()
	username = StringProperty()


class FacebookLogin(Login):

	birthday = DateProperty()
	email = StringProperty()
	gender = StringProperty()
	id = StringProperty()
	name = StringProperty()
	oauth_access_token = TextProperty()
	picture = TextProperty()


class GoogleLogin(Login):

	display_name = StringProperty()
	emails = StringProperty(repeated = True)
	gender = StringProperty()
	id = StringProperty()
	image_url = StringProperty()
	oauth_access_token = TextProperty()
	oauth_refresh_token = TextProperty()


class LiveLogin(Login):

	email = StringProperty()
	id = StringProperty()
	name = StringProperty()
	oauth_access_token = TextProperty()
	picture = TextProperty()
	refresh_token = TextProperty()


class LoginEvent(Event):

	country = StringProperty()
	ip = StringProperty()
	login_id = IntegerProperty(default = 0)
	success = BooleanProperty()
	user_agent = TextProperty()
	user_id = IntegerProperty(default = 0)


class RegistrationIntent(Intent):

	email = StringProperty()
	password = StringProperty()
	salt = StringProperty()
	username = StringProperty()


class TwitterLogin(Login):

	bio = TextProperty()
	id = StringProperty()
	name = StringProperty()
	oauth_access_token = TextProperty()
	profile_image_url = StringProperty()
	screen_name = TextProperty()


class YahooLogin(Login):

	emails = StringProperty(repeated = True)
	guid = StringProperty()
	image_url = StringProperty()
	name = StringProperty()
	oauth_access_token = TextProperty()
	oauth_access_token_secret = TextProperty()
	oauth_session_handle = TextProperty()


class YouTubeLogin(Login):

	id = StringProperty()
	oauth_access_token = TextProperty()
	oauth_refresh_token = TextProperty()
	title = StringProperty()
	thumbnail = StringProperty()
