feat: add invoice online URL and PDF download tools#127
Open
harryblam wants to merge 1 commit intoXeroAPI:mainfrom
Open
feat: add invoice online URL and PDF download tools#127harryblam wants to merge 1 commit intoXeroAPI:mainfrom
harryblam wants to merge 1 commit intoXeroAPI:mainfrom
Conversation
Add two new read-only tools for accessing Xero invoice documents: - get-invoice-online-url: returns the public shareable URL for an invoice (gracefully handles invoices without online viewing enabled) - get-invoice-as-pdf: returns the Xero-rendered invoice PDF as base64 Both use existing accounting.transactions scope — no new scopes required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two new read-only tools for accessing Xero invoice documents:
get-invoice-online-urlget-invoice-as-pdfChanges
New files
src/handlers/get-xero-invoice-online-url.handler.ts— callsaccountingApi.getOnlineInvoice(), extracts URL from responsesrc/handlers/get-xero-invoice-as-pdf.handler.ts— callsaccountingApi.getInvoiceAsPdf(), converts Buffer to base64src/tools/get/get-invoice-online-url.tool.ts— tool definition withinvoiceIdparameter; gracefully handles invoices without online viewing enabledsrc/tools/get/get-invoice-as-pdf.tool.ts— tool definition withinvoiceIdparameter; returns PDF content as base64Modified files
src/tools/get/index.ts— registers both new toolsScope
Both tools use
accountingApi.getOnlineInvoice()andaccountingApi.getInvoiceAsPdf()which fall under the existingaccounting.transactionsscope. No new scopes required.Testing
Tested against a live Xero account:
get-invoice-online-urlreturns the correct shareable URL (e.g.https://in.xero.com/...)get-invoice-as-pdfreturns a valid PDF (~90KB base64 for a simple invoice)