Learn the real value of your data

Who are we?

Christophe Thiriot (Maintainer of some applications)

@doubleface on twitter and github


Romain Foucault (Cozy Cloud employee)

@aenario on twitter and github

What is Cozy?

sorry if you were here this morning

 

  • https://cozy.io
  • open source personnal cloud
  • some preinstalled applications (degoogling)
  • You can install more applications
  • You can make more applications
  • Beta

Step 1 : get my data back

There is an app for that : my accounts

With login and passwords, gets a lot of your data back

Every data has its own connector

The connector to your data is missing ?

You can do something!

the My Accounts app handles storage / sync

trainline.js


module.exports = baseKonnector.createNew({
  name: 'Trainline',
  vendorLink: 'www.trainline.fr',
  fields: {
    login: 'email',
    password: 'password',
    folderPath: 'folder',
  },
  models: [Bill]
}
                    

Your "target" offers you an API ? your really lucky!

If no API, let's do scraping

Using "request-promise" "cheerio" npm modules


request({ method: 'GET', jar: true, url: "https://login.uber.com/login"})
.then((res, body) => {
    const $ = cheerio.load(body)
    const token = $('input[name=_csrf_token]').val()

    log.info('Logging in')

    return request({method: 'POST', jar: true,
        url: "https://login.uber.com/login",
        form: {
          email: requiredFields.login,
          password: requiredFields.password,
          _csrf_token: token
        }})
.then((result, body) => {
   log.info('Login succeeded')
})
                    

Step 2 : Use my data

You can create your own cozy application

A cozy application is just a simple static javascript application using the cozy client sdk and with a special package.json file in a github repository

Example :

index.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>TODO</title>
        <script src="cozy-client.js"></script>
        <script src="app.js"></script>
    </head>
    <body>
      <button id="create_special">
        Create Task for last bill
      </button>
      <ul id="todo" class="list-group"></ul>
    </body>
</html>

package.json

{
  "name": "todo",
  "version": "0.0.1",
  "description": "Next tasks to do in your cozy",
  "cozy-type": "static",
  "cozy-displayName": "todo",
  "cozy-permissions": {
    "TodoDemo": {
      "description": "Todo demo items"
    },
    "File": {
      "description": "Find bills in your file"
    }
  }
}

app.js (1/3)

function displayTodos() {
  cozy.defineIndex("tododemo", ["completed"])
  .then((index) => cozy.query(index, {
    selector: {"completed": false},
  }))
  .then(list => {
    todo.innerHTML = list.map(item => {
      return `
  • ${item.description}
  • `; }).join(""); }); }

    app.js (2/3)

    function getLastBill() {
      cozy.defineIndex('file', ["class", "lastModified"])
      .then((index) => cozy.query(index, {
        selector: {"class": "document"},
        sort: "lastModified",
        descending true
        limit: 1,
      }))
      .then(list => list[0])
      .then(file => {
        if (file === undefined) {
            window.alert("no document found");
        }
      }
      

    app.js (3/3)

    getLastBill()
    .then( (file) => {
      let url = `/apps/files/files/${file._id}/attach/${file.name}`;
      cozy.create("tododemo", {
        description: `Pay bill `,
      })
    })
    .then(displayTodos);
    
    

    Conclusion : Profit Share

    Connector : Make a PR to the konnectors repository.

    Talk with us about your new connector on the forum : https://forum.cozy.io

    Application : Create your repository, Install it in cozy.