# Buggy code
def send_sms(profile, body, to, from_):
    """
    Send an sms

    CLI Example:

        twilio.send_sms twilio-account 'Test sms' '+18019999999' '+18011111111'
    """
    ret = {}
    ret["message"] = {}
    ret["message"]["sid"] = None
    client = _get_twilio(profile)
    try:
        if TWILIO_5:
            message = client.sms.messages.create(body=body, to=to, from_=from_)
        else:
            message = client.messages.create(body=body, to=to, from_=from_)
    except TwilioRestException as exc:
        ret["_error"] = {}
        ret["_error"]["code"] = exc.code
        ret["_error"]["msg"] = exc.msg
        ret["_error"]["status"] = exc.status
        log.debug("Could not send sms. Error: %s", ret)
        return ret
    ret["message"] = {}
    ret["message"]["sid"] = message.sid
    ret["message"]["price"] = message.price
    ret["message"]["price_unit"] = message.price_unit
    ret["message"]["status"] = message.status
    ret["message"]["num_segments"] = message.num_segments
    ret["message"]["body"] = message.body
    ret["message"]["date_sent"] = six.text_type(message.date_sent)
    ret["message"]["date_created"] = six.text_type(message.date_created)
    log.info(ret)
    return ret


# Traceback (AttributeError)
# salt \* twilio.send_sms twilio_profile "Test message" '<to-phone-number>' '<from-phone-number>'
ubuntu-salt-test:
The minion function caused an exception: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1664, in _thread_return
return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/twilio_notify.py", line 81, in send_sms
client = _get_twilio(profile)
File "/usr/lib/python2.7/dist-packages/salt/modules/twilio_notify.py", line 63, in _get_twilio
creds.get('twilio.account_sid'),
AttributeError: 'unicode' object has no attribute 'get'

# Fixed code
def send_sms(profile, body, to, from_):
    """
    Send an sms

    CLI Example:

        twilio.send_sms my-twilio-account 'Test sms' '+18019999999' '+18011111111'
    """
    ret = {}
    ret["message"] = {}
    ret["message"]["sid"] = None
    client = _get_twilio(profile)
    try:
        if TWILIO_5:
            message = client.sms.messages.create(body=body, to=to, from_=from_)
        else:
            message = client.messages.create(body=body, to=to, from_=from_)
    except TwilioRestException as exc:
        ret["_error"] = {}
        ret["_error"]["code"] = exc.code
        ret["_error"]["msg"] = exc.msg
        ret["_error"]["status"] = exc.status
        log.debug("Could not send sms. Error: %s", ret)
        return ret
    ret["message"] = {}
    ret["message"]["sid"] = message.sid
    ret["message"]["price"] = message.price
    ret["message"]["price_unit"] = message.price_unit
    ret["message"]["status"] = message.status
    ret["message"]["num_segments"] = message.num_segments
    ret["message"]["body"] = message.body
    ret["message"]["date_sent"] = six.text_type(message.date_sent)
    ret["message"]["date_created"] = six.text_type(message.date_created)
    log.info(ret)
    return ret