<commit_before>module Bitstamp
  class Client
  
    def initialize(client_id, key, secret, curr_pair = DEFAULT_CURR_PAIR)
      @net = Bitstamp::NetComm.new(client_id, key, secret, curr_pair)
      @curr_pair = curr_pair[0..2], curr_pair[3..5]
    end


    # Get ticker data
    def ticker
      data = @net.get('ticker')
      Bitstamp::Model::Ticker.new(data)
    end


    def order_book
      data = @net.get('order_book')
      data['timestamp'] = Time.at(data['timestamp'].to_i)
      %w(asks bids).each do |dir|
        data[dir].map!{ |e| Bitstamp::Model::Offer.new(e) }
      end
      data
    end
    

    # Access to tranasactions
    def transactions
      @transactions ||= Bitstamp::Transactions.new(@net, @curr_pair)
    end


    # Get balances
    def balances
      r = Hash.new
      data = @net.post('balance')
      @curr_pair.each do |curr|
        r[curr.upcase] = Bitstamp::Model::Balance.new(
                            currency: curr.upcase,
                            balance: data["#{curr}_balance"],
                            available: data["#{curr}_available"],
                            reserved: data["#{curr}_reserved"]
                         )
      end
      r
    end
    

    # Access to orders
    def orders
      @orders ||= Bitstamp::Orders.new(@net)
    end

    def withdraw_btc(amount, address)
      r = @net.post('bitcoin_withdrawal', amount: amount, address: address)
      r['id']
    end


    def deposit_address
      @net.post('bitcoin_deposit_address') \
          .tr('"', '')
    end


    def unconfirmed_deposits
      @net.post('unconfirmed_btc')
    end

    
    def transfer_main_to_sub(sub_account_id, amount, currency = 'BTC')
      r = @net.post('transfer-from-main', subAccount: sub_account_id,
                                          amount: amount,
                                          currency: currency)
      r['status'] == 'ok'
    end


    def transfer_sub_to_main(amount, currency = 'BTC')
      r = @net.post('transfer-to-main', amount: amount,
                                        currency: currency)
      r['status'] == 'ok'
    end
  end
end<commit_msg>Client#deposit_address returns false in case of error.<commit_after>module Bitstamp
  class Client
  
    def initialize(client_id, key, secret, curr_pair = DEFAULT_CURR_PAIR)
      @net = Bitstamp::NetComm.new(client_id, key, secret, curr_pair)
      @curr_pair = curr_pair[0..2], curr_pair[3..5]
    end


    # Get ticker data
    def ticker
      data = @net.get('ticker')
      Bitstamp::Model::Ticker.new(data)
    end


    def order_book
      data = @net.get('order_book')
      data['timestamp'] = Time.at(data['timestamp'].to_i)
      %w(asks bids).each do |dir|
        data[dir].map!{ |e| Bitstamp::Model::Offer.new(e) }
      end
      data
    end
    

    # Access to tranasactions
    def transactions
      @transactions ||= Bitstamp::Transactions.new(@net, @curr_pair)
    end


    # Get balances
    def balances
      r = Hash.new
      data = @net.post('balance')
      @curr_pair.each do |curr|
        r[curr.upcase] = Bitstamp::Model::Balance.new(
                            currency: curr.upcase,
                            balance: data["#{curr}_balance"],
                            available: data["#{curr}_available"],
                            reserved: data["#{curr}_reserved"]
                         )
      end
      r
    end
    

    # Access to orders
    def orders
      @orders ||= Bitstamp::Orders.new(@net)
    end

    def withdraw_btc(amount, address)
      r = @net.post('bitcoin_withdrawal', amount: amount, address: address)
      r['id']
    end


    def deposit_address
      r = @net.post('bitcoin_deposit_address') \
              .tr('"', '')
      r.include?('error') ? false : r
    end


    def unconfirmed_deposits
      @net.post('unconfirmed_btc')
    end

    
    def transfer_main_to_sub(sub_account_id, amount, currency = 'BTC')
      r = @net.post('transfer-from-main', subAccount: sub_account_id,
                                          amount: amount,
                                          currency: currency)
      r['status'] == 'ok'
    end


    def transfer_sub_to_main(amount, currency = 'BTC')
      r = @net.post('transfer-to-main', amount: amount,
                                        currency: currency)
      r['status'] == 'ok'
    end
  end
end
{'fraction_non_alphanumeric': 0.12116390088656513, 'fraction_numerical': 0.0018185951352580132, 'mean_word_length': 1.8241335044929397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1320841', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1344, 'n_words': 281}