import { Injectable, Inject } from '@nestjs/common'
import { AxiosInstance } from 'axios'

@Injectable()
export class CustomerService {
    constructor(
        @Inject('QUICKBOOKS_API') private readonly quickbooksApi: AxiosInstance
    ) {}

	async getCustomer(customerId: string) {
        try {
			const response = await this.quickbooksApi.get(`customer/${customerId}`)
			return response.data?.Customer
        } catch (error) {
            throw new Error(`Failed to get customer ${customerId}: ${error.message}`)
        }
	}
}
