Class: LunchMoney::Calls::Assets

Inherits:
Base
  • Object
show all
Defined in:
lib/lunchmoney/calls/assets.rb

Overview

Constant Summary

Constants inherited from Base

Base::BASE_URL

Instance Attribute Summary

Attributes inherited from Base

#api_key

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LunchMoney::Calls::Base

Instance Method Details

#assetsObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/lunchmoney/calls/assets.rb', line 11

def assets
  response = get("assets")

  api_errors = errors(response)
  return api_errors if api_errors.present?

  response.body[:assets].map do |asset|
    LunchMoney::Objects::Asset.new(**asset)
  end
end

#create_asset(type_name:, name:, balance:, subtype_name: nil, display_name: nil, balance_as_of: nil, currency: nil, institution_name: nil, closed_on: nil, exclude_transactions: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/lunchmoney/calls/assets.rb', line 36

def create_asset(type_name:, name:, balance:, subtype_name: nil, display_name: nil, balance_as_of: nil,
  currency: nil, institution_name: nil, closed_on: nil, exclude_transactions: nil)
  params = {
    type_name:,
    name:,
    balance:,
    subtype_name:,
    display_name:,
    balance_as_of:,
    currency:,
    institution_name:,
    closed_on:,
    exclude_transactions:,
  }

  response = post("assets", params)

  api_errors = errors(response)
  return api_errors if api_errors.present?

  LunchMoney::Objects::Asset.new(**response.body)
end

#update_asset(asset_id, type_name: nil, name: nil, balance: nil, subtype_name: nil, display_name: nil, balance_as_of: nil, currency: nil, institution_name: nil, closed_on: nil, exclude_transactions: nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/lunchmoney/calls/assets.rb', line 74

def update_asset(asset_id, type_name: nil, name: nil, balance: nil, subtype_name: nil, display_name: nil,
  balance_as_of: nil, currency: nil, institution_name: nil, closed_on: nil, exclude_transactions: nil)
  params = {
    type_name:,
    name:,
    balance:,
    subtype_name:,
    display_name:,
    balance_as_of:,
    currency:,
    institution_name:,
    closed_on:,
    exclude_transactions:,
  }

  response = put("assets/#{asset_id}", params)

  api_errors = errors(response)
  return api_errors if api_errors.present?

  LunchMoney::Objects::Asset.new(**response.body)
end