         fetcher.new()
             .use(retrieveTokens)
             .use(logIn)
-            .use(retrieveListContact)
+            .use(retrieveContactList)
             .use(prepareCozyContacts)
-            .use(retrieveContacts)
+            .use(saveContacts)
             .args(requiredFields, {}, {})
             .fetch (err, fields, entries) ->
                 return callback err if err

            $ = cheerio.load body
            entries.csrfToken = $('#loginCsrfParam-login').val()
            entries.accountName = requiredFields.login
            log.info 'Tokens retrieved'
            next()


# Make the login request with the user inputs (login/password) and the csrf
# token retrieved above.
logIn = (requiredFields, entries, data, next) ->
    log.info 'Attempt login'
    opts =
        url: 'https://www.linkedin.com/uas/login-submit'
        jar: true

            loginCsrfParam: entries.csrfToken
            submit: "Sign+in"

    log.info 'Signing in...'
    request.post opts, (err, res, body) ->
        return next err if err

        if body is ""
            log.info 'Login succeeded!'
            next()
        else
            log.error 'Wrong login or password.'
            next new Error("Wrong login or password.")


# Retrieve a list of all Linkedin ID contacts available. The linkedin ID will
# be used to retrieve additional data about the contact.
retrieveContactList = (requiredFields, entries, data, next) ->
    log.info 'Retrieve list contact'

    contactsUrl = "https://www.linkedin.com/contacts/api/contacts/"
    contactsUrl += "?start=0&count=10000&fields=id"
    opts =
        url: contactsUrl
        jar: true
        json: true

    log.info 'Retrieve contact list...'
    request.get opts, (err, res, body) ->
        return next err if err

        if body.status? and body.status is 'error'
            next new Error body.status_details
        else
            entries.listContacts = body.contacts
            if not entries.listContacts?
                next new Error "Error retrieving contacts from request"
            else
                log.info 'Contact list retrieved.'
                next()


# Load all Cozy contacts, then perform several operations:
#
# * Keep only contacts linked to the current LinkedinAccount
# * Order them in a map where the LinkedIn account ID is the key
# * Order them in a map where the contact full name is the key.
#
# That way we will be able to check if the contact should be updated (because
# it already exists) or if it should be created.
#
prepareCozyContacts = (requiredFields, entries, data, next) ->

    log.info 'Load Cozy contacts...'
    Contact.all (err, contacts) ->
        return next err if err

