如何调用 evernote struct 对象来报告笔记本中的所有笔记?
How do I call the evernote struct object to report all notes inside a notebook?
我正在使用 ruby evernote-thrift API 和沙箱。
我在解释文档时遇到了一些问题;我正在尝试从特定笔记本中的所有笔记中检索主题行。
获取我调用的笔记本名称
notebooks = noteStore.listNotebooks(authToken)
然后 运行 .each
notebooks
。根据文档,有一个名为 noteList
的结构对象,但我不知道如何使用它。
这是 link 我试图利用的文档区域 http://www.rubydoc.info/gems/evernote-thrift/Evernote/EDAM/NoteStore/NoteList#struct_fields-instance_method
我的尝试如下,但它没有返回任何东西。不幸的是我根本不熟悉结构。
notebooks = noteStore.listNotebooks(authToken)
notebooks.each do |notebook|
next if notebook.name != 'First Notebook'
notes = notebook.noteList
noteList.each do |note|
puts note
end
end
我收到一个无方法错误...这很有意义,因为它是一个结构,我只是不知道如何利用它...
undefined method `noteList' for <Evernote::EDAM::Type::Notebook:0x007fb2041683f8> (NoMethodError)
API 是我见过的最少 Ruby 的事情之一。我对你试图艰难地度过难关表示哀悼:)
从 API 文档中,我所看到的与 Evernote::EDAM::Type::Notebook class 无关的是 #struct_fields 和 #validate,就实例方法而言走。也许那个 struct_fields 有你要找的东西?
如果这不能引导您到任何地方,我建议您使用 Pry 之类的工具来帮助您解决错误。我会在第二行放一个 binding.pry
语句,然后从那里探索笔记本对象。
为我们的 Ruby SDK 生成的文档令人困惑(抱歉!),但我发现一般文档更加清晰:https://dev.evernote.com/doc/reference/.
如您在 https://dev.evernote.com/doc/reference/Types.html#Struct_Notebook 中所见,Notebook
对象没有名为 noteList
的属性。有一个名为 NoteList
的结构,但这是已删除的 NoteStore.findNotes
返回的结构。
获取笔记本中笔记的titles/subjects的过程是获取Notebook
(你已经完成),然后将笔记本的guid传递给NoteStore.findNotesMetadata
(https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_findNotesMetadata). This returns a NotesMetadataList
which has a notes
attribute which is a list of NoteMetadata
. This struct has metadata like title and GUID but not the body. If you want the full information, you would pass the GUID into NoteStore.getNote
(https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_getNote).
我正在使用 ruby evernote-thrift API 和沙箱。
我在解释文档时遇到了一些问题;我正在尝试从特定笔记本中的所有笔记中检索主题行。
获取我调用的笔记本名称
notebooks = noteStore.listNotebooks(authToken)
然后 运行 .each
notebooks
。根据文档,有一个名为 noteList
的结构对象,但我不知道如何使用它。
这是 link 我试图利用的文档区域 http://www.rubydoc.info/gems/evernote-thrift/Evernote/EDAM/NoteStore/NoteList#struct_fields-instance_method
我的尝试如下,但它没有返回任何东西。不幸的是我根本不熟悉结构。
notebooks = noteStore.listNotebooks(authToken)
notebooks.each do |notebook|
next if notebook.name != 'First Notebook'
notes = notebook.noteList
noteList.each do |note|
puts note
end
end
我收到一个无方法错误...这很有意义,因为它是一个结构,我只是不知道如何利用它...
undefined method `noteList' for <Evernote::EDAM::Type::Notebook:0x007fb2041683f8> (NoMethodError)
API 是我见过的最少 Ruby 的事情之一。我对你试图艰难地度过难关表示哀悼:)
从 API 文档中,我所看到的与 Evernote::EDAM::Type::Notebook class 无关的是 #struct_fields 和 #validate,就实例方法而言走。也许那个 struct_fields 有你要找的东西?
如果这不能引导您到任何地方,我建议您使用 Pry 之类的工具来帮助您解决错误。我会在第二行放一个 binding.pry
语句,然后从那里探索笔记本对象。
为我们的 Ruby SDK 生成的文档令人困惑(抱歉!),但我发现一般文档更加清晰:https://dev.evernote.com/doc/reference/.
如您在 https://dev.evernote.com/doc/reference/Types.html#Struct_Notebook 中所见,Notebook
对象没有名为 noteList
的属性。有一个名为 NoteList
的结构,但这是已删除的 NoteStore.findNotes
返回的结构。
获取笔记本中笔记的titles/subjects的过程是获取Notebook
(你已经完成),然后将笔记本的guid传递给NoteStore.findNotesMetadata
(https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_findNotesMetadata). This returns a NotesMetadataList
which has a notes
attribute which is a list of NoteMetadata
. This struct has metadata like title and GUID but not the body. If you want the full information, you would pass the GUID into NoteStore.getNote
(https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_getNote).