Skip to content

A note export API for Scala and JS based on the Evernote SDK.

License

Notifications You must be signed in to change notification settings

aksiksi/everexport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EverExport

Build Status

A note export API written in Scala based on the Evernote SDK. Compiles to both the JVM and JS (via Scala.js) backends. Currently supports both 2.11.x and 2.12.x.

Install

Scala

In your build.sbt:

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
libraryDependencies += "me.assil" %% "everexport" % "0.3-SNAPSHOT"

NPM

npm install everexport

Examples

On the JVM (Scala):

import me.assil.everexport.{EverExport, Note, Notebook}

import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.util.Try

// Global EC for executing Futures
import scala.concurrent.ExecutionContext.Implicits.global

object QuickStart extends App {
  // https://dev.evernote.com/doc/articles/dev_tokens.php
  val token: String = ???
  val exporter = new EverExport(token, sandbox = true)

  // Get all notebooks in user's account
  val notebooksFuture: Future[Vector[Notebook]] = exporter.listNotebooks

  // Return all note titles for the *first* notebook
  val noteTitlesFuture: Future[Vector[String]] =
    for (
      notebooks <- notebooksFuture;
      titles <- exporter.getNoteTitles(notebooks(0).guid)
    ) yield titles

  // Export all notes from *second* notebook (assuming it exists!)
  val notesFuture: Future[Vector[Try[Note]]] =
    for (
      notebooks <- notebooksFuture;
      notes <- exporter.exportNotebook(notebooks(1).guid)
    ) yield notes

  // Wait 5 seconds for last Future to complete
  val notes = Await.result(notesFuture, 5.seconds)
  
  // Display notes exported from second notebook
  println(notes)
}

In JS:

const everexport = require('everexport')

const token = process.env.EVERNOTE_TOKEN // Same token as above
const exporter = new everexport.EverExport(token, true)

// Fetch all notebooks in user's account
exporter.listNotebooks()
// Then fetch all notes in *first* notebook
.then(notebooks => {
    const n = notebooks[0]
    return exporter.exportNotebook(n.guid)
})
// Then display each note's title and creation time
.then(notes => {
    notes.forEach(note => {
        console.log('Title: ' + note.title + ', Created on: ' + note.created)
    });
})

Build

First, make sure you have sbt 1.x installed.

Scala

Run sbt everexportJVM/package. JAR in jvm/target/scala-2.12.

JS

Run sbt everexportJS/fullOptJS. Optimized JS in js/target/scala-2.12/scalajs-bundler/main.