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

#cryptoArray<LunchMoney::Objects::Crypto>, LunchMoney::Errors



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) ⇒ LunchMoney::Objects::CryptoBase, LunchMoney::Errors

Parameters:

  • crypto_id (Integer)
  • name (String, nil) (defaults to: nil)
  • display_name (String, nil) (defaults to: nil)
  • institution_name (String, nil) (defaults to: nil)
  • balance (String, nil) (defaults to: nil)
  • currency (String, nil) (defaults to: nil)

Returns:



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