lunchmoney 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check_pipeline.yml +24 -0
  3. data/.github/workflows/ci.yml +1 -4
  4. data/.github/workflows/dependabot-rbi-updater.yml +3 -6
  5. data/.github/workflows/publish_gem.yml +14 -16
  6. data/.github/workflows/release_pipeline.yml +36 -0
  7. data/.rubocop.yml +5 -2
  8. data/Gemfile +1 -1
  9. data/Gemfile.lock +19 -18
  10. data/LICENSE +1 -1
  11. data/README.md +1 -1
  12. data/Rakefile +27 -0
  13. data/lib/lunchmoney/api.rb +160 -35
  14. data/lib/lunchmoney/calls/assets.rb +98 -0
  15. data/lib/lunchmoney/calls/base.rb +118 -0
  16. data/lib/lunchmoney/calls/budgets.rb +84 -0
  17. data/lib/lunchmoney/calls/categories.rb +196 -0
  18. data/lib/lunchmoney/calls/crypto.rb +50 -0
  19. data/lib/lunchmoney/calls/plaid_accounts.rb +40 -0
  20. data/lib/lunchmoney/calls/recurring_expenses.rb +29 -0
  21. data/lib/lunchmoney/calls/tags.rb +21 -0
  22. data/lib/lunchmoney/calls/transactions.rb +220 -0
  23. data/lib/lunchmoney/calls/users.rb +21 -0
  24. data/lib/lunchmoney/errors.rb +17 -1
  25. data/lib/lunchmoney/objects/asset.rb +92 -0
  26. data/lib/lunchmoney/objects/budget.rb +76 -0
  27. data/lib/lunchmoney/objects/category.rb +55 -0
  28. data/lib/lunchmoney/objects/child_category.rb +44 -0
  29. data/lib/lunchmoney/objects/child_transaction.rb +35 -0
  30. data/lib/lunchmoney/objects/config.rb +40 -0
  31. data/lib/lunchmoney/objects/crypto.rb +46 -0
  32. data/lib/lunchmoney/objects/crypto_base.rb +67 -0
  33. data/lib/lunchmoney/objects/data.rb +44 -0
  34. data/lib/lunchmoney/objects/object.rb +28 -0
  35. data/lib/lunchmoney/objects/plaid_account.rb +75 -0
  36. data/lib/lunchmoney/objects/recurring_expense.rb +68 -0
  37. data/lib/lunchmoney/objects/recurring_expense_base.rb +31 -0
  38. data/lib/lunchmoney/objects/split.rb +28 -0
  39. data/lib/lunchmoney/objects/tag.rb +24 -0
  40. data/lib/lunchmoney/objects/tag_base.rb +23 -0
  41. data/lib/lunchmoney/objects/transaction.rb +160 -0
  42. data/lib/lunchmoney/objects/transaction_base.rb +54 -0
  43. data/lib/lunchmoney/objects/transaction_modification_base.rb +32 -0
  44. data/lib/lunchmoney/objects/update_transaction.rb +47 -0
  45. data/lib/lunchmoney/objects/user.rb +38 -0
  46. data/lib/lunchmoney/version.rb +1 -1
  47. data/lunchmoney.gemspec +3 -4
  48. data/sorbet/rbi/gems/{minitest@5.21.2.rbi → minitest@5.22.2.rbi} +147 -144
  49. data/sorbet/rbi/gems/{rubocop-sorbet@0.7.6.rbi → rubocop-sorbet@0.7.7.rbi} +53 -6
  50. data/sorbet/rbi/gems/{rubocop@1.60.1.rbi → rubocop@1.60.2.rbi} +51 -30
  51. data/sorbet/rbi/gems/{toys@0.15.4.rbi → toys@0.15.5.rbi} +3 -3
  52. data/sorbet/rbi/gems/{webmock@3.19.1.rbi → webmock@3.20.0.rbi} +10 -10
  53. metadata +50 -47
  54. data/lib/lunchmoney/api_call.rb +0 -109
  55. data/lib/lunchmoney/assets/asset.rb +0 -89
  56. data/lib/lunchmoney/assets/asset_calls.rb +0 -96
  57. data/lib/lunchmoney/budget/budget.rb +0 -74
  58. data/lib/lunchmoney/budget/budget_calls.rb +0 -82
  59. data/lib/lunchmoney/budget/config.rb +0 -38
  60. data/lib/lunchmoney/budget/data.rb +0 -42
  61. data/lib/lunchmoney/categories/category/category.rb +0 -52
  62. data/lib/lunchmoney/categories/category/child_category.rb +0 -42
  63. data/lib/lunchmoney/categories/category_calls.rb +0 -195
  64. data/lib/lunchmoney/crypto/crypto/crypto.rb +0 -43
  65. data/lib/lunchmoney/crypto/crypto/crypto_base.rb +0 -65
  66. data/lib/lunchmoney/crypto/crypto_calls.rb +0 -49
  67. data/lib/lunchmoney/data_object.rb +0 -25
  68. data/lib/lunchmoney/plaid_accounts/plaid_account.rb +0 -73
  69. data/lib/lunchmoney/plaid_accounts/plaid_account_calls.rb +0 -38
  70. data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb +0 -65
  71. data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb +0 -29
  72. data/lib/lunchmoney/recurring_expenses/recurring_expense_calls.rb +0 -28
  73. data/lib/lunchmoney/tags/tag/tag.rb +0 -20
  74. data/lib/lunchmoney/tags/tag/tag_base.rb +0 -21
  75. data/lib/lunchmoney/tags/tag_calls.rb +0 -20
  76. data/lib/lunchmoney/transactions/transaction/child_transaction.rb +0 -31
  77. data/lib/lunchmoney/transactions/transaction/split.rb +0 -24
  78. data/lib/lunchmoney/transactions/transaction/transaction.rb +0 -156
  79. data/lib/lunchmoney/transactions/transaction/transaction_base.rb +0 -52
  80. data/lib/lunchmoney/transactions/transaction/transaction_modification_base.rb +0 -30
  81. data/lib/lunchmoney/transactions/transaction/update_transaction.rb +0 -43
  82. data/lib/lunchmoney/transactions/transaction_calls.rb +0 -218
  83. data/lib/lunchmoney/user/user.rb +0 -36
  84. data/lib/lunchmoney/user/user_calls.rb +0 -19
  85. /data/sorbet/rbi/gems/{crack@0.4.5.rbi → crack@1.0.0.rbi} +0 -0
  86. /data/sorbet/rbi/gems/{toys-core@0.15.4.rbi → toys-core@0.15.5.rbi} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66fd4ba45ca3d30c32dea0c70f504714811980af2bf373b2412232da5e9d19da
