lunchmoney 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish_gem.yml +1 -0
- data/Gemfile.lock +1 -1
- data/lib/lunchmoney/api.rb +34 -34
- data/lib/lunchmoney/calls/assets.rb +98 -0
- data/lib/lunchmoney/calls/base.rb +112 -0
- data/lib/lunchmoney/calls/budgets.rb +84 -0
- data/lib/lunchmoney/calls/categories.rb +196 -0
- data/lib/lunchmoney/calls/crypto.rb +50 -0
- data/lib/lunchmoney/calls/plaid_accounts.rb +40 -0
- data/lib/lunchmoney/calls/recurring_expenses.rb +29 -0
- data/lib/lunchmoney/calls/tags.rb +21 -0
- data/lib/lunchmoney/calls/transactions.rb +220 -0
- data/lib/lunchmoney/calls/users.rb +21 -0
- data/lib/lunchmoney/objects/asset.rb +91 -0
- data/lib/lunchmoney/objects/budget.rb +76 -0
- data/lib/lunchmoney/objects/category.rb +55 -0
- data/lib/lunchmoney/objects/child_category.rb +44 -0
- data/lib/lunchmoney/objects/child_transaction.rb +35 -0
- data/lib/lunchmoney/objects/config.rb +40 -0
- data/lib/lunchmoney/objects/crypto.rb +46 -0
- data/lib/lunchmoney/objects/crypto_base.rb +67 -0
- data/lib/lunchmoney/objects/data.rb +44 -0
- data/lib/lunchmoney/objects/object.rb +28 -0
- data/lib/lunchmoney/objects/plaid_account.rb +75 -0
- data/lib/lunchmoney/objects/recurring_expense.rb +68 -0
- data/lib/lunchmoney/objects/recurring_expense_base.rb +31 -0
- data/lib/lunchmoney/objects/split.rb +28 -0
- data/lib/lunchmoney/objects/tag.rb +24 -0
- data/lib/lunchmoney/objects/tag_base.rb +23 -0
- data/lib/lunchmoney/objects/transaction.rb +160 -0
- data/lib/lunchmoney/objects/transaction_base.rb +54 -0
- data/lib/lunchmoney/objects/transaction_modification_base.rb +32 -0
- data/lib/lunchmoney/objects/update_transaction.rb +47 -0
- data/lib/lunchmoney/objects/user.rb +38 -0
- data/lib/lunchmoney/version.rb +1 -1
- metadata +32 -32
- data/lib/lunchmoney/api_call.rb +0 -109
- data/lib/lunchmoney/assets/asset.rb +0 -89
- data/lib/lunchmoney/assets/asset_calls.rb +0 -96
- data/lib/lunchmoney/budget/budget.rb +0 -74
- data/lib/lunchmoney/budget/budget_calls.rb +0 -82
- data/lib/lunchmoney/budget/config.rb +0 -38
- data/lib/lunchmoney/budget/data.rb +0 -42
- data/lib/lunchmoney/categories/category/category.rb +0 -52
- data/lib/lunchmoney/categories/category/child_category.rb +0 -42
- data/lib/lunchmoney/categories/category_calls.rb +0 -195
- data/lib/lunchmoney/crypto/crypto/crypto.rb +0 -43
- data/lib/lunchmoney/crypto/crypto/crypto_base.rb +0 -65
- data/lib/lunchmoney/crypto/crypto_calls.rb +0 -49
- data/lib/lunchmoney/data_object.rb +0 -25
- data/lib/lunchmoney/plaid_accounts/plaid_account.rb +0 -73
- data/lib/lunchmoney/plaid_accounts/plaid_account_calls.rb +0 -38
- data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb +0 -65
- data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb +0 -29
- data/lib/lunchmoney/recurring_expenses/recurring_expense_calls.rb +0 -28
- data/lib/lunchmoney/tags/tag/tag.rb +0 -20
- data/lib/lunchmoney/tags/tag/tag_base.rb +0 -21
- data/lib/lunchmoney/tags/tag_calls.rb +0 -20
- data/lib/lunchmoney/transactions/transaction/child_transaction.rb +0 -31
- data/lib/lunchmoney/transactions/transaction/split.rb +0 -24
- data/lib/lunchmoney/transactions/transaction/transaction.rb +0 -156
- data/lib/lunchmoney/transactions/transaction/transaction_base.rb +0 -52
- data/lib/lunchmoney/transactions/transaction/transaction_modification_base.rb +0 -30
- data/lib/lunchmoney/transactions/transaction/update_transaction.rb +0 -43
- data/lib/lunchmoney/transactions/transaction_calls.rb +0 -218
- data/lib/lunchmoney/user/user.rb +0 -36
- data/lib/lunchmoney/user/user_calls.rb +0 -19
@@ -0,0 +1,50 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/crypto"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Calls
|
8
|
+
# https://lunchmoney.dev/#crypto
|
9
|
+
class Crypto < LunchMoney::Calls::Base
|
10
|
+
sig { returns(T.any(T::Array[LunchMoney::Objects::Crypto], LunchMoney::Errors)) }
|
11
|
+
def crypto
|
12
|
+
response = get("crypto")
|
13
|
+
|
14
|
+
api_errors = errors(response)
|
15
|
+
return api_errors if api_errors.present?
|
16
|
+
|
17
|
+
response.body[:crypto].map do |crypto|
|
18
|
+
LunchMoney::Objects::Crypto.new(**crypto)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
sig do
|
23
|
+
params(
|
24
|
+
crypto_id: Integer,
|
25
|
+
name: T.nilable(String),
|
26
|
+
display_name: T.nilable(String),
|
27
|
+
institution_name: T.nilable(String),
|
28
|
+
balance: T.nilable(String),
|
29
|
+
currency: T.nilable(String),
|
30
|
+
).returns(T.any(LunchMoney::Objects::CryptoBase, LunchMoney::Errors))
|
31
|
+
end
|
32
|
+
def update_crypto(crypto_id, name: nil, display_name: nil, institution_name: nil, balance: nil, currency: nil)
|
33
|
+
params = clean_params({
|
34
|
+
name:,
|
35
|
+
display_name:,
|
36
|
+
institution_name:,
|
37
|
+
balance:,
|
38
|
+
currency:,
|
39
|
+
})
|
40
|
+
|
41
|
+
response = put("crypto/manual/#{crypto_id}", params)
|
42
|
+
|
43
|
+
api_errors = errors(response)
|
44
|
+
return api_errors if api_errors.present?
|
45
|
+
|
46
|
+
LunchMoney::Objects::CryptoBase.new(**response.body)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/plaid_account"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Calls
|
8
|
+
# https://lunchmoney.dev/#plaid-accounts
|
9
|
+
class PlaidAccounts < LunchMoney::Calls::Base
|
10
|
+
sig { returns(T.any(T::Array[LunchMoney::Objects::PlaidAccount], LunchMoney::Errors)) }
|
11
|
+
def plaid_accounts
|
12
|
+
response = get("plaid_accounts")
|
13
|
+
|
14
|
+
api_errors = errors(response)
|
15
|
+
return api_errors if api_errors.present?
|
16
|
+
|
17
|
+
response.body[:plaid_accounts].map do |plaid_account|
|
18
|
+
LunchMoney::Objects::PlaidAccount.new(**plaid_account)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
sig do
|
23
|
+
params(
|
24
|
+
start_date: T.nilable(String),
|
25
|
+
end_date: T.nilable(String),
|
26
|
+
plaid_account_id: T.nilable(Integer),
|
27
|
+
).returns(T.any(T::Boolean, LunchMoney::Errors))
|
28
|
+
end
|
29
|
+
def plaid_accounts_fetch(start_date: nil, end_date: nil, plaid_account_id: nil)
|
30
|
+
params = clean_params({ start_date:, end_date:, plaid_account_id: })
|
31
|
+
response = post("plaid_accounts/fetch", params)
|
32
|
+
|
33
|
+
api_errors = errors(response)
|
34
|
+
return api_errors if api_errors.present?
|
35
|
+
|
36
|
+
response.body
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/recurring_expense"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Calls
|
8
|
+
# https://lunchmoney.dev/#recurring-expenses
|
9
|
+
class RecurringExpenses < LunchMoney::Calls::Base
|
10
|
+
sig do
|
11
|
+
params(
|
12
|
+
start_date: T.nilable(String),
|
13
|
+
end_date: T.nilable(String),
|
14
|
+
).returns(T.any(T::Array[LunchMoney::Objects::RecurringExpense], LunchMoney::Errors))
|
15
|
+
end
|
16
|
+
def recurring_expenses(start_date: nil, end_date: nil)
|
17
|
+
params = clean_params({ start_date:, end_date: })
|
18
|
+
response = get("recurring_expenses", query_params: params)
|
19
|
+
|
20
|
+
api_errors = errors(response)
|
21
|
+
return api_errors if api_errors.present?
|
22
|
+
|
23
|
+
response.body[:recurring_expenses].map do |recurring_expense|
|
24
|
+
LunchMoney::Objects::RecurringExpense.new(**recurring_expense)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/tag"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Calls
|
8
|
+
# https://lunchmoney.dev/#tags
|
9
|
+
class Tags < LunchMoney::Calls::Base
|
10
|
+
sig { returns(T.any(T::Array[LunchMoney::Objects::Tag], LunchMoney::Errors)) }
|
11
|
+
def tags
|
12
|
+
response = get("tags")
|
13
|
+
|
14
|
+
api_errors = errors(response)
|
15
|
+
return api_errors if api_errors.present?
|
16
|
+
|
17
|
+
response.body.map { |tag| LunchMoney::Objects::Tag.new(**tag) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/child_transaction"
|
5
|
+
require_relative "../objects/transaction"
|
6
|
+
require_relative "../objects/split"
|
7
|
+
require_relative "../objects/update_transaction"
|
8
|
+
|
9
|
+
module LunchMoney
|
10
|
+
module Calls
|
11
|
+
# https://lunchmoney.dev/#transactions
|
12
|
+
class Transactions < LunchMoney::Calls::Base
|
13
|
+
sig do
|
14
|
+
params(
|
15
|
+
tag_id: T.nilable(Integer),
|
16
|
+
recurring_id: T.nilable(Integer),
|
17
|
+
plaid_account_id: T.nilable(Integer),
|
18
|
+
category_id: T.nilable(Integer),
|
19
|
+
asset_id: T.nilable(Integer),
|
20
|
+
is_group: T.nilable(T::Boolean),
|
21
|
+
status: T.nilable(String),
|
22
|
+
start_date: T.nilable(String),
|
23
|
+
end_date: T.nilable(String),
|
24
|
+
debit_as_negative: T.nilable(T::Boolean),
|
25
|
+
pending: T.nilable(T::Boolean),
|
26
|
+
offset: T.nilable(Integer),
|
27
|
+
limit: T.nilable(Integer),
|
28
|
+
).returns(T.any(T::Array[LunchMoney::Objects::Transaction], LunchMoney::Errors))
|
29
|
+
end
|
30
|
+
def transactions(
|
31
|
+
tag_id: nil,
|
32
|
+
recurring_id: nil,
|
33
|
+
plaid_account_id: nil,
|
34
|
+
category_id: nil,
|
35
|
+
asset_id: nil,
|
36
|
+
is_group: nil,
|
37
|
+
status: nil,
|
38
|
+
start_date: nil,
|
39
|
+
end_date: nil,
|
40
|
+
debit_as_negative: nil,
|
41
|
+
pending: nil,
|
42
|
+
offset: nil,
|
43
|
+
limit: nil
|
44
|
+
)
|
45
|
+
|
46
|
+
params = clean_params({
|
47
|
+
tag_id:,
|
48
|
+
recurring_id:,
|
49
|
+
plaid_account_id:,
|
50
|
+
category_id:,
|
51
|
+
asset_id:,
|
52
|
+
is_group:,
|
53
|
+
status:,
|
54
|
+
start_date:,
|
55
|
+
end_date:,
|
56
|
+
debit_as_negative:,
|
57
|
+
pending:,
|
58
|
+
offset:,
|
59
|
+
limit:,
|
60
|
+
})
|
61
|
+
response = get("transactions", query_params: params)
|
62
|
+
|
63
|
+
api_errors = errors(response)
|
64
|
+
return api_errors if api_errors.present?
|
65
|
+
|
66
|
+
response.body[:transactions].map do |transaction|
|
67
|
+
transaction[:tags].map! { |tag| LunchMoney::Objects::TagBase.new(**tag) }
|
68
|
+
|
69
|
+
transaction[:children]&.map! do |child_transaction|
|
70
|
+
LunchMoney::Objects::ChildTransaction.new(**child_transaction)
|
71
|
+
end
|
72
|
+
|
73
|
+
LunchMoney::Objects::Transaction.new(**transaction)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
sig do
|
78
|
+
params(
|
79
|
+
transaction_id: Integer,
|
80
|
+
debit_as_negative: T.nilable(T::Boolean),
|
81
|
+
).returns(T.any(LunchMoney::Objects::Transaction, LunchMoney::Errors))
|
82
|
+
end
|
83
|
+
def transaction(transaction_id, debit_as_negative: nil)
|
84
|
+
params = clean_params({ debit_as_negative: })
|
85
|
+
response = get("transactions/#{transaction_id}", query_params: params)
|
86
|
+
|
87
|
+
api_errors = errors(response)
|
88
|
+
return api_errors if api_errors.present?
|
89
|
+
|
90
|
+
LunchMoney::Objects::Transaction.new(**response.body)
|
91
|
+
end
|
92
|
+
|
93
|
+
sig do
|
94
|
+
params(
|
95
|
+
transactions: T::Array[LunchMoney::Objects::UpdateTransaction],
|
96
|
+
apply_rules: T.nilable(T::Boolean),
|
97
|
+
skip_duplicates: T.nilable(T::Boolean),
|
98
|
+
check_for_recurring: T.nilable(T::Boolean),
|
99
|
+
debit_as_negative: T.nilable(T::Boolean),
|
100
|
+
skip_balance_update: T.nilable(T::Boolean),
|
101
|
+
).returns(T.any(T::Hash[Symbol, T::Array[Integer]], LunchMoney::Errors))
|
102
|
+
end
|
103
|
+
def insert_transactions(transactions, apply_rules: nil, skip_duplicates: nil,
|
104
|
+
check_for_recurring: nil, debit_as_negative: nil, skip_balance_update: nil)
|
105
|
+
params = clean_params({
|
106
|
+
transactions: transactions.map(&:serialize),
|
107
|
+
apply_rules:,
|
108
|
+
skip_duplicates:,
|
109
|
+
check_for_recurring:,
|
110
|
+
debit_as_negative:,
|
111
|
+
skip_balance_update:,
|
112
|
+
})
|
113
|
+
response = post("transactions", params)
|
114
|
+
|
115
|
+
api_errors = errors(response)
|
116
|
+
return api_errors if api_errors.present?
|
117
|
+
|
118
|
+
response.body
|
119
|
+
end
|
120
|
+
|
121
|
+
sig do
|
122
|
+
params(
|
123
|
+
transaction_id: Integer,
|
124
|
+
transaction: T.nilable(LunchMoney::Objects::UpdateTransaction),
|
125
|
+
split: T.nilable(T::Array[LunchMoney::Objects::Split]),
|
126
|
+
debit_as_negative: T.nilable(T::Boolean),
|
127
|
+
skip_balance_update: T.nilable(T::Boolean),
|
128
|
+
).returns(T.any({ updated: T::Boolean, split: T.nilable(T::Array[Integer]) }, LunchMoney::Errors))
|
129
|
+
end
|
130
|
+
def update_transaction(transaction_id, transaction: nil, split: nil,
|
131
|
+
debit_as_negative: nil, skip_balance_update: nil)
|
132
|
+
raise(
|
133
|
+
LunchMoney::MissingArgument,
|
134
|
+
"Either a transaction or split must be provided",
|
135
|
+
) if transaction.nil? && split.nil?
|
136
|
+
|
137
|
+
params = clean_params({
|
138
|
+
transaction: transaction&.serialize,
|
139
|
+
split: split&.map!(&:serialize),
|
140
|
+
debit_as_negative:,
|
141
|
+
skip_balance_update:,
|
142
|
+
})
|
143
|
+
response = put("transactions/#{transaction_id}", params)
|
144
|
+
|
145
|
+
api_errors = errors(response)
|
146
|
+
return api_errors if api_errors.present?
|
147
|
+
|
148
|
+
response.body
|
149
|
+
end
|
150
|
+
|
151
|
+
sig do
|
152
|
+
params(
|
153
|
+
parent_ids: T::Array[Integer],
|
154
|
+
remove_parents: T.nilable(T::Boolean),
|
155
|
+
).returns(T.any(T::Array[Integer], LunchMoney::Errors))
|
156
|
+
end
|
157
|
+
def unsplit_transaction(parent_ids, remove_parents: false)
|
158
|
+
params = { parent_ids:, remove_parents: }
|
159
|
+
response = post("transactions/unsplit", params)
|
160
|
+
|
161
|
+
api_errors = errors(response)
|
162
|
+
return api_errors if api_errors.present?
|
163
|
+
|
164
|
+
response.body
|
165
|
+
end
|
166
|
+
|
167
|
+
sig { params(transaction_id: Integer).returns(T.any(LunchMoney::Objects::Transaction, LunchMoney::Errors)) }
|
168
|
+
def transaction_group(transaction_id)
|
169
|
+
response = get("transactions/group", query_params: { transaction_id: })
|
170
|
+
|
171
|
+
api_errors = errors(response)
|
172
|
+
return api_errors if api_errors.present?
|
173
|
+
|
174
|
+
LunchMoney::Objects::Transaction.new(**response.body)
|
175
|
+
end
|
176
|
+
|
177
|
+
sig do
|
178
|
+
params(
|
179
|
+
date: String,
|
180
|
+
payee: String,
|
181
|
+
transactions: T::Array[T.any(Integer, String)],
|
182
|
+
category_id: T.nilable(Integer),
|
183
|
+
notes: T.nilable(String),
|
184
|
+
tags: T.nilable(T::Array[T.any(Integer, String)]),
|
185
|
+
).returns(T.any(Integer, LunchMoney::Errors))
|
186
|
+
end
|
187
|
+
def create_transaction_group(date:, payee:, transactions:, category_id: nil, notes: nil, tags: nil)
|
188
|
+
params = clean_params({
|
189
|
+
date:,
|
190
|
+
payee:,
|
191
|
+
transactions:,
|
192
|
+
category_id:,
|
193
|
+
notes:,
|
194
|
+
tags:,
|
195
|
+
})
|
196
|
+
response = post("transactions/group", params)
|
197
|
+
|
198
|
+
api_errors = errors(response)
|
199
|
+
return api_errors if api_errors.present?
|
200
|
+
|
201
|
+
response.body
|
202
|
+
end
|
203
|
+
|
204
|
+
sig do
|
205
|
+
params(transaction_id: T.any(
|
206
|
+
String,
|
207
|
+
Integer,
|
208
|
+
)).returns(T.any(T::Hash[Symbol, T::Array[Integer]], LunchMoney::Errors))
|
209
|
+
end
|
210
|
+
def delete_transaction_group(transaction_id)
|
211
|
+
response = delete("transactions/group/#{transaction_id}")
|
212
|
+
|
213
|
+
api_errors = errors(response)
|
214
|
+
return api_errors if api_errors.present?
|
215
|
+
|
216
|
+
response.body
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../objects/user"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Calls
|
8
|
+
# https://lunchmoney.dev/#user
|
9
|
+
class Users < LunchMoney::Calls::Base
|
10
|
+
sig { returns(T.any(LunchMoney::Objects::User, LunchMoney::Errors)) }
|
11
|
+
def me
|
12
|
+
response = get("me")
|
13
|
+
|
14
|
+
api_errors = errors(response)
|
15
|
+
return api_errors if api_errors.present?
|
16
|
+
|
17
|
+
LunchMoney::Objects::User.new(**response.body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module LunchMoney
|
5
|
+
module Objects
|
6
|
+
# https://lunchmoney.dev/#assets-object
|
7
|
+
class Asset < LunchMoney::Objects::Object
|
8
|
+
include LunchMoney::Validators
|
9
|
+
|
10
|
+
sig { returns(Integer) }
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
sig { returns(String) }
|
14
|
+
attr_reader :type_name, :balance_as_of, :created_at
|
15
|
+
|
16
|
+
sig { returns(String) }
|
17
|
+
attr_accessor :name, :balance, :currency
|
18
|
+
|
19
|
+
sig { returns(T.nilable(String)) }
|
20
|
+
attr_accessor :display_name, :closed_on, :institution_name, :subtype_name
|
21
|
+
|
22
|
+
sig { returns(T::Boolean) }
|
23
|
+
attr_accessor :exclude_transactions
|
24
|
+
|
25
|
+
# Valid asset type names
|
26
|
+
VALID_TYPE_NAMES = T.let(
|
27
|
+
[
|
28
|
+
"cash",
|
29
|
+
"credit",
|
30
|
+
"investment",
|
31
|
+
"real estate",
|
32
|
+
"loan",
|
33
|
+
"vehicle",
|
34
|
+
"cryptocurrency",
|
35
|
+
"employee compensation",
|
36
|
+
"other liability",
|
37
|
+
"other asset",
|
38
|
+
],
|
39
|
+
T::Array[String],
|
40
|
+
)
|
41
|
+
|
42
|
+
sig do
|
43
|
+
params(
|
44
|
+
created_at: String,
|
45
|
+
type_name: String,
|
46
|
+
name: String,
|
47
|
+
balance: String,
|
48
|
+
balance_as_of: String,
|
49
|
+
currency: String,
|
50
|
+
exclude_transactions: T::Boolean,
|
51
|
+
id: Integer,
|
52
|
+
subtype_name: T.nilable(String),
|
53
|
+
display_name: T.nilable(String),
|
54
|
+
closed_on: T.nilable(String),
|
55
|
+
institution_name: T.nilable(String),
|
56
|
+
).void
|
57
|
+
end
|
58
|
+
def initialize(created_at:, type_name:, name:, balance:, balance_as_of:, currency:, exclude_transactions:, id:,
|
59
|
+
subtype_name: nil, display_name: nil, closed_on: nil, institution_name: nil)
|
60
|
+
super()
|
61
|
+
@created_at = T.let(validate_iso8601!(created_at), String)
|
62
|
+
@type_name = T.let(validate_one_of!(type_name, VALID_TYPE_NAMES), String)
|
63
|
+
@name = name
|
64
|
+
@balance = balance
|
65
|
+
@balance_as_of = T.let(validate_iso8601!(balance_as_of), String)
|
66
|
+
@currency = currency
|
67
|
+
@exclude_transactions = exclude_transactions
|
68
|
+
@id = id
|
69
|
+
@subtype_name = subtype_name
|
70
|
+
@display_name = display_name
|
71
|
+
@closed_on = closed_on
|
72
|
+
@institution_name = institution_name
|
73
|
+
end
|
74
|
+
|
75
|
+
sig { params(name: String).void }
|
76
|
+
def type_name=(name)
|
77
|
+
@type_name = validate_one_of!(name, VALID_TYPE_NAMES)
|
78
|
+
end
|
79
|
+
|
80
|
+
sig { params(time: String).void }
|
81
|
+
def balance_as_of=(time)
|
82
|
+
@balance_as_of = validate_iso8601!(time)
|
83
|
+
end
|
84
|
+
|
85
|
+
sig { params(time: String).void }
|
86
|
+
def created_at=(time)
|
87
|
+
@created_at = validate_iso8601!(time)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "data"
|
5
|
+
require_relative "config"
|
6
|
+
|
7
|
+
module LunchMoney
|
8
|
+
module Objects
|
9
|
+
# https://lunchmoney.dev/#budget-object
|
10
|
+
class Budget < LunchMoney::Objects::Object
|
11
|
+
# API object reference documentation: https://lunchmoney.dev/#budget-object
|
12
|
+
|
13
|
+
sig { returns(String) }
|
14
|
+
attr_accessor :category_name
|
15
|
+
|
16
|
+
sig { returns(Integer) }
|
17
|
+
attr_accessor :order
|
18
|
+
|
19
|
+
sig { returns(T.nilable(String)) }
|
20
|
+
attr_accessor :category_group_name
|
21
|
+
|
22
|
+
sig { returns(T.nilable(Integer)) }
|
23
|
+
attr_accessor :category_id, :group_id
|
24
|
+
|
25
|
+
sig { returns(T.nilable(T::Boolean)) }
|
26
|
+
attr_accessor :is_group
|
27
|
+
|
28
|
+
sig { returns(T::Boolean) }
|
29
|
+
attr_accessor :is_income, :exclude_from_budget, :exclude_from_totals, :archived
|
30
|
+
|
31
|
+
sig { returns(T::Hash[Symbol, LunchMoney::Objects::Data]) }
|
32
|
+
attr_accessor :data
|
33
|
+
|
34
|
+
sig { returns(T.nilable(T::Hash[Symbol, LunchMoney::Objects::Config])) }
|
35
|
+
attr_accessor :config
|
36
|
+
|
37
|
+
sig { returns(T.nilable({ list: T::Array[LunchMoney::Objects::RecurringExpense] })) }
|
38
|
+
attr_accessor :recurring
|
39
|
+
|
40
|
+
sig do
|
41
|
+
params(
|
42
|
+
is_income: T::Boolean,
|
43
|
+
exclude_from_budget: T::Boolean,
|
44
|
+
exclude_from_totals: T::Boolean,
|
45
|
+
data: T::Hash[Symbol, LunchMoney::Objects::Data],
|
46
|
+
category_name: String,
|
47
|
+
order: Integer,
|
48
|
+
archived: T::Boolean,
|
49
|
+
category_id: T.nilable(Integer),
|
50
|
+
category_group_name: T.nilable(String),
|
51
|
+
group_id: T.nilable(Integer),
|
52
|
+
is_group: T.nilable(T::Boolean),
|
53
|
+
config: T.nilable(T::Hash[Symbol, LunchMoney::Objects::Config]),
|
54
|
+
recurring: T.nilable({ list: T::Array[LunchMoney::Objects::RecurringExpense] }),
|
55
|
+
).void
|
56
|
+
end
|
57
|
+
def initialize(is_income:, exclude_from_budget:, exclude_from_totals:, data:, category_name:, order:, archived:,
|
58
|
+
category_id: nil, category_group_name: nil, group_id: nil, is_group: nil, config: nil, recurring: nil)
|
59
|
+
super()
|
60
|
+
@category_id = category_id
|
61
|
+
@is_income = is_income
|
62
|
+
@exclude_from_budget = exclude_from_budget
|
63
|
+
@exclude_from_totals = exclude_from_totals
|
64
|
+
@data = data
|
65
|
+
@category_name = category_name
|
66
|
+
@order = order
|
67
|
+
@category_group_name = category_group_name
|
68
|
+
@group_id = group_id
|
69
|
+
@is_group = is_group
|
70
|
+
@config = config
|
71
|
+
@archived = archived
|
72
|
+
@recurring = recurring
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "child_category"
|
5
|
+
module LunchMoney
|
6
|
+
module Objects
|
7
|
+
# https://lunchmoney.dev/#categories-object
|
8
|
+
class Category < ChildCategory
|
9
|
+
sig { returns(T.nilable(String)) }
|
10
|
+
attr_accessor :group_category_name
|
11
|
+
|
12
|
+
sig { returns(T::Boolean) }
|
13
|
+
attr_accessor :is_income, :exclude_from_budget, :exclude_from_totals, :is_group
|
14
|
+
|
15
|
+
sig { returns(T.nilable(Integer)) }
|
16
|
+
attr_accessor :group_id, :order
|
17
|
+
|
18
|
+
sig { returns(T.nilable(T::Array[T.any(LunchMoney::Objects::Category, LunchMoney::Objects::ChildCategory)])) }
|
19
|
+
attr_accessor :children
|
20
|
+
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
id: Integer,
|
24
|
+
name: String,
|
25
|
+
is_income: T::Boolean,
|
26
|
+
exclude_from_budget: T::Boolean,
|
27
|
+
exclude_from_totals: T::Boolean,
|
28
|
+
is_group: T::Boolean,
|
29
|
+
archived: T.nilable(T::Boolean),
|
30
|
+
archived_on: T.nilable(String),
|
31
|
+
updated_at: T.nilable(String),
|
32
|
+
created_at: T.nilable(String),
|
33
|
+
group_id: T.nilable(Integer),
|
34
|
+
order: T.nilable(Integer),
|
35
|
+
description: T.nilable(String),
|
36
|
+
children: T.nilable(T::Array[T.any(LunchMoney::Objects::Category, LunchMoney::Objects::ChildCategory)]),
|
37
|
+
group_category_name: T.nilable(String),
|
38
|
+
).void
|
39
|
+
end
|
40
|
+
def initialize(id:, name:, is_income:, exclude_from_budget:, exclude_from_totals:, is_group:, archived: nil,
|
41
|
+
archived_on: nil, updated_at: nil, created_at: nil, group_id: nil, order: nil, description: nil, children: nil,
|
42
|
+
group_category_name: nil)
|
43
|
+
super(id:, name:, archived:, archived_on:, updated_at:, created_at:, description:)
|
44
|
+
@is_income = is_income
|
45
|
+
@exclude_from_budget = exclude_from_budget
|
46
|
+
@exclude_from_totals = exclude_from_totals
|
47
|
+
@is_group = is_group
|
48
|
+
@group_id = group_id
|
49
|
+
@order = order
|
50
|
+
@children = children
|
51
|
+
@group_category_name = group_category_name
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module LunchMoney
|
5
|
+
module Objects
|
6
|
+
# A slimmed down version of https://lunchmoney.dev/#categories-object used in the
|
7
|
+
# `children` field of some category calls
|
8
|
+
class ChildCategory < LunchMoney::Objects::Object
|
9
|
+
sig { returns(Integer) }
|
10
|
+
attr_accessor :id
|
11
|
+
|
12
|
+
sig { returns(String) }
|
13
|
+
attr_accessor :name
|
14
|
+
|
15
|
+
sig { returns(T.nilable(String)) }
|
16
|
+
attr_accessor :description, :archived_on, :updated_at, :created_at
|
17
|
+
|
18
|
+
sig { returns(T.nilable(T::Boolean)) }
|
19
|
+
attr_accessor :archived
|
20
|
+
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
id: Integer,
|
24
|
+
name: String,
|
25
|
+
archived: T.nilable(T::Boolean),
|
26
|
+
archived_on: T.nilable(String),
|
27
|
+
updated_at: T.nilable(String),
|
28
|
+
created_at: T.nilable(String),
|
29
|
+
description: T.nilable(String),
|
30
|
+
).void
|
31
|
+
end
|
32
|
+
def initialize(id:, name:, archived: nil, archived_on: nil, updated_at: nil, created_at: nil, description: nil)
|
33
|
+
super()
|
34
|
+
@id = id
|
35
|
+
@name = name
|
36
|
+
@archived = archived
|
37
|
+
@archived_on = archived_on
|
38
|
+
@updated_at = updated_at
|
39
|
+
@created_at = created_at
|
40
|
+
@description = description
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "transaction_base"
|
5
|
+
|
6
|
+
module LunchMoney
|
7
|
+
module Objects
|
8
|
+
# Slimmed down version of https://lunchmoney.dev/#transaction-object used in the
|
9
|
+
# `children` field of a transaction object with an additional `formatted_date`` field
|
10
|
+
class ChildTransaction < TransactionBase
|
11
|
+
sig { returns(String) }
|
12
|
+
attr_accessor :formatted_date
|
13
|
+
|
14
|
+
sig do
|
15
|
+
params(
|
16
|
+
id: Integer,
|
17
|
+
date: String,
|
18
|
+
amount: String,
|
19
|
+
currency: String,
|
20
|
+
to_base: Number,
|
21
|
+
payee: String,
|
22
|
+
formatted_date: String,
|
23
|
+
notes: T.nilable(String),
|
24
|
+
asset_id: T.nilable(Integer),
|
25
|
+
plaid_account_id: T.nilable(Integer),
|
26
|
+
).void
|
27
|
+
end
|
28
|
+
def initialize(id:, date:, amount:, currency:, to_base:, payee:, formatted_date:, notes: nil, asset_id: nil,
|
29
|
+
plaid_account_id: nil)
|
30
|
+
super(id:, date:, amount:, currency:, to_base:, payee:, notes:, asset_id:, plaid_account_id:)
|
31
|
+
@formatted_date = formatted_date
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|