Class: LunchMoney::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/lunchmoney/api.rb

Overview

The main API class that a user should interface through. The method of any individual call is delegated through here so that it is never necessary to go through things like LunchMoney::Calls::Users.new.user instead you can directly call the endpoint with LunchMoney::Api.new.user and it will be delegated to the correct call.

Examples:

api = LunchMoney::Api.new
api.categories # This will be delegated to LunchMoney::Calls::Categories#categories

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil) ⇒ Api

Returns a new instance of Api.



31
32
33
# File 'lib/lunchmoney/api.rb', line 31

def initialize(api_key: nil)
  @api_key = T.let((api_key || LunchMoney.configuration.api_key), T.nilable(String))
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



28
29
30
# File 'lib/lunchmoney/api.rb', line 28

def api_key
  @api_key
end

Instance Method Details

#asset_callsObject



222
223
224
225
226
# File 'lib/lunchmoney/api.rb', line 222

def asset_calls
  with_valid_api_key do
    @asset_calls ||= T.let(LunchMoney::Calls::Assets.new(api_key:), T.nilable(LunchMoney::Calls::Assets))
  end
end

#budget_callsObject



199
200
201
202
203
# File 'lib/lunchmoney/api.rb', line 199

def budget_calls
  with_valid_api_key do
    @budget_calls ||= T.let(LunchMoney::Calls::Budgets.new(api_key:), T.nilable(LunchMoney::Calls::Budgets))
  end
end

#category_callsObject



85
86
87
88
89
# File 'lib/lunchmoney/api.rb', line 85

def category_calls
  with_valid_api_key do
    @category_calls ||= T.let(LunchMoney::Calls::Categories.new(api_key:), T.nilable(LunchMoney::Calls::Categories))
  end
end

#crypto_callsObject



257
258
259
260
261
# File 'lib/lunchmoney/api.rb', line 257

def crypto_calls
  with_valid_api_key do
    @crypto_calls ||= T.let(LunchMoney::Calls::Crypto.new(api_key:), T.nilable(LunchMoney::Calls::Crypto))
  end
end

#plaid_account_callsObject



238
239
240
241
242
243
244
245
# File 'lib/lunchmoney/api.rb', line 238

def 
  with_valid_api_key do
    @plaid_account_calls ||= T.let(
      LunchMoney::Calls::PlaidAccounts.new(api_key:),
      T.nilable(LunchMoney::Calls::PlaidAccounts),
    )
  end
end

#recurring_expense_callsObject



177
178
179
180
181
182
183
184
# File 'lib/lunchmoney/api.rb', line 177

def recurring_expense_calls
  with_valid_api_key do
    @recurring_expense_calls ||= T.let(
      LunchMoney::Calls::RecurringExpenses.new(api_key:),
      T.nilable(LunchMoney::Calls::RecurringExpenses),
    )
  end
end

#tag_callsObject



98
99
100
101
102
# File 'lib/lunchmoney/api.rb', line 98

def tag_calls
  with_valid_api_key do
    @tag_calls ||= T.let(LunchMoney::Calls::Tags.new(api_key:), T.nilable(LunchMoney::Calls::Tags))
  end
end

#transaction_callsObject



161
162
163
164
165
166
167
168
# File 'lib/lunchmoney/api.rb', line 161

def transaction_calls
  with_valid_api_key do
    @transaction_calls ||= T.let(
      LunchMoney::Calls::Transactions.new(api_key:),
      T.nilable(LunchMoney::Calls::Transactions),
    )
  end
end

#user_callsObject



42
43
44
45
46
# File 'lib/lunchmoney/api.rb', line 42

def user_calls
  with_valid_api_key do
    @user_calls ||= T.let(LunchMoney::Calls::Users.new(api_key:), T.nilable(LunchMoney::Calls::Users))
  end
end