Sha256: 09bc507ac05535806f4216ce50443dba709880ca1c7836517257626d821d0899

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'evernote-thrift'
require 'yinx/helper'
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
      return ENV['YINX'] if ENV['YINX']
      File.exist?(TOKEN) ? File.read(TOKEN).chomp : nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yinx-0.1.7 lib/yinx/user_store.rb