Skip to content

Upgrade to LunchMoney v2 api - #476

Open
mmenanno wants to merge 43 commits into
mainfrom
v2
Open

Upgrade to LunchMoney v2 api#476
mmenanno wants to merge 43 commits into
mainfrom
v2

Conversation

@mmenanno

Copy link
Copy Markdown
Owner

A nearly full rewrite of the gem to support the v2 api with a lot of different architecture choices

Fixes #471

Resolve conflicts: delete VCR files that were modified by Sorbet
annotation stripping but should be deleted entirely.
All v1 code is now dead after Phase 01 (core infrastructure) and
Phase 02 (object system) rewrote the gem internals. This removes:

- lib/lunchmoney/api.rb (v1 delegation hub)
- lib/lunchmoney/calls/ (11 v1 call modules)
- lib/lunchmoney/deprecate.rb (v1 deprecation helper)
- 14 v1 object files (object.rb, asset.rb, budget.rb, crypto.rb, etc.)
- test/test_helper.rb (v1 test setup)
- test/helpers/ (4 v1 test helpers)
- test/lunchmoney/calls/ (11 v1 call tests)
- 8 additional v1 test files

Phase 03 will rebuild calls/, api.rb, and test infrastructure from scratch.
Provides build_object and build_collection private helpers that all
Calls::* modules will include. Centralizes response deserialization
so call modules stay DRY.
- test/test_helper.rb: new v2 test helper (no VCR, no Sorbet, no dotenv)
- test/helpers/configuration_helper.rb: ENV and API key helpers
- test/helpers/fixture_helper.rb: JSON fixture loading from spec files
- test/helpers/lunchmoney_stub_helper.rb: WebMock helpers with rate limit defaults
- Calls::Me — GET /me
- Calls::Categories — full CRUD (groups via is_group flag)
- Calls::Tags — full CRUD (new in v2)
- Calls::ManualAccounts — full CRUD (renamed from assets)
- Calls::PlaidAccounts — list, get, fetch
- Calls::RecurringItems — list, get (required date range)
- Calls::Summary — polymorphic aligned/non-aligned response
- Calls::Transactions — core CRUD + auto-paginating list + manual page
- Calls::Transactions::Split — split/unsplit (new dedicated endpoints)
- Calls::Transactions::Group — group/ungroup (renamed params)
- Calls::Transactions::Bulk — bulk update/delete (new in v2)
- Calls::Transactions::Attachments — CRUD for file attachments (new in v2)

Auto-pagination is currently eager (fetches all pages). Will become lazy
via Client::Pagination in Phase 04.
LunchMoney::Api inherits from Client::Base and includes all 12 call
modules. Exposes 40 public API methods. No ActiveSupport delegate
calls — methods come directly from included modules.

Entry point (lib/lunchmoney.rb) now requires api.rb, which loads all
objects, enums, and call modules. require "lunchmoney" gives full access.
…00, 0403, 0404)

- Client::Pagination: lazy Enumerable that auto-paginates transactions
- ClientValidationError: dedicated error class for client-side validation
- Wire validation: update methods construct request objects and validate
  before HTTP calls (transactions, manual_accounts, bulk)
- All request objects now raise ClientValidationError instead of ArgumentError
The fixture had {"recurring_items": {"recurring_items": [...]}} which
would break build_collection. Fixed to {"recurring_items": [...]}.
12 new test files, 188 total tests, 573 assertions:
- API delegation hub: respond_to checks for all 36+ methods
- Call modules: me, categories, tags, transactions, manual_accounts,
  plaid_accounts, recurring_items, summary, transaction submodules
- Client::Pagination: lazy enumeration with mocha mocks
- Object validation: InsertTransaction, UpdateTransaction,
  CreateManualAccount, SplitTransaction
…3, 0505-0507)

- Migrate Phase 01/02 tests to use test_helper.rb and ActiveSupport::TestCase
- Fix SimpleCov: set minimum on line coverage only (not branch), update
  groups for v2 file structure, remove references to deleted v1 files
- Add ClientValidationError tests to errors_test.rb
- Fixes toys test runner aborting before Minitest runs (SimpleCov at_exit
  hook order issue)
…1, 0605)

- Add weekly GitHub Action to check npm for new LunchMoney API spec
  versions, regenerate models, and open a PR for review
- Add generators/ filter to SimpleCov to exclude non-library code
- Update summary to reference v2 API
- Point documentation_uri to GitHub homepage (no more YARD docs)
- Point changelog_uri to CHANGELOG.md in the repo
Documents all breaking changes, new features, and removals for the
v2 migration. Date to be filled in at release time.
Comment thread .github/workflows/openapi_spec_update.yml Fixed
…sions

Remove stale yard-sorbet reference from YARD docs workflow, remove
Sorbet typed sigil and incompatible faraday-1-0 appraisal from
Appraisals, and add explicit permissions block to OpenAPI spec update
workflow to satisfy CodeQL.
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.

Support V2 API

2 participants