# Path: apps/api_bridge.py
# def getarrivals(request, result_count=3):
# def getparking():


import logging
import webapp2
import config
from google.appengine.api import mail
from google.appengine.api.taskqueue import Task
from apps import api_bridge



class EmailRequestHandler(webapp2.RequestHandler):
    def post(self):

      inbound_message = mail.InboundEmailMessage(self.request.body)
      logging.info("Email request! Sent from %s with message subject %s" % (inbound_message.sender,inbound_message.subject))

      body = inbound_message.subject
      logging.debug("email body arguments %s" % body)

      # ignore anything sent by ourselves to avoid an infinite loop
      if inbound_message.sender == config.EMAIL_SENDER_ADDRESS:
        self.response.set_status(200)
        return

      if body.lower().find('parking') > -1:
          logging.info('parking request via email')
          response = api_bridge.getparking()
      else:
          ## magic ##

# Path: apps/api_bridge.py
# def getarrivals(request, result_count=3):
# def getparking():


# Path: apps/electric_mail.py
import logging
import webapp2
import config
from google.appengine.api import mail
from google.appengine.api.taskqueue import Task
from apps import api_bridge




class EmailRequestHandler(webapp2.RequestHandler):
    def post(self):

      inbound_message = mail.InboundEmailMessage(self.request.body)
      logging.info("Email request! Sent from %s with message subject %s" % (inbound_message.sender,inbound_message.subject))

      body = inbound_message.subject
      logging.debug("email body arguments %s" % body)

      # ignore anything sent by ourselves to avoid an infinite loop
      if inbound_message.sender == config.EMAIL_SENDER_ADDRESS:
        self.response.set_status(200)
        return

      if body.lower().find('parking') > -1:
          logging.info('parking request via email')
          response = api_bridge.getparking()
      else:
          ## magic ##

          response = api_bridge.getarrivals(body,10)