Class: LunchMoney::Calls::Crypto

Inherits:
Base
  • Object
show all
Defined in:
lib/lunchmoney/calls/crypto.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

#cryptoObject



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

def crypto
  response = get("crypto")

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

  response.body[:crypto].map do |crypto|
    LunchMoney::Objects::Crypto.new(**crypto)
  end
end

#update_crypto(crypto_id, name: nil, display_name: nil, institution_name: nil, balance: nil, currency: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/lunchmoney/calls/crypto.rb', line 32

def update_crypto(crypto_id, name: nil, display_name: nil, institution_name: nil, balance: nil, currency: nil)
  params = clean_params({
    name:,
    display_name:,
    institution_name:,
    balance:,
    currency:,
  })

  response = put("crypto/manual/#{crypto_id}", params)

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

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