// Direct test of Helcim API with your token
// Run with: node test-helcim-direct.js

const token = process.env.NUXT_PUBLIC_HELCIM_TOKEN || 'aG_Eu%lqXCIJdWb2fUx52P_*-9GzaUHAVXvRjF43#sZw_FEeV9q7gl$pe$1EPRNs'

async function testHelcimConnection() {
  console.log('Testing Helcim API connection...')
  console.log('Token length:', token.length)
  console.log('Token prefix:', token.substring(0, 10) + '...')
  
  try {
    // Test 1: Try to get connection test
    const testResponse = await fetch('https://api.helcim.com/v2/connection-test', {
      method: 'GET',
      headers: {
        'accept': 'application/json',
        'api-token': token
      }
    })
    
    console.log('Connection test status:', testResponse.status)
    const testData = await testResponse.text()
    console.log('Connection test response:', testData)
    
    // Test 2: Try to create a customer
    const customerResponse = await fetch('https://api.helcim.com/v2/customers', {
      method: 'POST',
      headers: {
        'accept': 'application/json',
        'content-type': 'application/json',
        'api-token': token
      },
      body: JSON.stringify({
        customerType: 'PERSON',
        contactName: 'Test User',
        email: 'test@example.com'
      })
    })
    
    console.log('\nCreate customer status:', customerResponse.status)
    const customerData = await customerResponse.text()
    console.log('Create customer response:', customerData)
    
  } catch (error) {
    console.error('Error:', error)
  }
}

testHelcimConnection()