Skip to content

Commit e64be41

Browse files
committed
add more yard documentation
1 parent c2bf228 commit e64be41

31 files changed

+60
-1
lines changed

lib/lunchmoney.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@
88
require "sorbet-runtime"
99

1010
# Include T::Sig directly in the module class so that it doesn't need to be extended everywhere.
11-
Module.include(T::Sig)
11+
class Module
12+
include T::Sig
13+
end
1214

1315
require_relative "lunchmoney/version"
1416
require_relative "lunchmoney/validators"
1517
require_relative "lunchmoney/api"
1618

1719
module LunchMoney
20+
# Lock used to avoid config conflicts
1821
LOCK = T.let(Mutex.new, Mutex)
1922

2023
class << self
24+
# @example Set your API key
25+
# LunchMoney.configure do |config|
26+
# config.api_key = "your_api_key"
27+
# end
28+
#
29+
# @example Turn off object validation
30+
# LunchMoney.configure do |config|
31+
# config.validate_object_attributes = false
32+
# end
2133
sig do
2234
params(block: T.proc.params(arg0: LunchMoney::Configuration).void).void
2335
end

lib/lunchmoney/api.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
require_relative "crypto/crypto_calls"
1818

1919
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
22+
# call the endpoint with LunchMoney::Api.new.user and it will be delegated to the correct call.
2023
class Api
2124
sig { returns(T.nilable(String)) }
2225
attr_reader :api_key

lib/lunchmoney/api_call.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
require_relative "error"
55

66
module LunchMoney
7+
# Base class for all API call types
78
class ApiCall
9+
# Base URL used for API calls
810
BASE_URL = "https://dev.lunchmoney.app/v1/"
911

1012
sig { returns(T.nilable(String)) }

lib/lunchmoney/assets/asset.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#assets-object
56
class Asset < LunchMoney::DataObject
67
# API object reference documentation: https://lunchmoney.dev/#assets-object
78

@@ -25,6 +26,7 @@ class Asset < LunchMoney::DataObject
2526
sig { returns(T::Boolean) }
2627
attr_accessor :exclude_transactions
2728

