class Moneylovercli::Commands::Wallets

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/moneylovercli/commands/wallets.rb, line 12
def initialize(options)
  super
  @options = options
end

Public Instance Methods

execute(_input: $stdin, output: $stdout) click to toggle source
# File lib/moneylovercli/commands/wallets.rb, line 17
def execute(_input: $stdin, output: $stdout)
  config = YAML.load_file('config.yml')
  access_token = config['access_token']
  wallets = Moneylovercli::Api::Wallet.new(token: access_token)
    .list
    .parsed_response

  output.puts TTY::Table.new(
    %w[ID Name],
    wallets['data'].map { |data| [data['_id'], data['name']] }
  )
end