<commit_before>require 'httparty'
require 'httmultiparty'
require 'myfinance/version'
require 'myfinance/entidade'
require 'myfinance/pessoa'
require 'myfinance/conta_a_pagar'
require 'myfinance/conta_a_receber'
require 'myfinance/imposto'
require 'myfinance/categoria'
require 'myfinance/centro_receita_custo'
require 'myfinance/account'
require 'myfinance/conta_deposito'
require 'myfinance/webhook'
require 'myfinance/anexo'
require 'json'

module Myfinance

  # include HTTParty
  include HTTMultiParty

  attr_accessor :token, :endpoint, :account_id

  # se o usuario tiver mais de um account e não informarmos o account id,
  # ele pega o primeiro
  # se tiver mais de um, precisamos informar
  def self.setup(token, production=false, account=nil, logger=nil)
    logger(logger, :info, :curl) if logger

    if production
      @endpoint = 'https://app.myfinance.com.br'
    else
      @endpoint = 'https://sandbox.myfinance.com.br'
      # @endpoint = 'https://app.myfinance.com.br'
    end
    base_uri @endpoint
    @token = token
    # testo com uma chamada simples
    response = accounts
    # Resposta deve ser um array de hashes
    unless response.code == 200
      raise "Erro ao inicializar a API do MyFinance: #{response.code} : #{response.parsed_response}"
    end
    if account.is_a?(String)
      @account_id = account_id(account)
    else
      @account_id = get_account_id(account, response)
    end
  end

  def account_id
    @account_id
  end

  def set_account_id(account_id)
    @account_id = account_id
  end

  def set_account_id_by_name(account_name)
    @account_id = Myfinance.account_id(account_name)
  end

  private

  def self.header_info
    # { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
    { 'Content-Type' => 'application/json' }
  end

  def self.lget(url)<commit_msg>não posso chamar get_account_id sem passar a conta senão se tiver maos de uma não consigo inicializar<commit_after>require 'httparty'
require 'httmultiparty'
require 'myfinance/version'
require 'myfinance/entidade'
require 'myfinance/pessoa'
require 'myfinance/conta_a_pagar'
require 'myfinance/conta_a_receber'
require 'myfinance/imposto'
require 'myfinance/categoria'
require 'myfinance/centro_receita_custo'
require 'myfinance/account'
require 'myfinance/conta_deposito'
require 'myfinance/webhook'
require 'myfinance/anexo'
require 'json'

module Myfinance

  # include HTTParty
  include HTTMultiParty

  attr_accessor :token, :endpoint, :account_id

  # se o usuario tiver mais de um account e não informarmos o account id,
  # ele pega o primeiro
  # se tiver mais de um, precisamos informar
  def self.setup(token, production=false, account=nil, logger=nil)
    logger(logger, :info, :curl) if logger

    if production
      @endpoint = 'https://app.myfinance.com.br'
    else
      @endpoint = 'https://sandbox.myfinance.com.br'
      # @endpoint = 'https://app.myfinance.com.br'
    end
    base_uri @endpoint
    @token = token
    # testo com uma chamada simples
    response = accounts
    # Resposta deve ser um array de hashes
    unless response.code == 200
      raise "Erro ao inicializar a API do MyFinance: #{response.code} : #{response.parsed_response}"
    end
    if account and account.is_a?(String)
      @account_id = account_id(account)
    # else
    #   @account_id = get_account_id(account, response)
    end
  end

  def account_id
    @account_id
  end

  def set_account_id(account_id)
    @account_id = account_id
  end

  def set_account_id_by_name(account_name)
    @account_id = Myfinance.account_id(account_name)
  end

  private

  def self.header_info
    # { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
    { 'Content-Type' => 'application/json' }
  end

  def self.lget(url)
{'fraction_non_alphanumeric': 0.09619450317124736, 'fraction_numerical': 0.0015856236786469344, 'mean_word_length': 3.8838709677419354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921765', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1303, 'n_words': 323}