4
- data.tar.gz: 1a2becc26568423ff1b6fa70108400efa5cc366cd65e1ced013eb34084c65dee
3
+ metadata.gz: a66d419d272f25d940cb0ad8a5f5962b85aa3cb74deee1486e3f7ed9caf9f8ac
4
+ data.tar.gz: bd656eac78fd93d9979e3a86ab639f7f880f2e74fd2fb3a0e64889a7df8e6086
5
5
  SHA512:
6
- metadata.gz: 5a3a997026a7ab6c541ef0cb4c8b1fb6fcf992ad91d2ae6cc1ba408007f88a7a001cb9703d7c15038f4ce87fa36d78a9580b4cd5010e3a36a747c4845ce5e96b
7
- data.tar.gz: 3a4c3ec3283535b9829afd17427f89e7f88538826b4c30f02075e13807e925fac9070d90f9061ea7ec6cc8f135099dc43623929f83a322a48c987644083931d7
6
+ metadata.gz: d756dda147ed0c8cb492c2be68d40772a0d182513fbef4cdc326c7a5644b16f23e8a7ee5bb0228e030d6f16b9c8b396b1fd3cedc9bdfd9d389bdd9bddef37721
7
+ data.tar.gz: c9899675f397835b813d864db59db9e311cb1f99422349c901f8676a409bd22ce8be0a42e8bdc8c6ad77f341c23f7b67436966c4e10b09cc95eb9d8838dd3432
@@ -0,0 +1,24 @@
1
+ name: Check Pipeline
2
+
3
+ on:
4
+ push:
5
+ branches-ignore:
6
+ - main
7
+ paths-ignore:
8
+ - ".gitignore"
9
+ - "README.md"
10
+ tags-ignore:
11
+ - v*
12
+
13
+ jobs:
14
+ update-rbis:
15
+ name: RBI Updater
16
+ uses: mmenanno/lunchmoney/.github/workflows/dependabot-rbi-updater.yml@main
17
+ secrets: inherit
18
+
19
+ ci:
20
+ needs: update-rbis
21
+ if: always() && contains(needs.*.result, 'skipped')
22
+ name: "CI"
23
+ uses: mmenanno/lunchmoney/.github/workflows/ci.yml@main
24
+ secrets: inherit
@@ -1,11 +1,8 @@
1
1
  name: CI
