<commit_before>module MercadoPagoApiSupport
  def mock_authenticate(client_id, client_secret)
    headers = default_api_headers.merge({'Content-Length' => '63', 'Content-Type' => 'application/x-www-form-urlencoded'})
    mock_api_call mercado_pago_api_url, '/oauth/token',
                  headers: headers,
                  method: :post,
                  body: {'client_id' => client_id, 'client_secret' => client_secret, 'grant_type' => "client_credentials"},
                  return_body: authenticated_json
  end

  def mock_get_money_request(money_request_id, status = nil)
    response = money_request_json(status)
    mock_api_call mercado_pago_api_url, "/money_requests/#{money_request_id}?access_token=#{access_token}",
                  return_body: response
  end

  def mock_get_payment_status(external_reference, status = 'pending')
    return_body = { results: [{ collection: { status: status } }] }.to_json.to_s
    mock_api_call mercado_pago_api_url, "/collections/search?access_token=#{access_token}&external_reference=#{external_reference}",
                  return_body: return_body,
                  headers: {'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}
  end

  def money_request_json(status = nil)
    money_request = open_fixture('money_request.json')
    if status
      money_request = JSON.parse(money_request, symbolize_names: true)
      money_request[:status] = status<commit_msg>if status nil then empty response<commit_after>module MercadoPagoApiSupport
  def mock_authenticate(client_id, client_secret)
    headers = default_api_headers.merge({'Content-Length' => '63', 'Content-Type' => 'application/x-www-form-urlencoded'})
    mock_api_call mercado_pago_api_url, '/oauth/token',
                  headers: headers,
                  method: :post,
                  body: {'client_id' => client_id, 'client_secret' => client_secret, 'grant_type' => "client_credentials"},
                  return_body: authenticated_json
  end

  def mock_get_money_request(money_request_id, status = nil)
    response = money_request_json(status)
    mock_api_call mercado_pago_api_url, "/money_requests/#{money_request_id}?access_token=#{access_token}",
                  return_body: response
  end

  def mock_get_payment_status(external_reference, status = nil)
    return_body = (status ? { results: [{ collection: { status: status } }] }: { results: [] }).to_json
    mock_api_call mercado_pago_api_url, "/collections/search?access_token=#{access_token}&external_reference=#{external_reference}",
                  return_body: return_body,
                  headers: {'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}
  end

  def money_request_json(status = nil)
    money_request = open_fixture('money_request.json')
    if status
      money_request = JSON.parse(money_request, symbolize_names: true)
      money_request[:status] = status
{'fraction_non_alphanumeric': 0.11983067404754151, 'fraction_numerical': 0.0013025073266037122, 'mean_word_length': 3.8995215311004783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6527540', 'n_tokens_mistral': 961, 'n_tokens_neox': 918, 'n_words': 158}