lunchmoney 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish_gem.yml +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/lunchmoney/api.rb +34 -34
  5. data/lib/lunchmoney/calls/assets.rb +98 -0
  6. data/lib/lunchmoney/calls/base.rb +112 -0
  7. data/lib/lunchmoney/calls/budgets.rb +84 -0
  8. data/lib/lunchmoney/calls/categories.rb +196 -0
  9. data/lib/lunchmoney/calls/crypto.rb +50 -0
  10. data/lib/lunchmoney/calls/plaid_accounts.rb +40 -0
  11. data/lib/lunchmoney/calls/recurring_expenses.rb +29 -0
  12. data/lib/lunchmoney/calls/tags.rb +21 -0
  13. data/lib/lunchmoney/calls/transactions.rb +220 -0
  14. data/lib/lunchmoney/calls/users.rb +21 -0
  15. data/lib/lunchmoney/objects/asset.rb +91 -0
  16. data/lib/lunchmoney/objects/budget.rb +76 -0
  17. data/lib/lunchmoney/objects/category.rb +55 -0
  18. data/lib/lunchmoney/objects/child_category.rb +44 -0
  19. data/lib/lunchmoney/objects/child_transaction.rb +35 -0
  20. data/lib/lunchmoney/objects/config.rb +40 -0
  21. data/lib/lunchmoney/objects/crypto.rb +46 -0
  22. data/lib/lunchmoney/objects/crypto_base.rb +67 -0
  23. data/lib/lunchmoney/objects/data.rb +44 -0
  24. data/lib/lunchmoney/objects/object.rb +28 -0
  25. data/lib/lunchmoney/objects/plaid_account.rb +75 -0
  26. data/lib/lunchmoney/objects/recurring_expense.rb +68 -0
  27. data/lib/lunchmoney/objects/recurring_expense_base.rb +31 -0
  28. data/lib/lunchmoney/objects/split.rb +28 -0
  29. data/lib/lunchmoney/objects/tag.rb +24 -0
  30. data/lib/lunchmoney/objects/tag_base.rb +23 -0
  31. data/lib/lunchmoney/objects/transaction.rb +160 -0
  32. data/lib/lunchmoney/objects/transaction_base.rb +54 -0
  33. data/lib/lunchmoney/objects/transaction_modification_base.rb +32 -0
  34. data/lib/lunchmoney/objects/update_transaction.rb +47 -0
  35. data/lib/lunchmoney/objects/user.rb +38 -0
  36. data/lib/lunchmoney/version.rb +1 -1
  37. metadata +32 -32
  38. data/lib/lunchmoney/api_call.rb +0 -109
  39. data/lib/lunchmoney/assets/asset.rb +0 -89
  40. data/lib/lunchmoney/assets/asset_calls.rb +0 -96
  41. data/lib/lunchmoney/budget/budget.rb +0 -74
  42. data/lib/lunchmoney/budget/budget_calls.rb +0 -82
  43. data/lib/lunchmoney/budget/config.rb +0 -38
  44. data/lib/lunchmoney/budget/data.rb +0 -42
  45. data/lib/lunchmoney/categories/category/category.rb +0 -52
  46. data/lib/lunchmoney/categories/category/child_category.rb +0 -42
  47. data/lib/lunchmoney/categories/category_calls.rb +0 -195
  48. data/lib/lunchmoney/crypto/crypto/crypto.rb +0 -43
  49. data/lib/lunchmoney/crypto/crypto/crypto_base.rb +0 -65
  50. data/lib/lunchmoney/crypto/crypto_calls.rb +0 -49
  51. data/lib/lunchmoney/data_object.rb +0 -25
  52. data/lib/lunchmoney/plaid_accounts/plaid_account.rb +0 -73
  53. data/lib/lunchmoney/plaid_accounts/plaid_account_calls.rb +0 -38
  54. data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb +0 -65
  55. data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb +0 -29
  56. data/lib/lunchmoney/recurring_expenses/recurring_expense_calls.rb +0 -28
  57. data/lib/lunchmoney/tags/tag/tag.rb +0 -20
  58. data/lib/lunchmoney/tags/tag/tag_base.rb +0 -21
  59. data/lib/lunchmoney/tags/tag_calls.rb +0 -20
  60. data/lib/lunchmoney/transactions/transaction/child_transaction.rb +0 -31
  61. data/lib/lunchmoney/transactions/transaction/split.rb +0 -24
  62. data/lib/lunchmoney/transactions/transaction/transaction.rb +0 -156
  63. data/lib/lunchmoney/transactions/transaction/transaction_base.rb +0 -52
  64. data/lib/lunchmoney/transactions/transaction/transaction_modification_base.rb +0 -30
  65. data/lib/lunchmoney/transactions/transaction/update_transaction.rb +0 -43
  66. data/lib/lunchmoney/transactions/transaction_calls.rb +0 -218
  67. data/lib/lunchmoney/user/user.rb +0 -36
  68. data/lib/lunchmoney/user/user_calls.rb +0 -19
