def create(gandi):
    """ Create a new contact.
    """
    contact = {}

    for field, label, checks in FIELDS:
        ask_field(gandi, contact, field, label, checks)

    default_pwd = randomstring(16)
    contact['password'] = click.prompt('Please enter your password',
                                       hide_input=True,
                                       confirmation_prompt=True,
                                       default=default_pwd)

    result = True
    while result:
        result = gandi.contact.create_dry_run(contact)

        # display errors
        for err in result:
            gandi.echo(err['reason'])
            field = err['field']

            if field not in FIELDS_POSITION:
                return

            desc = FIELDS[FIELDS_POSITION.get(field)]
            ask_field(gandi, contact, *desc)

    result = gandi.contact.create(contact)
    handle = result['handle']

    gandi.echo('Please activate you public api access from gandi website, and '
               'get the apikey.')
    gandi.echo('Your handle is %s, and the password is the one you defined.' %
               handle)

    # open new browser window
    webbrowser.open('https://www.gandi.net/admin/api_key')
    # just to avoid missing the next question in webbrowser stderr
    time.sleep(1)

    # get the apikey from shell
    apikey = None
    while not apikey:
        apikey = click.prompt('What is your production apikey')

    caller = gandi.get('api.key')
    # save apikey in the conf if none defined else display an help on how to
    # use it
    if caller:
        gandi.echo('You already have an apikey defined, if you want to use the'
                   ' newly created contact, use the env var : ')
        gandi.echo('export API_KEY=%s' % apikey)
    else:
        gandi.echo('Will save your apikey into the config file.')
        gandi.configure(True, 'api.key', apikey)

    return handle
Create a new contact.