2
2
 
3
3
  on:
4
- push:
5
- paths-ignore:
6
- - ".gitignore"
7
- - "README.md"
8
4
  workflow_dispatch:
5
+ workflow_call:
9
6
  schedule:
10
7
  # Every day at 9pm
11
8
  - cron: '0 21 * * *'
@@ -1,9 +1,6 @@
1
1
  name: Dependabot RBI Updater
2
2
  on:
3
- pull_request:
4
- paths:
5
- - 'Gemfile.lock'
6
- - 'Gemfile'
3
+ workflow_call:
7
4
 
8
5
  jobs:
9
6
  update-rbis:
@@ -32,12 +29,12 @@ jobs:
32
29
  git config --local user.name "Dependabot RBI Updater"
33
30
  git config --local user.email action@github.com
34
31
  git add sorbet/*
35
- git commit -m "[dependabot skip] Update RBIs"
32
+ git diff-index --cached --quiet HEAD || git commit -m "[dependabot skip] Update RBIs"
36
33
  -
37
34
  name: Push changes
38
35
  uses: ad-m/github-push-action@v0.8.0
39
36
  with:
40
37
  github_token: ${{ secrets.LUNCHMONEY_PAT_TOKEN }}
41
- branch: ${{ github.head_ref }}
38
+ branch: ${{ github.ref }}
42
39
 
43
40
 
@@ -1,31 +1,29 @@
1
1
  name: Publish Gem
2
2
 
3
3
  on:
4
- push:
5
- tags:
6
- - v*
4
+ workflow_call:
5
+ workflow_dispatch:
6
+
7
7
  jobs:
8
8
  build:
9
9
  name: Build & Release Gem
10
10
  runs-on: ubuntu-latest
11
+ environment: rubygems
12
+
13
+ permissions:
14
+ contents: write
15
+ id-token: write
11
16
 
12
17
  steps:
18
+ # Set up
13
19
  - uses: actions/checkout@v4
14
-
15
20
  - name: Set up Ruby
16
21
  uses: ruby/setup-ruby@v1
17
22
  with:
18
- ruby-version: 3.3.0
19
23
  bundler-cache: true
20
- - name: Release Gem
21
- if: contains(github.ref, 'refs/tags/v')
22
- run: |
23
- mkdir -p $HOME/.gem
24
- touch $HOME/.gem/credentials
25
- chmod 0600 $HOME/.gem/credentials
26
- printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
27
- gem build *.gemspec
28
- gem push *.gem
29
- env:
30
- RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
24
+ ruby-version: ruby
25
+
26
+ # Release
27
+ - name: Publish to RubyGems
28
+ uses: rubygems/release-gem@v1
31
29
 
@@ -0,0 +1,36 @@
1
+ name: Release Pipeline
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - v*
8
+
9
+ jobs:
10
+ ci:
11
+ name: "CI"
12
+ uses: mmenanno/lunchmoney/.github/workflows/ci.yml@main
13
+ secrets: inherit
14
+ release:
15
+ needs: ci
16
+ if: always() && !contains(needs.*.result, 'failed') && !contains(needs.*.result, 'cancelled')
17
+ name: Build & Release Gem
18
+ runs-on: ubuntu-latest
19
+ environment: rubygems
20
+
21
+ permissions:
22
+ contents: write
23
+ id-token: write
24
+
25
+ steps:
26
+ # Set up
27
+ - uses: actions/checkout@v4
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ bundler-cache: true
32
+ ruby-version: ruby
33
+
34
+ # Release
35
+ - name: Publish to RubyGems
36
+ uses: rubygems/release-gem@v1
data/.rubocop.yml CHANGED
@@ -22,16 +22,19 @@ Sorbet/FalseSigil:
22
22
  Sorbet/StrictSigil:
23
23
  Enabled: true
24
24
  Exclude:
25
- - "test/*"
26
25
  - ".toys/**/*"
27
26
 
28
27
  Sorbet/ForbidTStruct:
28
+ # Context for why this is preferable https://github.com/Shopify/rubocop-sorbet/pull/178#issuecomment-1739924189
29
29
  Enabled: true
