Skip to content

クラウド請求書 API v3 のサポートを追加#8

Merged
beatinaniwa merged 1 commit into
mainfrom
feat/invoice-api-v3
May 8, 2026
Merged

クラウド請求書 API v3 のサポートを追加#8
beatinaniwa merged 1 commit into
mainfrom
feat/invoice-api-v3

Conversation

@beatinaniwa

Copy link
Copy Markdown
Owner

概要

クラウド会計 API に加えて マネーフォワード クラウド請求書 API v3 を扱えるようにし、AI エージェントから請求書ドラフトを CRUD できるようにする。

変更内容

  • iv_openapi.yaml を埋め込み、mf describe --api invoice で参照可能に
  • 新コマンド: mf invoices (list/get/create/update/delete)、mf invoice-partnersmf invoice-departmentsmf invoice-items
  • OAuth スコープに mfc/invoice/data.read / .write を追加(AllScopes のみ。DefaultScopes は変更なし)
  • internal/api.NewInvoiceClient を追加して invoice 用ベース URL の第二クライアントを生成、*api.Client 本体は共通利用
  • 新コマンドは DI + pure runner + RunE wrapper パターンで testable に(cmd/invoice_deps.go
  • 数値精度保持のため request body は json.Number ベースで decode、未知フィールド・trailing data・不正 JSON は拒否
  • describe parser に path-item parameters マージ、requestBody.$ref の 1 段解決、root-level security フォールバック、HTTP method ベースの read/write スコープ優先選択を追加
  • 設計ドキュメント (CONTRIBUTING.md / README.md) に新パターンの境界と請求書コマンドの使い方を追記

Codex ローカルレビューの結果

  • 8 ラウンド(修正: 12 件、スキップ: 0 件)
  • 主な指摘:
    • exitInvoiceAPIError で friendly remediation hint が消えていた → output.PrintError 直書きに変更
    • UpdateBillingRequest.Items は spec 非対応 → 削除
    • dry-run URL が url.PathEscape をバイパス → 適用
    • NormalizeInvoiceBaseURL? のみ URL を許容 → ForceQuery も拒否
    • maxLength がバイト基準 → utf8.RuneCountInString に変更
    • tag_names の空配列を明示送信できなかった → *[]string
    • JSON decoder が trailing data や未知フィールドを silent drop → DisallowUnknownFields + 再 Decode で io.EOF 期待
    • describerequired_scope が空表示 → root-level security フォールバック追加
    • --q の排他チェックが厳しすぎた → spec 通り 4 フラグに限定
    • HTTP method を見ない単純な scopes[0] 返却 → GET は .read 優先 / 他は .write 優先

テスト

  • go test -race ./...: 全パッケージ通過
  • golangci-lint run ./...: 0 issues
  • バイナリスモークテスト: mf describe --api invoice invoicesBillingNewTemplateCreateRequest が表示されることを確認

クラウド会計 API に加えて MoneyForward クラウド請求書 API v3 を扱える
ようにし、AI エージェントから請求書ドラフトを CRUD できるようにする。

- iv_openapi.yaml を埋め込み、`mf describe --api invoice` で参照可能に
- `mf invoices` (list/get/create/update/delete) と
  `mf invoice-partners` / `mf invoice-departments` / `mf invoice-items`
  を追加
- OAuth スコープに mfc/invoice/data.read / .write を追加(AllScopes のみ)
- 内部設計: 既存 *api.Client を再利用しつつ NewInvoiceClient で
  invoice 用ベース URL を持つ第二インスタンスを生成
- 新コマンドは DI + pure runner + RunE wrapper パターンで testable に
- 数値精度保持のため json.Number ベースで decode、未知フィールドや
  trailing data も拒否
- describe parser に path-item parameters マージ、requestBody.\$ref
  解決、root-level security フォールバック、HTTP method ベースの
  read/write スコープ優先選択を追加
@beatinaniwa

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@beatinaniwa beatinaniwa merged commit bbcec32 into main May 8, 2026
1 check passed
@beatinaniwa beatinaniwa deleted the feat/invoice-api-v3 branch May 8, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant