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
@@ -1,38 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#config-object
|
6
|
-
class Config < LunchMoney::DataObject
|
7
|
-
# API object reference documentation: https://lunchmoney.dev/#config-object
|
8
|
-
|
9
|
-
sig { returns(Integer) }
|
10
|
-
attr_accessor :config_id
|
11
|
-
|
12
|
-
sig { returns(Number) }
|
13
|
-
attr_accessor :amount, :to_base
|
14
|
-
|
15
|
-
sig { returns(String) }
|
16
|
-
attr_accessor :cadence, :currency, :auto_suggest
|
17
|
-
|
18
|
-
sig do
|
19
|
-
params(
|
20
|
-
config_id: Integer,
|
21
|
-
cadence: String,
|
22
|
-
amount: Number,
|
23
|
-
currency: String,
|
24
|
-
to_base: Number,
|
25
|
-
auto_suggest: String,
|
26
|
-
).void
|
27
|
-
end
|
28
|
-
def initialize(config_id:, cadence:, amount:, currency:, to_base:, auto_suggest:)
|
29
|
-
super()
|
30
|
-
@config_id = config_id
|
31
|
-
@cadence = cadence
|
32
|
-
@amount = amount
|
33
|
-
@currency = currency
|
34
|
-
@to_base = to_base
|
35
|
-
@auto_suggest = auto_suggest
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#data-object
|
6
|
-
class Data < LunchMoney::DataObject
|
7
|
-
# API object reference documentation: https://lunchmoney.dev/#data-object
|
8
|
-
|
9
|
-
sig { returns(T.nilable(Integer)) }
|
10
|
-
attr_accessor :num_transactions
|
11
|
-
|
12
|
-
sig { returns(T.nilable(Number)) }
|
13
|
-
attr_accessor :budget_amount, :budget_to_base, :spending_to_base
|
14
|
-
|
15
|
-
sig { returns(T.nilable(String)) }
|
16
|
-
attr_accessor :budget_currency
|
17
|
-
|
18
|
-
sig { returns(T.nilable(T::Boolean)) }
|
19
|
-
attr_accessor :is_automated
|
20
|
-
|
21
|
-
sig do
|
22
|
-
params(
|
23
|
-
spending_to_base: T.nilable(Number),
|
24
|
-
num_transactions: T.nilable(Integer),
|
25
|
-
budget_amount: T.nilable(Number),
|
26
|
-
budget_currency: T.nilable(String),
|
27
|
-
budget_to_base: T.nilable(Number),
|
28
|
-
is_automated: T.nilable(T::Boolean),
|
29
|
-
).void
|
30
|
-
end
|
31
|
-
def initialize(spending_to_base: nil, num_transactions: nil, budget_amount: nil, budget_currency: nil,
|
32
|
-
budget_to_base: nil, is_automated: nil)
|
33
|
-
super()
|
34
|
-
@budget_amount = budget_amount
|
35
|
-
@budget_currency = budget_currency
|
36
|
-
@budget_to_base = budget_to_base
|
37
|
-
@spending_to_base = spending_to_base
|
38
|
-
@num_transactions = num_transactions
|
39
|
-
@is_automated = is_automated
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#categories-object
|
6
|
-
class Category < ChildCategory
|
7
|
-
sig { returns(T.nilable(String)) }
|
8
|
-
attr_accessor :group_category_name
|
9
|
-
|
10
|
-
sig { returns(T::Boolean) }
|
11
|
-
attr_accessor :is_income, :exclude_from_budget, :exclude_from_totals, :is_group
|
12
|
-
|
13
|
-
sig { returns(T.nilable(Integer)) }
|
14
|
-
attr_accessor :group_id, :order
|
15
|
-
|
16
|
-
sig { returns(T.nilable(T::Array[T.any(LunchMoney::Category, LunchMoney::ChildCategory)])) }
|
17
|
-
attr_accessor :children
|
18
|
-
|
19
|
-
sig do
|
20
|
-
params(
|
21
|
-
id: Integer,
|
22
|
-
name: String,
|
23
|
-
is_income: T::Boolean,
|
24
|
-
exclude_from_budget: T::Boolean,
|
25
|
-
exclude_from_totals: T::Boolean,
|
26
|
-
is_group: T::Boolean,
|
27
|
-
archived: T.nilable(T::Boolean),
|
28
|
-
archived_on: T.nilable(String),
|
29
|
-
updated_at: T.nilable(String),
|
30
|
-
created_at: T.nilable(String),
|
31
|
-
group_id: T.nilable(Integer),
|
32
|
-
order: T.nilable(Integer),
|
33
|
-
description: T.nilable(String),
|
34
|
-
children: T.nilable(T::Array[T.any(LunchMoney::Category, LunchMoney::ChildCategory)]),
|
35
|
-
group_category_name: T.nilable(String),
|
36
|
-
).void
|
37
|
-
end
|
38
|
-
def initialize(id:, name:, is_income:, exclude_from_budget:, exclude_from_totals:, is_group:, archived: nil,
|
39
|
-
archived_on: nil, updated_at: nil, created_at: nil, group_id: nil, order: nil, description: nil, children: nil,
|
40
|
-
group_category_name: nil)
|
41
|
-
super(id:, name:, archived:, archived_on:, updated_at:, created_at:, description:)
|
42
|
-
@is_income = is_income
|
43
|
-
@exclude_from_budget = exclude_from_budget
|
44
|
-
@exclude_from_totals = exclude_from_totals
|
45
|
-
@is_group = is_group
|
46
|
-
@group_id = group_id
|
47
|
-
@order = order
|
48
|
-
@children = children
|
49
|
-
@group_category_name = group_category_name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# A slimmed down version of https://lunchmoney.dev/#categories-object used in the
|
6
|
-
# `children` field of some category calls
|
7
|
-
class ChildCategory < LunchMoney::DataObject
|
8
|
-
sig { returns(Integer) }
|
9
|
-
attr_accessor :id
|
10
|
-
|
11
|
-
sig { returns(String) }
|
12
|
-
attr_accessor :name
|
13
|
-
|
14
|
-
sig { returns(T.nilable(String)) }
|
15
|
-
attr_accessor :description, :archived_on, :updated_at, :created_at
|
16
|
-
|
17
|
-
sig { returns(T.nilable(T::Boolean)) }
|
18
|
-
attr_accessor :archived
|
19
|
-
|
20
|
-
sig do
|
21
|
-
params(
|
22
|
-
id: Integer,
|
23
|
-
name: String,
|
24
|
-
archived: T.nilable(T::Boolean),
|
25
|
-
archived_on: T.nilable(String),
|
26
|
-
updated_at: T.nilable(String),
|
27
|
-
created_at: T.nilable(String),
|
28
|
-
description: T.nilable(String),
|
29
|
-
).void
|
30
|
-
end
|
31
|
-
def initialize(id:, name:, archived: nil, archived_on: nil, updated_at: nil, created_at: nil, description: nil)
|
32
|
-
super()
|
33
|
-
@id = id
|
34
|
-
@name = name
|
35
|
-
@archived = archived
|
36
|
-
@archived_on = archived_on
|
37
|
-
@updated_at = updated_at
|
38
|
-
@created_at = created_at
|
39
|
-
@description = description
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,195 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative "category/child_category"
|
5
|
-
require_relative "category/category"
|
6
|
-
|
7
|
-
module LunchMoney
|
8
|
-
# https://lunchmoney.dev/#categories
|
9
|
-
class CategoryCalls < ApiCall
|
10
|
-
# Valid query parameter formets for categories
|
11
|
-
VALID_FORMATS = T.let(
|
12
|
-
[
|
13
|
-
"flattened",
|
14
|
-
"nested",
|
15
|
-
],
|
16
|
-
T::Array[String],
|
17
|
-
)
|
18
|
-
|
19
|
-
sig do
|
20
|
-
params(
|
21
|
-
format: T.nilable(T.any(String, Symbol)),
|
22
|
-
).returns(T.any(T::Array[LunchMoney::Category], LunchMoney::Errors))
|
23
|
-
end
|
24
|
-
def categories(format: nil)
|
25
|
-
response = get("categories", query_params: categories_params(format:))
|
26
|
-
|
27
|
-
api_errors = errors(response)
|
28
|
-
return api_errors if api_errors.present?
|
29
|
-
|
30
|
-
response.body[:categories].map do |category|
|
31
|
-
category[:children]&.map! { |child_category| LunchMoney::Category.new(**child_category) }
|
32
|
-
|
33
|
-
LunchMoney::Category.new(**category)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
sig { params(category_id: Integer).returns(T.any(LunchMoney::Category, LunchMoney::Errors)) }
|
38
|
-
def category(category_id)
|
39
|
-
response = get("categories/#{category_id}")
|
40
|
-
|
41
|
-
api_errors = errors(response)
|
42
|
-
return api_errors if api_errors.present?
|
43
|
-
|
44
|
-
response.body[:children]&.map! { |child_category| LunchMoney::ChildCategory.new(**child_category) }
|
45
|
-
|
46
|
-
LunchMoney::Category.new(**response.body)
|
47
|
-
end
|
48
|
-
|
49
|
-
sig do
|
50
|
-
params(
|
51
|
-
name: String,
|
52
|
-
description: T.nilable(String),
|
53
|
-
is_income: T::Boolean,
|
54
|
-
exclude_from_budget: T::Boolean,
|
55
|
-
exclude_from_totals: T::Boolean,
|
56
|
-
archived: T::Boolean,
|
57
|
-
group_id: T.nilable(Integer),
|
58
|
-
).returns(T.any(T::Hash[Symbol, Integer], LunchMoney::Errors))
|
59
|
-
end
|
60
|
-
def create_category(name:, description: nil, is_income: false, exclude_from_budget: false,
|
61
|
-
exclude_from_totals: false, archived: false, group_id: nil)
|
62
|
-
params = clean_params({
|
63
|
-
name:,
|
64
|
-
description:,
|
65
|
-
is_income:,
|
66
|
-
exclude_from_budget:,
|
67
|
-
exclude_from_totals:,
|
68
|
-
archived:,
|
69
|
-
group_id:,
|
70
|
-
})
|
71
|
-
response = post("categories", params)
|
72
|
-
|
73
|
-
api_errors = errors(response)
|
74
|
-
return api_errors if api_errors.present?
|
75
|
-
|
76
|
-
response.body
|
77
|
-
end
|
78
|
-
|
79
|
-
sig do
|
80
|
-
params(
|
81
|
-
name: String,
|
82
|
-
description: T.nilable(String),
|
83
|
-
is_income: T::Boolean,
|
84
|
-
exclude_from_budget: T::Boolean,
|
85
|
-
exclude_from_totals: T::Boolean,
|
86
|
-
category_ids: T::Array[Integer],
|
87
|
-
new_categories: T::Array[String],
|
88
|
-
).returns(T.any(T::Hash[Symbol, Integer], LunchMoney::Errors))
|
89
|
-
end
|
90
|
-
def create_category_group(name:, description: nil, is_income: false, exclude_from_budget: false,
|
91
|
-
exclude_from_totals: false, category_ids: [], new_categories: [])
|
92
|
-
|
93
|
-
params = {
|
94
|
-
name:,
|
95
|
-
description:,
|
96
|
-
is_income:,
|
97
|
-
exclude_from_budget:,
|
98
|
-
exclude_from_totals:,
|
99
|
-
category_ids:,
|
100
|
-
new_categories:,
|
101
|
-
}
|
102
|
-
|
103
|
-
response = post("categories/group", params)
|
104
|
-
|
105
|
-
api_errors = errors(response)
|
106
|
-
return api_errors if api_errors.present?
|
107
|
-
|
108
|
-
response.body
|
109
|
-
end
|
110
|
-
|
111
|
-
sig do
|
112
|
-
params(
|
113
|
-
category_id: Integer,
|
114
|
-
name: T.nilable(String),
|
115
|
-
description: T.nilable(String),
|
116
|
-
is_income: T.nilable(T::Boolean),
|
117
|
-
exclude_from_budget: T.nilable(T::Boolean),
|
118
|
-
exclude_from_totals: T.nilable(T::Boolean),
|
119
|
-
archived: T.nilable(T::Boolean),
|
120
|
-
group_id: T.nilable(Integer),
|
121
|
-
).returns(T.any(T::Boolean, LunchMoney::Errors))
|
122
|
-
end
|
123
|
-
def update_category(category_id, name: nil, description: nil, is_income: nil, exclude_from_budget: nil,
|
124
|
-
exclude_from_totals: nil, archived: nil, group_id: nil)
|
125
|
-
|
126
|
-
params = clean_params({
|
127
|
-
name:,
|
128
|
-
description:,
|
129
|
-
is_income:,
|
130
|
-
exclude_from_budget:,
|
131
|
-
exclude_from_totals:,
|
132
|
-
archived:,
|
133
|
-
group_id:,
|
134
|
-
})
|
135
|
-
response = put("categories/#{category_id}", params)
|
136
|
-
|
137
|
-
api_errors = errors(response)
|
138
|
-
return api_errors if api_errors.present?
|
139
|
-
|
140
|
-
response.body
|
141
|
-
end
|
142
|
-
|
143
|
-
sig do
|
144
|
-
params(
|
145
|
-
group_id: Integer,
|
146
|
-
category_ids: T::Array[Integer],
|
147
|
-
new_categories: T::Array[String],
|
148
|
-
).returns(T.any(LunchMoney::Category, LunchMoney::Errors))
|
149
|
-
end
|
150
|
-
def add_to_category_group(group_id, category_ids: [], new_categories: [])
|
151
|
-
params = {
|
152
|
-
category_ids:,
|
153
|
-
new_categories:,
|
154
|
-
}
|
155
|
-
|
156
|
-
response = post("categories/group/#{group_id}/add", params)
|
157
|
-
|
158
|
-
api_errors = errors(response)
|
159
|
-
return api_errors if api_errors.present?
|
160
|
-
|
161
|
-
LunchMoney::Category.new(**response.body)
|
162
|
-
end
|
163
|
-
|
164
|
-
sig { params(category_id: Integer).returns(T.any(T::Boolean, LunchMoney::Errors)) }
|
165
|
-
def delete_category(category_id)
|
166
|
-
response = delete("categories/#{category_id}")
|
167
|
-
|
168
|
-
api_errors = errors(response)
|
169
|
-
return api_errors if api_errors.present?
|
170
|
-
|
171
|
-
response.body
|
172
|
-
end
|
173
|
-
|
174
|
-
sig { params(category_id: Integer).returns(T.any(T::Boolean, LunchMoney::Errors)) }
|
175
|
-
def force_delete_category(category_id)
|
176
|
-
response = delete("categories/#{category_id}/force")
|
177
|
-
|
178
|
-
api_errors = errors(response)
|
179
|
-
return api_errors if api_errors.present?
|
180
|
-
|
181
|
-
response.body
|
182
|
-
end
|
183
|
-
|
184
|
-
private
|
185
|
-
|
186
|
-
sig { params(format: T.nilable(T.any(String, Symbol))).returns(T.nilable(T::Hash[Symbol, String])) }
|
187
|
-
def categories_params(format:)
|
188
|
-
return unless format
|
189
|
-
|
190
|
-
raise(InvalidQueryParameter, "format must be either flattened or nested") if VALID_FORMATS.exclude?(format.to_s)
|
191
|
-
|
192
|
-
{ format: format.to_s }
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#crypto-object
|
6
|
-
class Crypto < CryptoBase
|
7
|
-
include LunchMoney::Validators
|
8
|
-
|
9
|
-
sig { returns(String) }
|
10
|
-
attr_reader :balance_as_of
|
11
|
-
|
12
|
-
sig { returns(String) }
|
13
|
-
attr_accessor :currency, :status
|
14
|
-
|
15
|
-
sig do
|
16
|
-
params(
|
17
|
-
created_at: String,
|
18
|
-
source: String,
|
19
|
-
name: String,
|
20
|
-
balance: String,
|
21
|
-
balance_as_of: String,
|
22
|
-
currency: String,
|
23
|
-
status: String,
|
24
|
-
institution_name: T.nilable(String),
|
25
|
-
id: T.nilable(Integer),
|
26
|
-
zabo_account_id: T.nilable(Integer),
|
27
|
-
display_name: T.nilable(String),
|
28
|
-
).void
|
29
|
-
end
|
30
|
-
def initialize(created_at:, source:, name:, balance:, balance_as_of:, currency:,
|
31
|
-
status:, institution_name: nil, id: nil, zabo_account_id: nil, display_name: nil)
|
32
|
-
super(created_at:, source:, name:, balance:, institution_name:, id:, zabo_account_id:, display_name:)
|
33
|
-
@balance_as_of = T.let(validate_iso8601!(balance_as_of), String)
|
34
|
-
@currency = currency
|
35
|
-
@status = status
|
36
|
-
end
|
37
|
-
|
38
|
-
sig { params(time: String).void }
|
39
|
-
def balance_as_of=(time)
|
40
|
-
@balance_as_of = validate_iso8601!(time)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#crypto-object
|
6
|
-
class CryptoBase < LunchMoney::DataObject
|
7
|
-
include LunchMoney::Validators
|
8
|
-
|
9
|
-
sig { returns(T.nilable(Integer)) }
|
10
|
-
attr_accessor :id, :zabo_account_id
|
11
|
-
|
12
|
-
sig { returns(String) }
|
13
|
-
attr_reader :source, :created_at
|
14
|
-
|
15
|
-
sig { returns(String) }
|
16
|
-
attr_accessor :name, :balance
|
17
|
-
|
18
|
-
sig { returns(T.nilable(String)) }
|
19
|
-
attr_accessor :display_name, :institution_name
|
20
|
-
|
21
|
-
# Valid crypto source types
|
22
|
-
VALID_SOURCES = T.let(
|
23
|
-
[
|
24
|
-
"synced",
|
25
|
-
"manual",
|
26
|
-
],
|
27
|
-
T::Array[String],
|
28
|
-
)
|
29
|
-
|
30
|
-
sig do
|
31
|
-
params(
|
32
|
-
created_at: String,
|
33
|
-
source: String,
|
34
|
-
name: String,
|
35
|
-
balance: String,
|
36
|
-
institution_name: T.nilable(String),
|
37
|
-
id: T.nilable(Integer),
|
38
|
-
zabo_account_id: T.nilable(Integer),
|
39
|
-
display_name: T.nilable(String),
|
40
|
-
).void
|
41
|
-
end
|
42
|
-
def initialize(created_at:, source:, name:, balance:, institution_name: nil, id: nil, zabo_account_id: nil,
|
43
|
-
display_name: nil)
|
44
|
-
super()
|
45
|
-
@created_at = T.let(validate_iso8601!(created_at), String)
|
46
|
-
@source = T.let(validate_one_of!(source, VALID_SOURCES), String)
|
47
|
-
@name = name
|
48
|
-
@balance = balance
|
49
|
-
@institution_name = institution_name
|
50
|
-
@id = id
|
51
|
-
@zabo_account_id = zabo_account_id
|
52
|
-
@display_name = display_name
|
53
|
-
end
|
54
|
-
|
55
|
-
sig { params(name: String).void }
|
56
|
-
def source=(name)
|
57
|
-
@source = validate_one_of!(name, VALID_SOURCES)
|
58
|
-
end
|
59
|
-
|
60
|
-
sig { params(time: String).void }
|
61
|
-
def created_at=(time)
|
62
|
-
@created_at = validate_iso8601!(time)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative "crypto/crypto_base"
|
5
|
-
require_relative "crypto/crypto"
|
6
|
-
|
7
|
-
module LunchMoney
|
8
|
-
# https://lunchmoney.dev/#crypto
|
9
|
-
class CryptoCalls < ApiCall
|
10
|
-
sig { returns(T.any(T::Array[LunchMoney::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::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::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::CryptoBase.new(**response.body)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# Base data object for the objects returned and used when calling the LunchMoney API
|
6
|
-
class DataObject
|
7
|
-
sig { params(symbolize_keys: T::Boolean).returns(T::Hash[String, T.untyped]) }
|
8
|
-
def serialize(symbolize_keys: false)
|
9
|
-
ivars = instance_variables
|
10
|
-
|
11
|
-
output = {}
|
12
|
-
|
13
|
-
ivars.each do |ivar|
|
14
|
-
key = ivar.to_s.gsub("@", "")
|
15
|
-
key = key.to_sym if symbolize_keys
|
16
|
-
|
17
|
-
value = instance_variable_get(ivar)
|
18
|
-
|
19
|
-
output[key] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
output
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module LunchMoney
|
5
|
-
# https://lunchmoney.dev/#plaid-accounts-object
|
6
|
-
class PlaidAccount < LunchMoney::DataObject
|
7
|
-
sig { returns(Integer) }
|
8
|
-
attr_accessor :id
|
9
|
-
|
10
|
-
sig { returns(String) }
|
11
|
-
attr_accessor :date_linked,
|
12
|
-
:name,
|
13
|
-
:type,
|
14
|
-
:mask,
|
15
|
-
:institution_name,
|
16
|
-
:status,
|
17
|
-
:balance,
|
18
|
-
:currency,
|
19
|
-
:balance_last_update,
|
20
|
-
:display_name,
|
21
|
-
:plaid_last_successful_update
|
22
|
-
|
23
|
-
sig { returns(T.nilable(String)) }
|
24
|
-
attr_accessor :subtype, :import_start_date, :last_fetch, :last_import
|
25
|
-
|
26
|
-
sig { returns(T.nilable(Integer)) }
|
27
|
-
attr_accessor :limit
|
28
|
-
|
29
|
-
sig do
|
30
|
-
params(
|
31
|
-
date_linked: String,
|
32
|
-
name: String,
|
33
|
-
type: String,
|
34
|
-
mask: String,
|
35
|
-
institution_name: String,
|
36
|
-
status: String,
|
37
|
-
balance: String,
|
38
|
-
currency: String,
|
39
|
-
balance_last_update: String,
|
40
|
-
display_name: String,
|
41
|
-
id: Integer,
|
42
|
-
plaid_last_successful_update: String,
|
43
|
-
last_import: T.nilable(String),
|
44
|
-
limit: T.nilable(Integer),
|
45
|
-
subtype: T.nilable(String),
|
46
|
-
import_start_date: T.nilable(String),
|
47
|
-
last_fetch: T.nilable(String),
|
48
|
-
).void
|
49
|
-
end
|
50
|
-
def initialize(date_linked:, name:, type:, mask:, institution_name:, status:, balance:, currency:,
|
51
|
-
balance_last_update:, display_name:, id:, plaid_last_successful_update:, last_import: nil, limit: nil,
|
52
|
-
subtype: nil, import_start_date: nil, last_fetch: nil)
|
53
|
-
super()
|
54
|
-
@id = id
|
55
|
-
@date_linked = date_linked
|
56
|
-
@name = name
|
57
|
-
@display_name = display_name
|
58
|
-
@type = type
|
59
|
-
@subtype = subtype
|
60
|
-
@mask = mask
|
61
|
-
@institution_name = institution_name
|
62
|
-
@status = status
|
63
|
-
@limit = limit
|
64
|
-
@balance = balance
|
65
|
-
@currency = currency
|
66
|
-
@balance_last_update = balance_last_update
|
67
|
-
@import_start_date = import_start_date
|
68
|
-
@last_import = last_import
|
69
|
-
@last_fetch = last_fetch
|
70
|
-
@plaid_last_successful_update = plaid_last_successful_update
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative "plaid_account"
|
5
|
-
|
6
|
-
module LunchMoney
|
7
|
-
# https://lunchmoney.dev/#plaid-accounts
|
8
|
-
class PlaidAccountCalls < ApiCall
|
9
|
-
sig { returns(T.any(T::Array[LunchMoney::PlaidAccount], LunchMoney::Errors)) }
|
10
|
-
def plaid_accounts
|
11
|
-
response = get("plaid_accounts")
|
12
|
-
|
13
|
-
api_errors = errors(response)
|
14
|
-
return api_errors if api_errors.present?
|
15
|
-
|
16
|
-
response.body[:plaid_accounts].map do |plaid_account|
|
17
|
-
LunchMoney::PlaidAccount.new(**plaid_account)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
sig do
|
22
|
-
params(
|
23
|
-
start_date: T.nilable(String),
|
24
|
-
end_date: T.nilable(String),
|
25
|
-
plaid_account_id: T.nilable(Integer),
|
26
|
-
).returns(T.any(T::Boolean, LunchMoney::Errors))
|
27
|
-
end
|
28
|
-
def plaid_accounts_fetch(start_date: nil, end_date: nil, plaid_account_id: nil)
|
29
|
-
params = clean_params({ start_date:, end_date:, plaid_account_id: })
|
30
|
-
response = post("plaid_accounts/fetch", params)
|
31
|
-
|
32
|
-
api_errors = errors(response)
|
33
|
-
return api_errors if api_errors.present?
|
34
|
-
|
35
|
-
response.body
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|