30
- # Context for why this is preferable https://github.com/Shopify/rubocop-sorbet/pull/178#issuecomment-1739924189
30
+
31
31
 
32
32
  Sorbet/RedundantExtendTSig:
33
33
  Enabled: true
34
34
 
35
+ Sorbet/ForbidTUnsafe:
36
+ Enabled: true
37
+
35
38
  Minitest:
36
39
  Enabled: true
37
40
 
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  # Specify development dependencies here
9
9
  gem "toys"
10
- gem "minitest", "~> 5.21", require: false
10
+ gem "minitest", "~> 5.22", require: false
11
11
  gem "mocha", "~> 2.1.0", require: false
12
12
  gem "webmock", require: false
13
13
  gem "vcr", require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lunchmoney (1.0.0)
4
+ lunchmoney (1.1.1)
5
5
  activesupport (>= 6.1)
6
6
  faraday (>= 1.0.0)
7
7
  sorbet-runtime (>= 0.5)
@@ -31,7 +31,8 @@ GEM
31
31
  coderay (1.1.3)
32
32
  concurrent-ruby (1.2.3)
33
33
  connection_pool (2.4.1)
34
- crack (0.4.5)
34
+ crack (1.0.0)
35
+ bigdecimal
35
36
  rexml
36
37
  dotenv (2.8.1)
37
38
  drb (2.2.0)
@@ -47,7 +48,7 @@ GEM
47
48
  json (2.7.1)
48
49
  language_server-protocol (3.17.0.3)
49
50
  method_source (1.0.0)
50
- minitest (5.21.2)
51
+ minitest (5.22.2)
51
52
  mocha (2.1.0)
52
53
  ruby2_keywords (>= 0.0.5)
53
54
  mutex_m (0.2.0)
@@ -75,7 +76,7 @@ GEM
75
76
  sorbet-runtime (>= 0.5.9204)
76
77
  regexp_parser (2.9.0)
77
78
  rexml (3.2.6)
78
- rubocop (1.60.1)
79
+ rubocop (1.60.2)
79
80
  json (~> 2.3)
80
81
  language_server-protocol (>= 3.17.0)
81
82
  parallel (~> 1.10)
@@ -98,18 +99,18 @@ GEM
98
99
  rubocop-ast (>= 1.30.0, < 2.0)
99
100
  rubocop-shopify (2.14.0)
100
101
  rubocop (~> 1.51)
101
- rubocop-sorbet (0.7.6)
102
+ rubocop-sorbet (0.7.7)
102
103
  rubocop (>= 0.90.0)
103
104
  ruby-progressbar (1.13.0)
104
105
  ruby2_keywords (0.0.5)
105
- sorbet (0.5.11219)
106
- sorbet-static (= 0.5.11219)
107
- sorbet-runtime (0.5.11219)
108
- sorbet-static (0.5.11219-universal-darwin)
109
- sorbet-static (0.5.11219-x86_64-linux)
110
- sorbet-static-and-runtime (0.5.11219)
111
- sorbet (= 0.5.11219)
112
- sorbet-runtime (= 0.5.11219)
106
+ sorbet (0.5.11247)
107
+ sorbet-static (= 0.5.11247)
108
+ sorbet-runtime (0.5.11247)
109
+ sorbet-static (0.5.11247-universal-darwin)
110
+ sorbet-static (0.5.11247-x86_64-linux)
111
+ sorbet-static-and-runtime (0.5.11247)
112
+ sorbet (= 0.5.11247)
113
+ sorbet-runtime (= 0.5.11247)
113
114
  spoom (1.2.4)
114
115
  erubi (>= 1.10.0)
115
116
  sorbet-static-and-runtime (>= 0.5.10187)
@@ -127,15 +128,15 @@ GEM
127
128
  thor (>= 1.2.0)
128
129
  yard-sorbet
129
130
  thor (1.3.0)
130
- toys (0.15.4)
131
- toys-core (= 0.15.4)
132
- toys-core (0.15.4)
131
+ toys (0.15.5)
132
+ toys-core (= 0.15.5)
133
+ toys-core (0.15.5)
133
134
  tzinfo (2.0.6)
134
135
  concurrent-ruby (~> 1.0)
135
136
  unicode-display_width (2.5.0)
136
137
  uri (0.13.0)
