( token: string, guid: string, withContent = true )
| 393 | } |
| 394 | |
| 395 | export async function getNote( |
| 396 | token: string, |
| 397 | guid: string, |
| 398 | withContent = true |
| 399 | ): Promise<EvernoteNote> { |
| 400 | const writer = new ThriftWriter() |
| 401 | writer.writeMessageBegin('getNote', 0) |
| 402 | writer.writeStringField(1, token) |
| 403 | writer.writeStringField(2, guid) |
| 404 | writer.writeBoolField(3, withContent) |
| 405 | writer.writeBoolField(4, false) |
| 406 | writer.writeBoolField(5, false) |
| 407 | writer.writeBoolField(6, false) |
| 408 | writer.writeFieldStop() |
| 409 | |
| 410 | const reader = await callNoteStore(token, writer) |
| 411 | let note: EvernoteNote | null = null |
| 412 | |
| 413 | reader.readStruct((r, fieldId, fieldType) => { |
| 414 | if (fieldId === 0 && fieldType === TYPE_STRUCT) { |
| 415 | note = readNote(r) |
| 416 | } else { |
| 417 | if (!checkEvernoteException(r, fieldId, fieldType)) { |
| 418 | r.skip(fieldType) |
| 419 | } |
| 420 | } |
| 421 | }) |
| 422 | |
| 423 | if (!note) { |
| 424 | throw new Error('No note returned from Evernote API') |
| 425 | } |
| 426 | |
| 427 | return note |
| 428 | } |
| 429 | |
| 430 | /** Wrap content in ENML if it's not already */ |
| 431 | function wrapInEnml(content: string): string { |
no test coverage detected