@@ -1,65 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # https://lunchmoney.dev/#recurring-expenses-object
6
- class RecurringExpense < RecurringExpenseBase
7
- sig { returns(Integer) }
8
- attr_accessor :id
9
-
10
- sig { returns(T.nilable(String)) }
11
- attr_accessor :start_date, :end_date, :description, :original_name
12
-
13
- sig { returns(String) }
14
- attr_accessor :cadence, :billing_date, :type, :source, :created_at
15
-
16
- sig { returns(T.nilable(Integer)) }
17
- attr_accessor :plaid_account_id, :asset_id, :transaction_id, :category_id
18
-
19
- sig do
20
- params(
21
- cadence: String,
22
- payee: String,
23
- amount: String,
24
- currency: String,
25
- billing_date: String,
26
- type: String,
27
- source: String,
28
- id: Integer,
29
- created_at: String,
30
- category_id: T.nilable(Integer),
31
- start_date: T.nilable(String),
32
- end_date: T.nilable(String),
33
- description: T.nilable(String),
34
- original_name: T.nilable(String),
35
- plaid_account_id: T.nilable(Integer),
36
- asset_id: T.nilable(Integer),
37
- transaction_id: T.nilable(Integer),
38
- to_base: T.nilable(Number),
39
- ).void
40
- end
41
- def initialize(cadence:, payee:, amount:, currency:, billing_date:, type:, source:, id:, created_at:,
42
- category_id: nil, start_date: nil, end_date: nil, description: nil, original_name: nil, plaid_account_id: nil,
43
- asset_id: nil, transaction_id: nil, to_base: nil)
44
- super(payee:, amount:, currency:, to_base:)
45
- @cadence = cadence
46
- @payee = payee
47
- @amount = amount
48
- @currency = currency
49
- @billing_date = billing_date
50
- @type = type
51
- @source = source
52
- @id = id
53
- @category_id = category_id
54
- @created_at = created_at
55
- @start_date = start_date
56
- @end_date = end_date
57
- @description = description
58
- @original_name = original_name
59
- @plaid_account_id = plaid_account_id
60
- @asset_id = asset_id
61
- @transaction_id = transaction_id
62
- @to_base = to_base
63
- end
64
- end
65
- end
@@ -1,29 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # https://lunchmoney.dev/#recurring-expenses-object
6
- class RecurringExpenseBase < LunchMoney::DataObject
7
- sig { returns(String) }
8
- attr_accessor :payee, :currency, :amount
9
-
10
- sig { returns(T.nilable(Number)) }
11
- attr_accessor :to_base
12
-
13
- sig do
14
- params(
15
- payee: String,
16
- amount: String,
17
- currency: String,
18
- to_base: T.nilable(Number),
19
- ).void
20
- end
21
- def initialize(payee:, amount:, currency:, to_base:)
22
- super()
23
- @payee = payee
24
- @amount = amount
25
- @currency = currency
26
- @to_base = to_base
27
- end
28
- end
29
- end
@@ -1,28 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require_relative "recurring_expense/recurring_expense_base"
5
- require_relative "recurring_expense/recurring_expense"
6
-
7
- module LunchMoney
8
- # https://lunchmoney.dev/#recurring-expenses
9
- class RecurringExpenseCalls < ApiCall
10
- sig do
11
- params(
12
- start_date: T.nilable(String),
13
- end_date: T.nilable(String),
14
- ).returns(T.any(T::Array[LunchMoney::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::RecurringExpense.new(**recurring_expense)
25
- end
26
- end
27
- end
28
- end
@@ -1,20 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # https://lunchmoney.dev/#tags-object
6
- class Tag < TagBase
7
- sig { returns(T.nilable(String)) }
8
- attr_accessor :description
9
-
10
- sig { returns(T::Boolean) }
11
- attr_accessor :archived
12
-
13
- sig { params(id: Integer, name: String, archived: T::Boolean, description: T.nilable(String)).void }
14
- def initialize(id:, name:, archived:, description: nil)
15
- super(id:, name:)
16
- @archived = archived
17
- @description = description
18
- end
19
- end
20
- end
@@ -1,21 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # https://lunchmoney.dev/#tags-object without some fields. This is used within field returns of other objects like
6
- # field returns of other objects like transactions
7
- class TagBase < LunchMoney::DataObject
8
- sig { returns(Integer) }
9
- attr_accessor :id
10
-
11
- sig { returns(String) }
12
- attr_accessor :name
13
-
14
- sig { params(id: Integer, name: String).void }
15
- def initialize(id:, name:)
16
- super()
17
- @id = id
18
- @name = name
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require_relative "tag/tag_base"
5
- require_relative "tag/tag"
6
-
7
- module LunchMoney
8
- # https://lunchmoney.dev/#tags
9
- class TagCalls < ApiCall
10
- sig { returns(T.any(T::Array[LunchMoney::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::Tag.new(**tag) }
18
- end
19
- end
20
- end
@@ -1,31 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # Slimmed down version of https://lunchmoney.dev/#transaction-object used in the
6
- # `children` field of a transaction object with an additional `formatted_date`` field
7
- class ChildTransaction < TransactionBase
8
- sig { returns(String) }
9
- attr_accessor :formatted_date
10
-
11
- sig do
12
- params(
13
- id: Integer,
14
- date: String,
15
- amount: String,
16
- currency: String,
17
- to_base: Number,
18
- payee: String,
19
- formatted_date: String,
20
- notes: T.nilable(String),
21
- asset_id: T.nilable(Integer),
22
- plaid_account_id: T.nilable(Integer),
23
- ).void
24
- end
25
- def initialize(id:, date:, amount:, currency:, to_base:, payee:, formatted_date:, notes: nil, asset_id: nil,
26
- plaid_account_id: nil)
27
- super(id:, date:, amount:, currency:, to_base:, payee:, notes:, asset_id:, plaid_account_id:)
28
- @formatted_date = formatted_date
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # Object used to split a transaction when updating https://lunchmoney.dev/#update-transaction
6
- class Split < TransactionModificationBase
7
- sig { returns(T.any(Number, String)) }
8
- attr_accessor :amount
9
-
10
- sig do
11
- params(
12
- amount: T.any(Number, String),
13
- payee: T.nilable(String),
14
- date: T.nilable(String),
15
- category_id: T.nilable(Integer),
16
- notes: T.nilable(String),
17
- ).void
18
- end
19
- def initialize(amount:, payee: nil, date: nil, category_id: nil, notes: nil)
20
- super(payee:, date:, category_id:, notes:)
21
- @amount = amount
22
- end
23
- end
24
- end
@@ -1,156 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # https://lunchmoney.dev/#transaction-object
6
- class Transaction < TransactionBase
7
- sig { returns(T.nilable(Integer)) }
8
- attr_accessor :category_id,
9
- :category_group_id,
10
- :recurring_id,
11
- :parent_id,
12
- :group_id,
13
- :external_id
14
-
15
- sig { returns(String) }
16
- attr_accessor :created_at,
17
- :updated_at,
18
- :status,
19
- :source,
20
- :display_name,
21
- :account_display_name
22
-
23
- sig { returns(T.nilable(String)) }
24
- attr_accessor :category_name,
25
- :category_group_name,
26
- :original_name,
27
- :recurring_payee,
28
- :recurring_description,
29
- :recurring_cadence,
30
- :recurring_type,
31
- :recurring_amount,
32
- :recurring_currency,
33
- :asset_institution_name,
34
- :asset_name,
35
- :asset_display_name,
36
- :asset_status,
37
- :plaid_account_name,
38
- :plaid_account_mask,
39
- :institution_name,
40
- :plaid_account_display_name,
41
- :plaid_metadata,
42
- :display_notes
43
-
44
- sig { returns(T::Boolean) }
45
- attr_accessor :is_income, :exclude_from_budget, :exclude_from_totals, :is_pending, :has_children, :is_group
46
-
47
- sig { returns(T::Array[LunchMoney::TagBase]) }
48
- attr_accessor :tags
49
-
50
- sig { returns(T.nilable(T::Array[LunchMoney::ChildTransaction])) }
51
- attr_accessor :children
52
-
53
- sig do
54
- params(
55
- id: Integer,
56
- date: String,
57
- amount: String,
58
- currency: String,
59
- to_base: Number,
60
- payee: String,
61
- is_income: T::Boolean,
62
- exclude_from_budget: T::Boolean,
63
- exclude_from_totals: T::Boolean,
64
- created_at: String,
65
- updated_at: String,
66
- status: String,
67
- is_pending: T::Boolean,
68
- has_children: T::Boolean,
69
- is_group: T::Boolean,
70
- source: String,
71
- display_name: String,
72
- account_display_name: String,
73
- tags: T::Array[LunchMoney::TagBase],
74
- category_id: T.nilable(Integer),
75
- category_name: T.nilable(String),
76
- category_group_id: T.nilable(Integer),
77
- category_group_name: T.nilable(String),
78
- notes: T.nilable(String),
79
- original_name: T.nilable(String),
80
- recurring_id: T.nilable(Integer),
81
- recurring_payee: T.nilable(String),
82
- recurring_description: T.nilable(String),
83
- recurring_cadence: T.nilable(String),
84
- recurring_type: T.nilable(String),
85
- recurring_amount: T.nilable(String),
86
- recurring_currency: T.nilable(String),
87
- parent_id: T.nilable(Integer),
88
- group_id: T.nilable(Integer),
89
- asset_id: T.nilable(Integer),
90
- asset_institution_name: T.nilable(String),
91
- asset_name: T.nilable(String),
92
- asset_display_name: T.nilable(String),
93
- asset_status: T.nilable(String),
94
- plaid_account_id: T.nilable(Integer),
95
- plaid_account_name: T.nilable(String),
96
- plaid_account_mask: T.nilable(String),
97
- institution_name: T.nilable(String),
98
- plaid_account_display_name: T.nilable(String),
99
- plaid_metadata: T.nilable(String),
100
- display_notes: T.nilable(String),
101
- external_id: T.nilable(Integer),
102
- children: T.nilable(T::Array[LunchMoney::ChildTransaction]),
103
- ).void
104
- end
105
- def initialize(id:, date:, amount:, currency:, to_base:, payee:, is_income:, exclude_from_budget:,
106
- exclude_from_totals:, created_at:, updated_at:, status:, is_pending:, has_children:, is_group:, source:,
107
- display_name:, account_display_name:, tags:, category_id: nil, category_name: nil, category_group_id: nil,
108
- category_group_name: nil, notes: nil, original_name: nil, recurring_id: nil, recurring_payee: nil,
109
- recurring_description: nil, recurring_cadence: nil, recurring_type: nil, recurring_amount: nil,
110
- recurring_currency: nil, parent_id: nil, group_id: nil, asset_id: nil, asset_institution_name: nil,
111
- asset_name: nil, asset_display_name: nil, asset_status: nil, plaid_account_id: nil, plaid_account_name: nil,
112
- plaid_account_mask: nil, institution_name: nil, plaid_account_display_name: nil, plaid_metadata: nil,
113
- display_notes: nil, external_id: nil, children: nil)
114
- super(id:, date:, amount:, currency:, to_base:, payee:, notes:, asset_id:, plaid_account_id:)
115
- @is_income = is_income
116
- @exclude_from_budget = exclude_from_budget
117
- @exclude_from_totals = exclude_from_totals
118
- @created_at = created_at
119
- @updated_at = updated_at
120
- @status = status
121
- @is_pending = is_pending
122
- @has_children = has_children
123
- @is_group = is_group
124
- @source = source
125
- @display_name = display_name
126
- @account_display_name = account_display_name
127
- @tags = tags
128
- @category_id = category_id
129
- @category_name = category_name
130
- @category_group_id = category_group_id
131
- @category_group_name = category_group_name
132
- @original_name = original_name
133
- @recurring_id = recurring_id
134
- @recurring_payee = recurring_payee
135
- @recurring_description = recurring_description
136
- @recurring_cadence = recurring_cadence
137
- @recurring_type = recurring_type
138
- @recurring_amount = recurring_amount
139
- @recurring_currency = recurring_currency
140
- @parent_id = parent_id
141
- @group_id = group_id
142
- @asset_institution_name = asset_institution_name
143
- @asset_name = asset_name
144
- @asset_display_name = asset_display_name
145
- @asset_status = asset_status
146
- @plaid_account_name = plaid_account_name
147
- @plaid_account_mask = plaid_account_mask
148
- @institution_name = institution_name
149
- @plaid_account_display_name = plaid_account_display_name
150
- @plaid_metadata = plaid_metadata
151
- @display_notes = display_notes
152
- @children = children
153
- @external_id = external_id
154
- end
155
- end
156
- end
@@ -1,52 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # Slimmed down version of https://lunchmoney.dev/#transaction-object used as a base for other transaction objects
6
- class TransactionBase < LunchMoney::DataObject
7
- sig { returns(Integer) }
8
- attr_accessor :id
9
-
10
- sig { returns(Number) }
11
- attr_accessor :to_base
12
-
13
- sig { returns(T.nilable(Integer)) }
14
- attr_accessor :asset_id, :plaid_account_id
15
-
16
- sig { returns(String) }
17
- attr_accessor :date,
18
- :amount,
19
- :currency,
20
- :payee
21
-
22
- sig { returns(T.nilable(String)) }
23
- attr_accessor :notes
24
-
25
- sig do
26
- params(
27
- id: Integer,
28
- date: String,
29
- amount: String,
30
- currency: String,
31
- to_base: Number,
32
- payee: String,
33
- notes: T.nilable(String),
34
- asset_id: T.nilable(Integer),
35
- plaid_account_id: T.nilable(Integer),
36
- ).void
37
- end
38
- def initialize(id:, date:, amount:, currency:, to_base:, payee:, notes: nil, asset_id: nil,
39
- plaid_account_id: nil)
40
- super()
41
- @id = id
42
- @date = date
43
- @amount = amount
44
- @currency = currency
45
- @to_base = to_base
46
- @payee = payee
47
- @notes = notes
48
- @asset_id = asset_id
49
- @plaid_account_id = plaid_account_id
50
- end
51
- end
52
- end
@@ -1,30 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # Base object used for transaction objects that are used to update
6
- # transactions https://lunchmoney.dev/#update-transaction
7
- class TransactionModificationBase < LunchMoney::DataObject
8
- sig { returns(T.nilable(String)) }
9
- attr_accessor :payee, :date, :notes
10
-
11
- sig { returns(T.nilable(Integer)) }
12
- attr_accessor :category_id
13
-
14
- sig do
15
- params(
16
- payee: T.nilable(String),
17
- date: T.nilable(String),
18
- category_id: T.nilable(Integer),
19
- notes: T.nilable(String),
20
- ).void
21
- end
22
- def initialize(payee: nil, date: nil, category_id: nil, notes: nil)
23
- super()
24
- @payee = payee
25
- @date = date
26
- @category_id = category_id
27
- @notes = notes
28
- end
29
- end
30
- end
@@ -1,43 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module LunchMoney
5
- # object used when updating a transaction https://lunchmoney.dev/#update-transaction
6
- class UpdateTransaction < TransactionModificationBase
7
- sig { returns(T.nilable(String)) }
8
- attr_accessor :amount, :currency, :status, :external_id
9
-
10
- sig { returns(T.nilable(Integer)) }
11
- attr_accessor :asset_id, :recurring_id
12
-
13
- sig { returns(T.nilable(T::Array[T.any(String, Integer)])) }
14
- attr_accessor :tags
15
-
16
- sig do
17
- params(
18
- tags: T.nilable(T::Array[T.any(String, Integer)]),
19
- category_id: T.nilable(Integer),
20
- payee: T.nilable(String),
21
- amount: T.nilable(String),
22
- currency: T.nilable(String),
23
- asset_id: T.nilable(Integer),
24
- recurring_id: T.nilable(Integer),
25
- notes: T.nilable(String),
26
- status: T.nilable(String),
27
- external_id: T.nilable(String),
28
- date: T.nilable(String),
29
- ).void
30
- end
31
- def initialize(tags: nil, category_id: nil, payee: nil, amount: nil, currency: nil, asset_id: nil,
32
- recurring_id: nil, notes: nil, status: nil, external_id: nil, date: nil)
33
- super(payee:, date:, category_id:, notes:)
34
- @amount = amount
35
- @tags = tags
36
- @currency = currency
37
- @asset_id = asset_id
38
- @recurring_id = recurring_id
39
- @status = status
40
- @external_id = external_id
41
- end
42
- end
43
- end