Sha256: d1e37920f4751eb30b31327a5eaf07d6a3a8ebeae7e029f60304affb64a317c7

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'evernote-thrift'
require 'yinx/note_store'

module Yinx
  class UserStore

    attr_reader :userStore

    SANDBOX = "sandbox.evernote.com"
    #REAL = "www.evernote.com"
    REAL = "app.yinxiang.com"

    TOKEN = "#{ENV['HOME']}/.yinx"

    def initialize real_env = true
      @real = real_env
      userStoreUrl = "https://#{host}/edam/user"
      userStoreTransport = Thrift::HTTPClientTransport.new(userStoreUrl)
      userStoreProtocol = Thrift::BinaryProtocol.new(userStoreTransport)
      @userStore = Evernote::EDAM::UserStore::UserStore::Client.new(userStoreProtocol)
    end

    def host
      @real ? REAL : SANDBOX
    end

    def checkVersion
      userStore.checkVersion("Evernote EDAMTest (Ruby)",
                             Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR,
                             Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
    end

    def note_store authToken = default_token
      NoteStore.new userStore, authToken
    end

    def default_token
      File.exist?(TOKEN) ? File.read(TOKEN).chomp : nil
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yinx-0.1.1 lib/yinx/user_store.rb
yinx-0.1.0 lib/yinx/user_store.rb