Sha256: ec950fce7f6dc6f308e2590b3d777c38b571a3ab9cf0e4057a1b06086e60fed0

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

# typed: strict
# frozen_string_literal: true

require_relative "../objects/crypto"

module LunchMoney
  module Calls
    # https://lunchmoney.dev/#crypto
    class Crypto < LunchMoney::Calls::Base
      sig { returns(T.any(T::Array[LunchMoney::Objects::Crypto], LunchMoney::Errors)) }
      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

      sig do
        params(
          crypto_id: Integer,
          name: T.nilable(String),
          display_name: T.nilable(String),
          institution_name: T.nilable(String),
          balance: T.nilable(String),
          currency: T.nilable(String),
        ).returns(T.any(LunchMoney::Objects::CryptoBase, LunchMoney::Errors))
      end
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lunchmoney-1.4.0 lib/lunchmoney/calls/crypto.rb
lunchmoney-1.2.0 lib/lunchmoney/calls/crypto.rb
lunchmoney-1.1.2 lib/lunchmoney/calls/crypto.rb
lunchmoney-1.1.1 lib/lunchmoney/calls/crypto.rb
lunchmoney-1.1.0 lib/lunchmoney/calls/crypto.rb