137
138
  vcr (6.2.0)
138
- webmock (3.19.1)
139
+ webmock (3.20.0)
139
140
  addressable (>= 2.8.0)
140
141
  crack (>= 0.3.2)
141
142
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -154,7 +155,7 @@ DEPENDENCIES
154
155
  appraisal
155
156
  dotenv
156
157
  lunchmoney!
157
- minitest (~> 5.21)
158
+ minitest (~> 5.22)
158
159
  mocha (~> 2.1.0)
159
160
  pry-sorbet (~> 0.2)
160
161
  rubocop-minitest
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2021 halorrr
3
+ Copyright (c) 2021 mmenanno
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  This gem is a API client library of the [LunchMoney API](https://lunchmoney.dev/) for the wonderful [LunchMoney](http://lunchmoney.app/) web app for personal finance & budgeting.
8
8
 
9
- Documentation is still a work in process, but you can find the yard docs for this gem [here](https://halorrr.github.io/lunchmoney/) as well as some write ups of the basics below.
9
+ Documentation is still a work in process, but you can find the yard docs for this gem [here](https://halorrr.github.io/lunchmoney/) as well as some write ups of the basics below. An example of every call is listed on the [Api class in the yard docs](https://halorrr.github.io/lunchmoney/LunchMoney/Api.html).
10
10
 
11
11
  ## Usage
12
12
 
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'toys' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("toys", "toys")
@@ -4,22 +4,25 @@
4
4
  require_relative "exceptions"
5
5
  require_relative "configuration"
6
6
 
7
- require_relative "api_call"
8
- require_relative "data_object"
9
- require_relative "user/user_calls"
10
- require_relative "categories/category_calls"
11
- require_relative "tags/tag_calls"
12
- require_relative "transactions/transaction_calls"
13
- require_relative "recurring_expenses/recurring_expense_calls"
14
- require_relative "budget/budget_calls"
15
- require_relative "assets/asset_calls"
16
- require_relative "plaid_accounts/plaid_account_calls"
17
- require_relative "crypto/crypto_calls"
7
+ require_relative "calls/base"
8
+ require_relative "objects/object"
9
+ require_relative "calls/users"
10
+ require_relative "calls/categories"
11
+ require_relative "calls/tags"
12
+ require_relative "calls/transactions"
13
+ require_relative "calls/recurring_expenses"
14
+ require_relative "calls/budgets"
15
+ require_relative "calls/assets"
16
+ require_relative "calls/plaid_accounts"
17
+ require_relative "calls/crypto"
18
18
 
19
19
  module LunchMoney
20
- # The main API class that a user should interface through the method of any individual call is delegated through here
21
- # so that it is never necessary to go through things like `LunchMoney::UserCalls.new.user` instead you can directly
20
+ # The main API class that a user should interface through. The method of any individual call is delegated through here
21
+ # so that it is never necessary to go through things like `LunchMoney::Calls::Users.new.user` instead you can directly
22
22
  # call the endpoint with LunchMoney::Api.new.user and it will be delegated to the correct call.
23
+ # @example
24
+ # api = LunchMoney::Api.new
25
+ # api.categories # This will be delegated to LunchMoney::Calls::Categories#categories
23
26
  class Api
24
27
  sig { returns(T.nilable(String)) }
25
28
  attr_reader :api_key
@@ -31,10 +34,14 @@ module LunchMoney
31
34
 
32
35
  delegate :me, to: :user_calls
33
36
 
34
- sig { returns(LunchMoney::ApiCall) }
37
+ # All [user call types](https://lunchmoney.dev/#user) come through here.
38
+ # @example [Get User](https://lunchmoney.dev/#get-user)
39
+ # api = LunchMoney::Api.new
40
+ # api.me
41
+ sig { returns(LunchMoney::Calls::Base) }
35
42
  def user_calls
36
43
  with_valid_api_key do
37
- @user_calls ||= T.let(LunchMoney::UserCalls.new(api_key:), T.nilable(LunchMoney::UserCalls))
44
+ @user_calls ||= T.let(LunchMoney::Calls::Users.new(api_key:), T.nilable(LunchMoney::Calls::Users))
38
45
  end
39
46
  end
40
47
 
@@ -48,19 +55,49 @@ module LunchMoney
48
55
  :force_delete_category,
49
56
  to: :category_calls
50
57
 
51
- sig { returns(LunchMoney::ApiCall) }
58
+ # All [category call types](https://lunchmoney.dev/#categories) come through here. Reference the docs for
59
+ # available parameters for each call
60
+ # @example [Get All Categories](https://lunchmoney.dev/#get-all-categories)
61
+ # api = LunchMoney::Api.new
62
+ # api.categories
63
+ # @example [Get Single Category](https://lunchmoney.dev/#get-single-category)
64
+ # api = LunchMoney::Api.new
65
+ # api.category(1234567)
66
+ # @example [Create Category](https://lunchmoney.dev/#create-category)
67
+ # api = LunchMoney::Api.new
68
+ # api.create_category(name: "New Category Name")
69
+ # @example [Create Category Group](https://lunchmoney.dev/#create-category-group)
70
+ # api = LunchMoney::Api.new
71
+ # api.create_category_group(name: "New Category Group Name")
72
+ # @example [Update Category](https://lunchmoney.dev/#update-category)
73
+ # api = LunchMoney::Api.new
74
+ # api.update_category(1234567, "Updated Category Name")
75
+ # @example [Add to Category Group](https://lunchmoney.dev/#add-to-category-group)
76
+ # api = LunchMoney::Api.new
77
+ # api.add_to_category_group(7654321, category_ids: [1234567], new_categories: ["Another Category"])
78
+ # @example [Delete Category](https://lunchmoney.dev/#delete-category)
79
+ # api = LunchMoney::Api.new
80
+ # api.delete_category(1234567)
81
+ # @example [Force Delete Category](https://lunchmoney.dev/#force-delete-category)
82
+ # api = LunchMoney::Api.new
83
+ # api.force_delete_category(1234567)
84
+ sig { returns(LunchMoney::Calls::Base) }
52
85
  def category_calls
53
86
  with_valid_api_key do
54
- @category_calls ||= T.let(LunchMoney::CategoryCalls.new(api_key:), T.nilable(LunchMoney::CategoryCalls))
87
+ @category_calls ||= T.let(LunchMoney::Calls::Categories.new(api_key:), T.nilable(LunchMoney::Calls::Categories))
55
88
  end
56
89
  end
57
90
 
58
91
  delegate :tags, to: :tag_calls
59
92
 
60
- sig { returns(LunchMoney::ApiCall) }
93
+ # All [tags call types](https://lunchmoney.dev/#tags) come through here.
94
+ # @example [Get All Tags](https://lunchmoney.dev/#get-all-tags)
95
+ # api = LunchMoney::Api.new
96
+ # api.tags
97
+ sig { returns(LunchMoney::Calls::Base) }
61
98
  def tag_calls
62
99
  with_valid_api_key do
63
- @tag_calls ||= T.let(LunchMoney::TagCalls.new(api_key:), T.nilable(LunchMoney::TagCalls))
100
+ @tag_calls ||= T.let(LunchMoney::Calls::Tags.new(api_key:), T.nilable(LunchMoney::Calls::Tags))
64
101
  end
65
102
  end
66
103
 
@@ -74,70 +111,158 @@ module LunchMoney
74
111
  :delete_transaction_group,
75
112
  to: :transaction_calls
76
113
 
77
- sig { returns(LunchMoney::ApiCall) }
114
+ # All [transaction call types](https://lunchmoney.dev/#transactions) come through here.
115
+ # @example [Get All Transactions](https://lunchmoney.dev/#get-all-transactions)
116
+ # api = LunchMoney::Api.new
117
+ # api.transactions
118
+ # @example [Get Single Transaction](https://lunchmoney.dev/#get-single-transaction)
119
+ # api = LunchMoney::Api.new
120
+ # api.transaction(123456789)
121
+ # @example [Insert Transactions](https://lunchmoney.dev/#insert-transactions)
122
+ # api = LunchMoney::Api.new
123
+ # transaction = LunchMoney::Objects::UpdateTransaction.new(
124
+ # date: "2024-01-01",
125
+ # amount: "10.99",
126
+ # payee: "Example Payee",
127
+ # currency: "cad",
128
+ # status: "cleared"
129
+ # )
130
+ # api.insert_transactions([transaction])
131
+ # @example Regular [Update Transactions](https://lunchmoney.dev/#update-transactions)
132
+ # api = LunchMoney::Api.new
133
+ # transaction = LunchMoney::Objects::UpdateTransaction.new(
134
+ # date: "2024-01-01",
135
+ # amount: "10.99",
136
+ # payee: "Example Payee",
137
+ # currency: "cad",
138
+ # status: "cleared"
139
+ # )
140
+ # api.update_transaction(123456789, transaction: transaction)
141
+ # @example Split [Update Transactions](https://lunchmoney.dev/#update-transactions)
142
+ # api = LunchMoney::Api.new
143
+ # split = [
144
+ # LunchMoney::Objects::Split.new(amount: "10.00"),
145
+ # LunchMoney::Objects::Split.new(amount: "47.54"),
146
+ # ]
147
+ # api.update_transaction(12345678, split: split)
148
+ # @example [Unsplit Transactions](https://lunchmoney.dev/#unsplit-transactions)
149
+ # api = LunchMoney::Api.new
150
+ # api.unsplit_transaction([123456789])
151
+ # @example [Get Transaction Group](https://lunchmoney.dev/#get-transaction-group)
152
+ # api = LunchMoney::Api.new
153
+ # api.transaction_group(987654321)
154
+ # @example [Create Transaction Group](https://lunchmoney.dev/#create-transaction-group)
155
+ # api = LunchMoney::Api.new
156
+ # api.create_transaction_group(date: "2024-01-01", payee: "Group", transactions: [123456789, 987654321])
157
+ # @example [Delete Transaction Group](https://lunchmoney.dev/#delete-transaction-group)
158
+ # api = LunchMoney::Api.new
159
+ # api.delete_transaction_group(905483362)
160
+ sig { returns(LunchMoney::Calls::Base) }
78
161
  def transaction_calls
79
162
  with_valid_api_key do
80
163
  @transaction_calls ||= T.let(
81
- LunchMoney::TransactionCalls.new(api_key:),
82
- T.nilable(LunchMoney::TransactionCalls),
164
+ LunchMoney::Calls::Transactions.new(api_key:),
165
+ T.nilable(LunchMoney::Calls::Transactions),
83
166
  )
84
167
  end
85
168
  end
86
169
 
87
170
  delegate :recurring_expenses, to: :recurring_expense_calls
88
171
 
89
- sig { returns(LunchMoney::ApiCall) }
172
+ # All [recurring expenses call types](https://lunchmoney.dev/#recurring-expenses) come through here.
173
+ # @example [Get Recurring Expenses](https://lunchmoney.dev/#get-recurring-expenses)
174
+ # api = LunchMoney::Api.new
175
+ # api.recurring_expenses
176
+ sig { returns(LunchMoney::Calls::Base) }
90
177
  def recurring_expense_calls
91
178
  with_valid_api_key do
92
179
  @recurring_expense_calls ||= T.let(
93
- LunchMoney::RecurringExpenseCalls.new(api_key:),
94
- T.nilable(LunchMoney::RecurringExpenseCalls),
180
+ LunchMoney::Calls::RecurringExpenses.new(api_key:),
181
+ T.nilable(LunchMoney::Calls::RecurringExpenses),
95
182
  )
96
183
  end
97
184
  end
98
185
 
99
186
  delegate :budgets, :upsert_budget, :remove_budget, to: :budget_calls
100
187
 
101
- sig { returns(LunchMoney::ApiCall) }
188
+ # All [budget call types](https://lunchmoney.dev/#budget) come through here.
189
+ # @example [Get Budget Summary](https://lunchmoney.dev/#get-budget-summary)
190
+ # api = LunchMoney::Api.new
191
+ # api.budgets(start_date: "2023-01-01", end_date: "2024-01-01")
192
+ # @example [Upsert Budget](https://lunchmoney.dev/#upsert-budget)
193
+ # api = LunchMoney::Api.new
194
+ # api.upsert_budget(start_date: "2023-01-01", category_id: 777052, amount: 400.99)
195
+ # @example [Remove Budget(https://lunchmoney.dev/#remove-budget)
196
+ # api = LunchMoney::Api.new
197
+ # api.remove_budget(start_date: "2023-01-01", category_id: 777052)
198
+ sig { returns(LunchMoney::Calls::Base) }
102
199
  def budget_calls
103
200
  with_valid_api_key do
104
- @budget_calls ||= T.let(LunchMoney::BudgetCalls.new(api_key:), T.nilable(LunchMoney::BudgetCalls))
201
+ @budget_calls ||= T.let(LunchMoney::Calls::Budgets.new(api_key:), T.nilable(LunchMoney::Calls::Budgets))
105
202
  end
106
203
  end
107
204
 
108
205
  delegate :assets, :create_asset, :update_asset, to: :asset_calls
109
206
 
110
- sig { returns(LunchMoney::ApiCall) }
207
+ # All [assets call types](https://lunchmoney.dev/#assets) come through here.
208
+ # @example [Get All Assets](https://lunchmoney.dev/#get-all-assets)
209
+ # api = LunchMoney::Api.new
210
+ # api.assets
211
+ # @example [Create Asset](https://lunchmoney.dev/#create-asset)
212
+ # api = LunchMoney::Api.new
213
+ # api.create_asset(
214
+ # type_name: "cash",
215
+ # name: "Create Asset Test",
216
+ # balance: "10.00",
217
+ # )
218
+ # @example [Update Asset](https://lunchmoney.dev/#update-asset)
219
+ # api = LunchMoney::Api.new
220
+ # api.update_asset(93746, balance: "99.99")
221
+ sig { returns(LunchMoney::Calls::Base) }
111
222
  def asset_calls
112
223
  with_valid_api_key do
113
- @asset_calls ||= T.let(LunchMoney::AssetCalls.new(api_key:), T.nilable(LunchMoney::AssetCalls))
224
+ @asset_calls ||= T.let(LunchMoney::Calls::Assets.new(api_key:), T.nilable(LunchMoney::Calls::Assets))
114
225
  end
115
226
  end
116
227
 
117
228
  delegate :plaid_accounts, :plaid_accounts_fetch, to: :plaid_account_calls
118
229
 
119
- sig { returns(LunchMoney::ApiCall) }
230
+ # All [Plaid accounts call types](https://lunchmoney.dev/#plaid-accounts) come through here.
231
+ # @example [Get All Plaid Accounts](https://lunchmoney.dev/#get-all-plaid-accounts)
232
+ # api = LunchMoney::Api.new
233
+ # api.plaid_accounts
234
+ # @example [Trigger Fetch from Plaid](https://lunchmoney.dev/#trigger-fetch-from-plaid)
235
+ # api = LunchMoney::Api.new
236
+ # api.plaid_accounts_fetch
237
+ sig { returns(LunchMoney::Calls::Base) }
120
238
  def plaid_account_calls
121
239
  with_valid_api_key do
122
240
  @plaid_account_calls ||= T.let(
123
- LunchMoney::PlaidAccountCalls.new(api_key:),
124
- T.nilable(LunchMoney::PlaidAccountCalls),
241
+ LunchMoney::Calls::PlaidAccounts.new(api_key:),
242
+ T.nilable(LunchMoney::Calls::PlaidAccounts),
125
243
  )
126
244
  end
127
245
  end
128
246
 
129
247
  delegate :crypto, :update_crypto, to: :crypto_calls
130
248
 
131
- sig { returns(LunchMoney::ApiCall) }
249
+ # All [crypto call types](https://lunchmoney.dev/#crypto) come through here.
250
+ # @example [Get All Crypto](https://lunchmoney.dev/#get-all-crypto)
251
+ # api = LunchMoney::Api.new
252
+ # api.crypto
253
+ # @example [Update Manual Crypto Asset](https://lunchmoney.dev/#update-manual-crypto-asset)
254
+ # api = LunchMoney::Api.new
255
+ # api.update_crypto(1234567, name: "New Crypto Name")
256
+ sig { returns(LunchMoney::Calls::Base) }
132
257
  def crypto_calls
133
258
  with_valid_api_key do
134
- @crypto_calls ||= T.let(LunchMoney::CryptoCalls.new(api_key:), T.nilable(LunchMoney::CryptoCalls))
259
+ @crypto_calls ||= T.let(LunchMoney::Calls::Crypto.new(api_key:), T.nilable(LunchMoney::Calls::Crypto))
135
260
  end
136
261
  end
137
262
 
138
263
  private
139
264
 
140
- sig { params(block: T.proc.returns(LunchMoney::ApiCall)).returns(LunchMoney::ApiCall) }
265
+ sig { params(block: T.proc.returns(LunchMoney::Calls::Base)).returns(LunchMoney::Calls::Base) }
141
266
  def with_valid_api_key(&block)
142
267
  raise(InvalidApiKey, "API key is missing or invalid") if api_key.blank?
143
268