"""
Twitter platform for notify component.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/notify.twitter/
"""
import logging

from homeassistant.components.notify import DOMAIN, BaseNotificationService
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.helpers import validate_config

_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['TwitterAPI==2.4.2']

CONF_CONSUMER_KEY = "consumer_key"
CONF_CONSUMER_SECRET = "consumer_secret"
CONF_ACCESS_TOKEN_SECRET = "access_token_secret"


def get_service(hass, config):
    """Get the Twitter notification service."""
    if not validate_config({DOMAIN: config},
                           {DOMAIN: [CONF_CONSUMER_KEY, CONF_CONSUMER_SECRET,
                                     CONF_ACCESS_TOKEN,
                                     CONF_ACCESS_TOKEN_SECRET]},
                           _LOGGER):
        return None

    return TwitterNotificationService(config[CONF_CONSUMER_KEY],
                                      config[CONF_CONSUMER_SECRET],
                                      config[CONF_ACCESS_TOKEN],
                                      config[CONF_ACCESS_TOKEN_SECRET])


# pylint: disable=too-few-public-methods
class TwitterNotificationService(BaseNotificationService):
    """Implement notification service for the Twitter service."""

    def __init__(self, consumer_key, consumer_secret, access_token_key,
                 access_token_secret):
        """Initialize the service."""
        from TwitterAPI import TwitterAPI
        self.api = TwitterAPI(consumer_key, consumer_secret, access_token_key,
                              access_token_secret)

    def send_message(self, message="", **kwargs):
        """Tweet some message."""
        resp = self.api.request('statuses/update', {'status': message})
        if resp.status_code != 200:
            import json
            obj = json.loads(resp.text)
            error_message = obj['errors'][0]['message']
            error_code = obj['errors'][0]['code']
            _LOGGER.error("Error %s : %s (Code %s)", resp.status_code,
                          error_message,
                          error_code)

@@ -189,59 +189,193 @@
 ng%0A%0A
-from homeassistant.components.notify import DOMAIN,
+import voluptuous as vol%0A%0Aimport homeassistant.helpers.config_validation as cv%0Afrom homeassistant.components.notify import (PLATFORM_SCHEMA,%0A                                            
  Bas
@@ -394,16 +394,17 @@
 nService
+)
 %0Afrom ho
@@ -449,58 +449,8 @@
 OKEN
-%0Afrom homeassistant.helpers import validate_config
 %0A%0A_L
@@ -653,389 +653,336 @@
 t%22%0A%0A
-%0Adef get_service(hass, config):%0A    %22%22%22Get the Twitter notification service.%22%22%22%0A    if not validate_config(%7BDOMAIN: config%7D,%0A                           %7BDOMAIN: %5BCONF_CONSUMER_KEY, CONF_CONSUMER_SECRET,%0A                                     CONF_ACCESS_TOKEN,%0A                                     CONF_ACCESS_TOKEN_SECRET%5D%7D,%0A                           _LOGGER):%0A        return None%0A
+PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(%7B%0A    vol.Required(CONF_CONSUMER_KEY): cv.string,%0A    vol.Required(CONF_CONSUMER_SECRET): cv.string,%0A    vol.Required(CONF_ACCESS_TOKEN): cv.string,%0A    vol.Required(CONF_ACCESS_TOKEN_SECRET): cv.string,%0A%7D)%0A%0A%0Adef get_service(hass, config):%0A    %22%22%22Get the Twitter notification service.%22%22%22
 %0A   

Use voluptuous for twitter (#3126)