29+
# Valid asset type names
2830
VALID_TYPE_NAMES = T.let(
2931
[
3032
"cash",
@@ -41,6 +43,7 @@ class Asset < LunchMoney::DataObject
4143
T::Array[String],
4244
)
4345

46+
# Valid asset subtype names
4447
VALID_SUBTYPE_NAMES = T.let(
4548
[
4649
"retirement",

lib/lunchmoney/assets/asset_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "asset"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#assets
78
class AssetCalls < ApiCall
89
sig { returns(T.any(T::Array[LunchMoney::Asset], LunchMoney::Errors)) }
910
def assets

lib/lunchmoney/budget/budget.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require_relative "config"
66

77
module LunchMoney
8+
# https://lunchmoney.dev/#budget-object
89
class Budget < LunchMoney::DataObject
910
# API object reference documentation: https://lunchmoney.dev/#budget-object
1011

lib/lunchmoney/budget/budget_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "budget"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#budget
78
class BudgetCalls < ApiCall
89
sig do
910
params(

lib/lunchmoney/budget/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#config-object
56
class Config < LunchMoney::DataObject
67
# API object reference documentation: https://lunchmoney.dev/#config-object
78

lib/lunchmoney/budget/data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#data-object
56
class Data < LunchMoney::DataObject
67
# API object reference documentation: https://lunchmoney.dev/#data-object
78

lib/lunchmoney/categories/category.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#categories-object
56
class Category < LunchMoney::DataObject
67
sig { returns(Integer) }
78
attr_accessor :id

lib/lunchmoney/categories/category_calls.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
require_relative "category"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#categories
78
class CategoryCalls < ApiCall
9+
# Valid query parameter formets for categories
810
VALID_FORMATS = T.let(
911
[
1012
"flattened",

lib/lunchmoney/configuration.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# Holds global configuration options for this gem
6+
# @example api_key
7+
# LunchMoney::Configuration.api_key
8+
# => "your_api_key"
9+
#
10+
# @example validate_object_attributes
11+
# LunchMoney::Configuration.validate_object_attributes
12+
# => true
513
class Configuration
614
sig { returns(T.nilable(String)) }
715
attr_accessor :api_key

lib/lunchmoney/crypto/crypto.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#crypto-object
56
class Crypto < LunchMoney::DataObject
67
sig { returns(T.nilable(Integer)) }
78
attr_accessor :id, :zabo_account_id

lib/lunchmoney/crypto/crypto_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "crypto"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#crypto
78
class CryptoCalls < ApiCall
89
sig { returns(T.any(T::Array[LunchMoney::Crypto], LunchMoney::Errors)) }
910
def crypto

lib/lunchmoney/data_object.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# Base data object for the objects returned and used when calling the LunchMoney API
56
class DataObject
67
sig { params(symbolize_keys: T::Boolean).returns(T::Hash[String, T.untyped]) }
78
def serialize(symbolize_keys: false)

lib/lunchmoney/error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# This class is used to represent errors returned directly from the LunchMoney API
56
class Error
67
sig { returns(String) }
78
attr_reader :message
@@ -13,4 +14,5 @@ def initialize(message:)
1314
end
1415
end
1516

17+
# A type alias for an array of LunchMoney::Error
1618
LunchMoney::Errors = T.type_alias { T::Array[LunchMoney::Error] }

lib/lunchmoney/exceptions.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# Base exception class for exceptions raised by this gem
56
class Exception < StandardError; end
67

8+
# Exception raised when an API Key appears to be invalid
79
class InvalidApiKey < Exception; end
810

11+
# Exception raised when an object attribute is invalid
912
class InvalidObjectAttribute < Exception; end
1013

14+
# Exception raised when a query parameter is invalid
1115
class InvalidQueryParameter < Exception; end
1216
end

lib/lunchmoney/plaid_accounts/plaid_account.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#plaid-accounts-object
56
class PlaidAccount < LunchMoney::DataObject
67
sig { returns(Integer) }
78
attr_accessor :id

lib/lunchmoney/plaid_accounts/plaid_account_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "plaid_account"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#plaid-accounts
78
class PlaidAccountCalls < ApiCall
89
sig { returns(T.any(T::Array[LunchMoney::PlaidAccount], LunchMoney::Errors)) }
910
def plaid_accounts

lib/lunchmoney/recurring_expenses/recurring_expense.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#recurring-expenses-object
56
class RecurringExpense < LunchMoney::DataObject
67
sig { returns(Integer) }
78
attr_accessor :id, :amount

lib/lunchmoney/recurring_expenses/recurring_expense_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "recurring_expense"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#recurring-expenses
78
class RecurringExpenseCalls < ApiCall
89
sig do
910
params(

lib/lunchmoney/tags/tag.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#tags-object
56
class Tag < LunchMoney::DataObject
67
sig { returns(Integer) }
78
attr_accessor :id

lib/lunchmoney/tags/tag_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "tag"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#tags
78
class TagCalls < ApiCall
89
sig { returns(T.any(T::Array[LunchMoney::Tag], LunchMoney::Errors)) }
910
def all_tags

lib/lunchmoney/transactions/split.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# Object used to split a transaction when updating https://lunchmoney.dev/#update-transaction
56
class Split < LunchMoney::DataObject
67
sig { returns(T.nilable(String)) }
78
attr_accessor :payee, :date, :notes

lib/lunchmoney/transactions/transaction.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#transaction-object
56
class Transaction < LunchMoney::DataObject
67
sig { returns(T.nilable(Integer)) }
78
attr_accessor :id, :to_base, :category_id, :recurring_id, :asset_id, :plaid_account_id, :parent_id, :group_id

lib/lunchmoney/transactions/transaction_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require_relative "split"
77

88
module LunchMoney
9+
# https://lunchmoney.dev/#transactions
910
class TransactionCalls < ApiCall
1011
sig do
1112
params(

lib/lunchmoney/transactions/update_transaction.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# object used when updating a transaction https://lunchmoney.dev/#update-transaction
56
class UpdateTransaction < LunchMoney::DataObject
67
sig { returns(T.nilable(String)) }
78
attr_accessor :date, :payee, :amount, :currency, :notes, :status, :external_id

lib/lunchmoney/user/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# https://lunchmoney.dev/#user-object
56
class User < LunchMoney::DataObject
67
sig { returns(Integer) }
78
attr_accessor :user_id, :account_id

lib/lunchmoney/user/user_calls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "user"
55

66
module LunchMoney
7+
# https://lunchmoney.dev/#user
78
class UserCalls < ApiCall
89
sig { returns(T.any(LunchMoney::User, LunchMoney::Errors)) }
910
def user

lib/lunchmoney/validators.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require "time"
55

66
module LunchMoney
7+
# module containing reusable methods for validating data objects
78
module Validators
89
include Kernel
910

lib/lunchmoney/version.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# frozen_string_literal: true
33

44
module LunchMoney
5+
# Current version of the gem
56
VERSION = "0.5.1"
67
end

0 commit comments

Comments
 (0)