( token: string, guid: string, title?: string, content?: string, notebookGuid?: string, tagNames?: string[] )
| 485 | } |
| 486 | |
| 487 | export async function updateNote( |
| 488 | token: string, |
| 489 | guid: string, |
| 490 | title?: string, |
| 491 | content?: string, |
| 492 | notebookGuid?: string, |
| 493 | tagNames?: string[] |
| 494 | ): Promise<EvernoteNote> { |
| 495 | const writer = new ThriftWriter() |
| 496 | writer.writeMessageBegin('updateNote', 0) |
| 497 | writer.writeStringField(1, token) |
| 498 | |
| 499 | writer.writeFieldBegin(TYPE_STRUCT, 2) |
| 500 | writer.writeStringField(1, guid) |
| 501 | if (title !== undefined) { |
| 502 | writer.writeStringField(2, title) |
| 503 | } |
| 504 | if (content !== undefined) { |
| 505 | writer.writeStringField(3, wrapInEnml(content)) |
| 506 | } |
| 507 | if (notebookGuid !== undefined) { |
| 508 | writer.writeStringField(11, notebookGuid) |
| 509 | } |
| 510 | if (tagNames !== undefined) { |
| 511 | writer.writeStringListField(15, tagNames) |
| 512 | } |
| 513 | writer.writeFieldStop() |
| 514 | |
| 515 | writer.writeFieldStop() |
| 516 | |
| 517 | const reader = await callNoteStore(token, writer) |
| 518 | let note: EvernoteNote | null = null |
| 519 | |
| 520 | reader.readStruct((r, fieldId, fieldType) => { |
| 521 | if (fieldId === 0 && fieldType === TYPE_STRUCT) { |
| 522 | note = readNote(r) |
| 523 | } else { |
| 524 | if (!checkEvernoteException(r, fieldId, fieldType)) { |
| 525 | r.skip(fieldType) |
| 526 | } |
| 527 | } |
| 528 | }) |
| 529 | |
| 530 | if (!note) { |
| 531 | throw new Error('No note returned from Evernote API') |
| 532 | } |
| 533 | |
| 534 | return note |
| 535 | } |
| 536 | |
| 537 | export async function deleteNote(token: string, guid: string): Promise<number> { |
| 538 | const writer = new ThriftWriter() |
no test coverage detected