feat: implement SalesInvoiceTspSwitchService and SalesInvoiceTspService for handling TSP provider interactions

- Add SalesInvoiceTspSwitchService to manage TSP provider selection and sending invoices.
- Introduce SalesInvoiceTspService for creating, sending, and retrieving sales invoices.
- Implement NamaProviderSwitchAdapter for communication with the NAMA TSP provider API.
- Define DTOs for request and response structures specific to the NAMA provider.
- Enhance error handling and logging for TSP provider interactions.
This commit is contained in:
2026-05-03 16:23:17 +03:30
parent ad470d2166
commit a486127ade
62 changed files with 4136 additions and 5015 deletions
+47
View File
@@ -0,0 +1,47 @@
import {
FetchRequestContext,
FetchRequestInterceptor,
} from '@/common/interceptors/fetch-request.interceptor'
import { Injectable } from '@nestjs/common'
@Injectable()
export class HttpClientUtil {
async request(
url: string,
init: RequestInit = {},
interceptors: FetchRequestInterceptor[] = [],
): Promise<Response> {
let context: FetchRequestContext = { url, init }
for (const interceptor of interceptors) {
if (!interceptor.onRequest) {
continue
}
context = await interceptor.onRequest(context)
}
try {
let response = await fetch(context.url, context.init)
for (const interceptor of interceptors) {
if (!interceptor.onResponse) {
continue
}
response = await interceptor.onResponse(context, response)
console.log('response')
console.log(response)
}
return response
} catch (error: any) {
for (const interceptor of interceptors) {
if (!interceptor.onError) {
continue
}
await interceptor.onError(context, error)
}
throw error
}
}
}
+1
View File
@@ -3,3 +3,4 @@ export * from './enum-translator.util'
export * from './mappers/consumer_mappers.util'
export * from './password.util'
export * from './tracking-code-generator.util'
export * from './http-client.util'